@ekanos/cli 0.17.0 → 0.18.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.
Files changed (71) hide show
  1. package/README.md +1 -0
  2. package/dist/commands/catalog.js +11 -7
  3. package/dist/commands/catalog.js.map +1 -1
  4. package/dist/commands/names.d.ts +19 -0
  5. package/dist/commands/names.js +122 -0
  6. package/dist/commands/names.js.map +1 -0
  7. package/dist/commands/publish.d.ts +53 -3
  8. package/dist/commands/publish.js +58 -16
  9. package/dist/commands/publish.js.map +1 -1
  10. package/dist/commands/sources.js +15 -5
  11. package/dist/commands/sources.js.map +1 -1
  12. package/dist/commands/status.d.ts +2 -0
  13. package/dist/commands/status.js +12 -12
  14. package/dist/commands/status.js.map +1 -1
  15. package/dist/commands/teams-connect.js +1 -1
  16. package/dist/commands/teams-connect.js.map +1 -1
  17. package/dist/experience/boundary.d.ts +2 -2
  18. package/dist/experience/boundary.js +2 -11
  19. package/dist/experience/boundary.js.map +1 -1
  20. package/dist/experience/build.d.ts +3 -1
  21. package/dist/experience/build.js +15 -26
  22. package/dist/experience/build.js.map +1 -1
  23. package/dist/experience/clean-room.d.ts +40 -0
  24. package/dist/experience/clean-room.js +150 -0
  25. package/dist/experience/clean-room.js.map +1 -0
  26. package/dist/experience/definition-checks.d.ts +12 -1
  27. package/dist/experience/definition-checks.js +34 -11
  28. package/dist/experience/definition-checks.js.map +1 -1
  29. package/dist/experience/definition-shape.d.ts +20 -2
  30. package/dist/experience/definition-shape.js.map +1 -1
  31. package/dist/experience/publish.d.ts +42 -5
  32. package/dist/experience/publish.js +195 -11
  33. package/dist/experience/publish.js.map +1 -1
  34. package/dist/harness-scaffold.js +3 -1
  35. package/dist/harness-scaffold.js.map +1 -1
  36. package/dist/index.js +25 -2
  37. package/dist/index.js.map +1 -1
  38. package/dist/names-api.d.ts +90 -0
  39. package/dist/names-api.js +123 -0
  40. package/dist/names-api.js.map +1 -0
  41. package/dist/pack.js +5 -0
  42. package/dist/pack.js.map +1 -1
  43. package/dist/product-kinds.d.ts +13 -0
  44. package/dist/product-kinds.js +17 -0
  45. package/dist/product-kinds.js.map +1 -0
  46. package/dist/project-checks.d.ts +7 -0
  47. package/dist/project-checks.js +47 -0
  48. package/dist/project-checks.js.map +1 -1
  49. package/dist/publish-api.d.ts +38 -5
  50. package/dist/publish-api.js +59 -16
  51. package/dist/publish-api.js.map +1 -1
  52. package/dist/repo/publish.d.ts +6 -3
  53. package/dist/repo/publish.js +48 -14
  54. package/dist/repo/publish.js.map +1 -1
  55. package/dist/source-products-api.d.ts +3 -2
  56. package/dist/source-products-api.js +1 -1
  57. package/dist/source-products-api.js.map +1 -1
  58. package/dist/team-connect-api.d.ts +4 -0
  59. package/dist/team-connect-api.js +1 -1
  60. package/dist/team-connect-api.js.map +1 -1
  61. package/dist/toolchain-api.d.ts +15 -0
  62. package/dist/toolchain-api.js +12 -1
  63. package/dist/toolchain-api.js.map +1 -1
  64. package/dist/validate-findings.js +2 -1
  65. package/dist/validate-findings.js.map +1 -1
  66. package/package.json +2 -2
  67. package/templates/experience/package.json.tmpl +7 -4
  68. package/templates/harness/app/experience/layout/page.tsx.tmpl +1 -0
  69. package/templates/harness/app/experience/layout.tsx.tmpl +3 -0
  70. package/templates/harness/app/experience/pages/[id]/[...path]/page.tsx.tmpl +1 -0
  71. package/templates/package.json.tmpl +5 -4
@@ -0,0 +1,90 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * The CLI's client for package names: the pre-flight that says what a slug
4
+ * will be called, and the global-name claims.
5
+ *
6
+ * GET /api/partner/slugs/<slug>?source=<slug|id>[&availability=global|restricted]
7
+ * → 200 { ok: true, data: { slug, status, available, namespace,
8
+ * displayName, token, availability, claim } }
9
+ * `status` is the host's word for the slug (`global_unapproved` when a
10
+ * global package has no approved name). Every field past `available` is
11
+ * optional here: an older host omits them.
12
+ *
13
+ * POST /api/partner/names/claims { source, slug, reason? }
14
+ * → 201 { ok: true, data: { id, slug, status: "requested", createdAt } }
15
+ * → 409 { code: "CLAIM_EXISTS" | "SLUG_RESERVED" | "SLUG_TAKEN" }
16
+ *
17
+ * GET /api/partner/names/claims/<slug>?source=<slug|id>
18
+ * → 200 { ok: true, data: { slug, status: "none" | "requested" |
19
+ * "approved" | "rejected", reason, requestedAt, decidedAt } }
20
+ *
21
+ * → 400 INVALID_REQUEST · 401 / 3xx refresh once and retry · 403 FORBIDDEN
22
+ * (no developer seat) or MFA_REQUIRED · 404 SOURCE_NOT_FOUND
23
+ */
24
+ export type NamesApiResult<T> = {
25
+ status: 'ok';
26
+ data: T;
27
+ } | {
28
+ status: 'unauthorized';
29
+ };
30
+ export declare const SlugLookupSchema: z.ZodObject<{
31
+ slug: z.ZodString;
32
+ status: z.ZodString;
33
+ available: z.ZodBoolean;
34
+ namespace: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
+ displayName: z.ZodOptional<z.ZodString>;
36
+ token: z.ZodOptional<z.ZodString>;
37
+ availability: z.ZodOptional<z.ZodEnum<{
38
+ global: "global";
39
+ restricted: "restricted";
40
+ }>>;
41
+ claim: z.ZodOptional<z.ZodNullable<z.ZodObject<{
42
+ status: z.ZodEnum<{
43
+ approved: "approved";
44
+ rejected: "rejected";
45
+ requested: "requested";
46
+ }>;
47
+ reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ }, z.core.$strip>>>;
49
+ }, z.core.$strip>;
50
+ export type SlugLookup = z.infer<typeof SlugLookupSchema>;
51
+ export declare const NameClaimRequestedSchema: z.ZodObject<{
52
+ id: z.ZodString;
53
+ slug: z.ZodString;
54
+ status: z.ZodLiteral<"requested">;
55
+ createdAt: z.ZodString;
56
+ }, z.core.$strip>;
57
+ export type NameClaimRequested = z.infer<typeof NameClaimRequestedSchema>;
58
+ export declare const NameClaimStatusSchema: z.ZodObject<{
59
+ slug: z.ZodString;
60
+ status: z.ZodEnum<{
61
+ approved: "approved";
62
+ none: "none";
63
+ rejected: "rejected";
64
+ requested: "requested";
65
+ }>;
66
+ reason: z.ZodNullable<z.ZodString>;
67
+ requestedAt: z.ZodNullable<z.ZodString>;
68
+ decidedAt: z.ZodNullable<z.ZodString>;
69
+ }, z.core.$strip>;
70
+ export type NameClaimStatus = z.infer<typeof NameClaimStatusSchema>;
71
+ /**
72
+ * What the host will call a slug for this Source. `unavailable` is any answer
73
+ * that is not the lookup (an older host without the route, a server error, a
74
+ * shape this CLI does not read): the caller carries on with the bare slug.
75
+ */
76
+ export type SlugLookupResult = {
77
+ status: 'ok';
78
+ lookup: SlugLookup;
79
+ } | {
80
+ status: 'unavailable';
81
+ } | {
82
+ status: 'unauthorized';
83
+ };
84
+ export declare function lookupSlug(host: string, accessToken: string, source: string, slug: string, availability?: 'global' | 'restricted'): Promise<SlugLookupResult>;
85
+ export declare function requestNameClaim(host: string, accessToken: string, body: {
86
+ source: string;
87
+ slug: string;
88
+ reason?: string;
89
+ }): Promise<NamesApiResult<NameClaimRequested>>;
90
+ export declare function getNameClaim(host: string, accessToken: string, source: string, slug: string): Promise<NamesApiResult<NameClaimStatus>>;
@@ -0,0 +1,123 @@
1
+ import { z } from 'zod';
2
+ import { request } from './auth/ekanos-api.js';
3
+ import { authRequiredError, forbiddenError, invalidStateError, networkError, notFoundError, validationError, } from './errors.js';
4
+ export const SlugLookupSchema = z.object({
5
+ slug: z.string(),
6
+ status: z.string(),
7
+ available: z.boolean(),
8
+ namespace: z.string().nullable().optional(),
9
+ displayName: z.string().optional(),
10
+ token: z.string().optional(),
11
+ availability: z.enum(['global', 'restricted']).optional(),
12
+ claim: z
13
+ .object({
14
+ status: z.enum(['requested', 'approved', 'rejected']),
15
+ reason: z.string().nullable().optional(),
16
+ })
17
+ .nullable()
18
+ .optional(),
19
+ });
20
+ export const NameClaimRequestedSchema = z.object({
21
+ id: z.string(),
22
+ slug: z.string(),
23
+ status: z.literal('requested'),
24
+ createdAt: z.string(),
25
+ });
26
+ export const NameClaimStatusSchema = z.object({
27
+ slug: z.string(),
28
+ status: z.enum(['none', 'requested', 'approved', 'rejected']),
29
+ reason: z.string().nullable(),
30
+ requestedAt: z.string().nullable(),
31
+ decidedAt: z.string().nullable(),
32
+ });
33
+ export async function lookupSlug(host, accessToken, source, slug, availability) {
34
+ const query = new URLSearchParams({ source });
35
+ if (availability)
36
+ query.set('availability', availability);
37
+ const response = await request(`${host}/api/partner/slugs/${encodeURIComponent(slug)}?${query}`, { method: 'GET', headers: headers(accessToken) });
38
+ if (isUnauthorized(response.status))
39
+ return { status: 'unauthorized' };
40
+ if (!response.ok)
41
+ return { status: 'unavailable' };
42
+ const body = await readOptionalJson(response);
43
+ const parsed = SlugLookupSchema.safeParse(body.data);
44
+ return parsed.success
45
+ ? { status: 'ok', lookup: parsed.data }
46
+ : { status: 'unavailable' };
47
+ }
48
+ export function requestNameClaim(host, accessToken, body) {
49
+ return call(host, accessToken, '/api/partner/names/claims', NameClaimRequestedSchema, { method: 'POST', body });
50
+ }
51
+ export function getNameClaim(host, accessToken, source, slug) {
52
+ return call(host, accessToken, `/api/partner/names/claims/${encodeURIComponent(slug)}?${new URLSearchParams({ source })}`, NameClaimStatusSchema, { method: 'GET' });
53
+ }
54
+ async function call(host, accessToken, path, schema, init) {
55
+ const response = await request(`${host}${path}`, {
56
+ method: init.method,
57
+ headers: Object.assign(Object.assign({}, headers(accessToken)), (init.body === undefined
58
+ ? {}
59
+ : { 'content-type': 'application/json' })),
60
+ body: init.body === undefined ? undefined : JSON.stringify(init.body),
61
+ });
62
+ if (isUnauthorized(response.status))
63
+ return { status: 'unauthorized' };
64
+ const body = await readOptionalJson(response);
65
+ const code = typeof body.code === 'string' ? body.code : null;
66
+ const message = typeof body.error === 'string' && body.error ? body.error : null;
67
+ const route = path.split('?')[0];
68
+ if (response.status === 403 && code === 'MFA_REQUIRED') {
69
+ throw authRequiredError(message !== null && message !== void 0 ? message : `${host} requires multi-factor authentication.`, 'Complete MFA in the browser, then run "ekanos login" again.');
70
+ }
71
+ if (response.status === 403) {
72
+ throw forbiddenError(message !== null && message !== void 0 ? message : 'This account does not hold the developer seat on the Source.', 'Ask the Source operator for the developer seat, or run "ekanos sources" to list the sources you hold a seat on.');
73
+ }
74
+ if (response.status === 404) {
75
+ throw notFoundError(message !== null && message !== void 0 ? message : 'Source not found.', 'Check --source against "ekanos sources".');
76
+ }
77
+ if (response.status === 409) {
78
+ throw invalidStateError(message !== null && message !== void 0 ? message : 'The host refused the claim.', conflictHint(code));
79
+ }
80
+ if (response.status === 400) {
81
+ throw validationError(message !== null && message !== void 0 ? message : 'The host refused the request.', 'Names are kebab-case, e.g. "google-drive". See "ekanos names --help".');
82
+ }
83
+ if (!response.ok) {
84
+ throw networkError(`${host}${route} responded ${response.status}.`, response.status >= 500
85
+ ? 'The Ekanos deployment returned a server error. Retry shortly.'
86
+ : 'Confirm the host runs a build that includes the names routes.');
87
+ }
88
+ const parsed = schema.safeParse(body.data);
89
+ if (!parsed.success) {
90
+ throw networkError(`${host}${route} answered in a shape this CLI does not read.`, 'Run "ekanos upgrade" - the CLI and the host disagree on the names contract.');
91
+ }
92
+ return { status: 'ok', data: parsed.data };
93
+ }
94
+ function conflictHint(code) {
95
+ switch (code) {
96
+ case 'CLAIM_EXISTS':
97
+ return 'A claim for this name is already open; check it with "ekanos names status <slug>".';
98
+ case 'SLUG_RESERVED':
99
+ return 'This name is reserved. Pick another, or publish restricted under your Source namespace.';
100
+ case 'SLUG_TAKEN':
101
+ return 'Another package already holds this name. Pick another, or publish restricted under your Source namespace.';
102
+ default:
103
+ return 'Check the claim with "ekanos names status <slug>".';
104
+ }
105
+ }
106
+ function headers(accessToken) {
107
+ return { accept: 'application/json', authorization: `Bearer ${accessToken}` };
108
+ }
109
+ function isUnauthorized(status) {
110
+ return status === 401 || (status >= 300 && status < 400);
111
+ }
112
+ async function readOptionalJson(response) {
113
+ try {
114
+ const parsed = await response.json();
115
+ return typeof parsed === 'object' && parsed !== null
116
+ ? parsed
117
+ : {};
118
+ }
119
+ catch (_a) {
120
+ return {};
121
+ }
122
+ }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,CAAC,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,QAAkB;IAElB,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAE9C,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;YAClD,CAAC,CAAE,MAAkC;YACrC,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;eAAO,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["import { z } from 'zod';\n\nimport { request } from './auth/ekanos-api';\nimport {\n authRequiredError,\n forbiddenError,\n invalidStateError,\n networkError,\n notFoundError,\n validationError,\n} from './errors';\n\n/**\n * The CLI's client for package names: the pre-flight that says what a slug\n * will be called, and the global-name claims.\n *\n * GET /api/partner/slugs/<slug>?source=<slug|id>[&availability=global|restricted]\n * → 200 { ok: true, data: { slug, status, available, namespace,\n * displayName, token, availability, claim } }\n * `status` is the host's word for the slug (`global_unapproved` when a\n * global package has no approved name). Every field past `available` is\n * optional here: an older host omits them.\n *\n * POST /api/partner/names/claims { source, slug, reason? }\n * → 201 { ok: true, data: { id, slug, status: \"requested\", createdAt } }\n * → 409 { code: \"CLAIM_EXISTS\" | \"SLUG_RESERVED\" | \"SLUG_TAKEN\" }\n *\n * GET /api/partner/names/claims/<slug>?source=<slug|id>\n * → 200 { ok: true, data: { slug, status: \"none\" | \"requested\" |\n * \"approved\" | \"rejected\", reason, requestedAt, decidedAt } }\n *\n * → 400 INVALID_REQUEST · 401 / 3xx refresh once and retry · 403 FORBIDDEN\n * (no developer seat) or MFA_REQUIRED · 404 SOURCE_NOT_FOUND\n */\n\nexport type NamesApiResult<T> =\n | { status: 'ok'; data: T }\n | { status: 'unauthorized' };\n\nexport const SlugLookupSchema = z.object({\n slug: z.string(),\n status: z.string(),\n available: z.boolean(),\n namespace: z.string().nullable().optional(),\n displayName: z.string().optional(),\n token: z.string().optional(),\n availability: z.enum(['global', 'restricted']).optional(),\n claim: z\n .object({\n status: z.enum(['requested', 'approved', 'rejected']),\n reason: z.string().nullable().optional(),\n })\n .nullable()\n .optional(),\n});\n\nexport type SlugLookup = z.infer<typeof SlugLookupSchema>;\n\nexport const NameClaimRequestedSchema = z.object({\n id: z.string(),\n slug: z.string(),\n status: z.literal('requested'),\n createdAt: z.string(),\n});\n\nexport type NameClaimRequested = z.infer<typeof NameClaimRequestedSchema>;\n\nexport const NameClaimStatusSchema = z.object({\n slug: z.string(),\n status: z.enum(['none', 'requested', 'approved', 'rejected']),\n reason: z.string().nullable(),\n requestedAt: z.string().nullable(),\n decidedAt: z.string().nullable(),\n});\n\nexport type NameClaimStatus = z.infer<typeof NameClaimStatusSchema>;\n\n/**\n * What the host will call a slug for this Source. `unavailable` is any answer\n * that is not the lookup (an older host without the route, a server error, a\n * shape this CLI does not read): the caller carries on with the bare slug.\n */\nexport type SlugLookupResult =\n | { status: 'ok'; lookup: SlugLookup }\n | { status: 'unavailable' }\n | { status: 'unauthorized' };\n\nexport async function lookupSlug(\n host: string,\n accessToken: string,\n source: string,\n slug: string,\n availability?: 'global' | 'restricted',\n): Promise<SlugLookupResult> {\n const query = new URLSearchParams({ source });\n if (availability) query.set('availability', availability);\n\n const response = await request(\n `${host}/api/partner/slugs/${encodeURIComponent(slug)}?${query}`,\n { method: 'GET', headers: headers(accessToken) },\n );\n\n if (isUnauthorized(response.status)) return { status: 'unauthorized' };\n if (!response.ok) return { status: 'unavailable' };\n\n const body = await readOptionalJson(response);\n const parsed = SlugLookupSchema.safeParse(body.data);\n\n return parsed.success\n ? { status: 'ok', lookup: parsed.data }\n : { status: 'unavailable' };\n}\n\nexport function requestNameClaim(\n host: string,\n accessToken: string,\n body: { source: string; slug: string; reason?: string },\n): Promise<NamesApiResult<NameClaimRequested>> {\n return call(\n host,\n accessToken,\n '/api/partner/names/claims',\n NameClaimRequestedSchema,\n { method: 'POST', body },\n );\n}\n\nexport function getNameClaim(\n host: string,\n accessToken: string,\n source: string,\n slug: string,\n): Promise<NamesApiResult<NameClaimStatus>> {\n return call(\n host,\n accessToken,\n `/api/partner/names/claims/${encodeURIComponent(slug)}?${new URLSearchParams({ source })}`,\n NameClaimStatusSchema,\n { method: 'GET' },\n );\n}\n\nasync function call<T>(\n host: string,\n accessToken: string,\n path: string,\n schema: z.ZodType<T>,\n init: { method: 'GET' | 'POST'; body?: unknown },\n): Promise<NamesApiResult<T>> {\n const response = await request(`${host}${path}`, {\n method: init.method,\n headers: {\n ...headers(accessToken),\n ...(init.body === undefined\n ? {}\n : { 'content-type': 'application/json' }),\n },\n body: init.body === undefined ? undefined : JSON.stringify(init.body),\n });\n\n if (isUnauthorized(response.status)) return { status: 'unauthorized' };\n\n const body = await readOptionalJson(response);\n const code = typeof body.code === 'string' ? body.code : null;\n const message =\n typeof body.error === 'string' && body.error ? body.error : null;\n const route = path.split('?')[0];\n\n if (response.status === 403 && code === 'MFA_REQUIRED') {\n throw authRequiredError(\n message ?? `${host} requires multi-factor authentication.`,\n 'Complete MFA in the browser, then run \"ekanos login\" again.',\n );\n }\n if (response.status === 403) {\n throw forbiddenError(\n message ?? 'This account does not hold the developer seat on the Source.',\n 'Ask the Source operator for the developer seat, or run \"ekanos sources\" to list the sources you hold a seat on.',\n );\n }\n if (response.status === 404) {\n throw notFoundError(\n message ?? 'Source not found.',\n 'Check --source against \"ekanos sources\".',\n );\n }\n if (response.status === 409) {\n throw invalidStateError(\n message ?? 'The host refused the claim.',\n conflictHint(code),\n );\n }\n if (response.status === 400) {\n throw validationError(\n message ?? 'The host refused the request.',\n 'Names are kebab-case, e.g. \"google-drive\". See \"ekanos names --help\".',\n );\n }\n if (!response.ok) {\n throw networkError(\n `${host}${route} responded ${response.status}.`,\n response.status >= 500\n ? 'The Ekanos deployment returned a server error. Retry shortly.'\n : 'Confirm the host runs a build that includes the names routes.',\n );\n }\n\n const parsed = schema.safeParse(body.data);\n if (!parsed.success) {\n throw networkError(\n `${host}${route} answered in a shape this CLI does not read.`,\n 'Run \"ekanos upgrade\" - the CLI and the host disagree on the names contract.',\n );\n }\n\n return { status: 'ok', data: parsed.data };\n}\n\nfunction conflictHint(code: string | null): string {\n switch (code) {\n case 'CLAIM_EXISTS':\n return 'A claim for this name is already open; check it with \"ekanos names status <slug>\".';\n case 'SLUG_RESERVED':\n return 'This name is reserved. Pick another, or publish restricted under your Source namespace.';\n case 'SLUG_TAKEN':\n return 'Another package already holds this name. Pick another, or publish restricted under your Source namespace.';\n default:\n return 'Check the claim with \"ekanos names status <slug>\".';\n }\n}\n\nfunction headers(accessToken: string): Record<string, string> {\n return { accept: 'application/json', authorization: `Bearer ${accessToken}` };\n}\n\nfunction isUnauthorized(status: number): boolean {\n return status === 401 || (status >= 300 && status < 400);\n}\n\nasync function readOptionalJson(\n response: Response,\n): Promise<Record<string, unknown>> {\n try {\n const parsed: unknown = await response.json();\n\n return typeof parsed === 'object' && parsed !== null\n ? (parsed as Record<string, unknown>)\n : {};\n } catch {\n return {};\n }\n}\n"]}
package/dist/pack.js CHANGED
@@ -14,6 +14,8 @@ import { ESLINT_CONFIG_NAMES, VITEST_CONFIG_NAMES } from './project-checks.js';
14
14
  *
15
15
  * - `ekanos.json`, `package.json` (required)
16
16
  * - `README.md` (when present)
17
+ * - `contract.json` (when present): the hosted gate's `checks/contract-emit`
18
+ * compares it to what the code derives and refuses an archive without it
17
19
  * - `tsconfig*.json` at the project root (when present)
18
20
  * - a vitest/vite config at the project root (when present — see
19
21
  * `VITEST_CONFIG_NAMES`)
@@ -86,6 +88,9 @@ export function selectProjectFiles(projectDir) {
86
88
  if (isRegularFile(path.join(projectDir, 'README.md'))) {
87
89
  selected.push('README.md');
88
90
  }
91
+ if (isRegularFile(path.join(projectDir, 'contract.json'))) {
92
+ selected.push('contract.json');
93
+ }
89
94
  selected.push(...selectRootConfigFiles(projectDir));
90
95
  const srcDir = path.join(projectDir, 'src');
91
96
  // lstat, not stat: `src` itself as a symlink must not pull a foreign tree
package/dist/pack.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pack.js","sourceRoot":"","sources":["../src/pack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,+EAA+E;AAC/E,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,2EAA2E;AAC3E,2EAA2E;AAC3E,6EAA6E;AAC7E,wCAAwC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AASjD,MAAM,UAAU,WAAW,CAAC,UAAkB;IAC5C,MAAM,KAAK,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAE7C,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE1C,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACjD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAErB,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC;QAC9C,IAAI,SAAS,KAAK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AAc,CAAC,YAAoB;IAI1C,IAAI,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACnD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC5C,CAAC;IAED,kEAAkE;IAClE,KAAK,IAAI,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,GAAG;YAAE,SAAS;QAEtC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAEvC,IACE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG;YACtC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,GAAG,EACxC,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,MAAM,eAAe,CACnB,gBAAgB,YAAY,0CAA0C,EACtE,qEAAqE;QACnE,2BAA2B,CAC9B,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,MAAc,EACd,MAAc,EACd,MAAc,EACd,KAAa;IAEb,MAAM,CAAC,KAAK,CACV,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,IAAI,EAClD,MAAM,EACN,MAAM,EACN,QAAQ,CACT,CAAC;AACJ,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as zlib from 'node:zlib';\n\nimport { preconditionError, validationError } from './errors';\nimport { ESLINT_CONFIG_NAMES, VITEST_CONFIG_NAMES } from './project-checks';\n\n/**\n * Deterministic project packing for `ekanos publish`.\n *\n * A minimal ustar writer over Node's built-ins — no `tar` dependency. The\n * selection is deliberately a WHITELIST, not \"everything minus a blocklist\":\n * the submission is reviewed by an operator and installed into Ekanos, so the\n * archive must contain exactly the files the toolchain knows about and\n * nothing a working directory happens to hold.\n *\n * - `ekanos.json`, `package.json` (required)\n * - `README.md` (when present)\n * - `tsconfig*.json` at the project root (when present)\n * - a vitest/vite config at the project root (when present — see\n * `VITEST_CONFIG_NAMES`)\n * - an ESLint flat config at the project root (when present — see\n * `ESLINT_CONFIG_NAMES`): the gate's `checks/capability-lint` runs the\n * capability preset from it, and refuses an archive without one\n * - everything under `src/`, recursively\n *\n * The tsconfig/vitest entries exist because the hosted gate's\n * `checks/typecheck` and `checks/tests` stages run the project's OWN `tsc`\n * and `vitest` — over the ARCHIVE, not the partner's working directory — so\n * without them there is no `tsconfig.json` to compile against (`tsc --noEmit`\n * falls back to printing its help text and exiting 1, not a type error) and\n * no test config to load the SDK's server-inline block. `ekanos init`\n * scaffolds both at the project root, so a project published straight from\n * `init` always has them; this walk just stops silently dropping them.\n *\n * Excluded everywhere: dotfiles and dot-directories (which covers `.ekanos`,\n * `.git`, `.env`), `node_modules`, and anything that is not a regular file\n * (symlinks are skipped, not followed — a link pointing outside the project\n * must never pull foreign bytes into a submission).\n *\n * Determinism: entries are sorted by path and every header carries a fixed\n * mtime, so packing the same tree twice yields byte-identical archives and a\n * stable sha256.\n */\n\nconst BLOCK_SIZE = 512;\n\n/** Fixed header mtime — determinism over provenance (the VCS owns history). */\nconst FIXED_MTIME_SECONDS = 0;\n\n/** The server refuses archives over 5 MiB; fail fast on the client too. */\n// 4 MiB — mirrors the server route's cap, which itself sits under Vercel's\n// ~4.5 MB request-body ceiling so oversize is caught here with a clear error\n// instead of by an opaque platform 413.\nexport const MAX_ARCHIVE_BYTES = 4 * 1024 * 1024;\n\nexport interface PackedProject {\n /** The gzipped tarball. */\n archive: Buffer;\n /** Project-relative POSIX paths, in the order they were packed. */\n files: string[];\n}\n\nexport function packProject(projectDir: string): PackedProject {\n const files = selectProjectFiles(projectDir);\n\n const blocks: Buffer[] = [];\n\n for (const relative of files) {\n const absolute = path.join(projectDir, relative);\n const content = fs.readFileSync(absolute);\n\n blocks.push(tarHeader(relative, content.length));\n blocks.push(content);\n\n const remainder = content.length % BLOCK_SIZE;\n if (remainder !== 0) {\n blocks.push(Buffer.alloc(BLOCK_SIZE - remainder));\n }\n }\n\n // End-of-archive: two zero blocks.\n blocks.push(Buffer.alloc(BLOCK_SIZE * 2));\n\n const archive = zlib.gzipSync(Buffer.concat(blocks), { level: 9 });\n\n if (archive.length > MAX_ARCHIVE_BYTES) {\n throw validationError(\n `The packed archive is ${archive.length} bytes, over the ` +\n `${MAX_ARCHIVE_BYTES}-byte submission limit.`,\n 'Reduce the project to source only — large binary assets do not ' +\n 'belong in an integration submission.',\n );\n }\n\n return { archive, files };\n}\n\n/**\n * The whitelist walk. Exported for tests: the selection rules are the part\n * with security consequences, so they are asserted directly.\n */\nexport function selectProjectFiles(projectDir: string): string[] {\n for (const required of ['ekanos.json', 'package.json']) {\n if (!isRegularFile(path.join(projectDir, required))) {\n throw preconditionError(\n `Cannot pack ${projectDir}: ${required} is missing.`,\n `Run \"ekanos publish\" from an integration project (or pass --dir), ` +\n `and run \"ekanos init\" first if this is a new project.`,\n );\n }\n }\n\n const selected = ['ekanos.json', 'package.json'];\n\n if (isRegularFile(path.join(projectDir, 'README.md'))) {\n selected.push('README.md');\n }\n\n selected.push(...selectRootConfigFiles(projectDir));\n\n const srcDir = path.join(projectDir, 'src');\n // lstat, not stat: `src` itself as a symlink must not pull a foreign tree\n // into the archive — the same rule walk() applies to every entry inside.\n if (fs.existsSync(srcDir) && fs.lstatSync(srcDir).isDirectory()) {\n selected.push(...walk(projectDir, 'src'));\n }\n\n return selected.sort();\n}\n\n/** `tsconfig.json`, plus any sibling a root `tsconfig.json` might `extends`\n * (e.g. `tsconfig.build.json`) — matched by name, not content, since packing\n * runs before anything parses JSON with comments. Root-level only: this is\n * about the build/test config the gate's own stages need, not a recursive\n * search. */\nconst TSCONFIG_PATTERN = /^tsconfig(\\.[^./]+)?\\.json$/;\n\n/**\n * The project-root config files the hosted gate's `checks/typecheck`,\n * `checks/tests` and `checks/capability-lint` stages need to run the project's OWN `tsc`/`vitest`\n * meaningfully — see the module doc comment above. Each is included only\n * when present as a regular file (never a symlink, matching every other\n * entry point in this walk), so a project without one of these (unusual, but\n * not invalid) packs exactly as before.\n */\nfunction selectRootConfigFiles(projectDir: string): string[] {\n const selected: string[] = [];\n\n for (const entry of fs.readdirSync(projectDir, { withFileTypes: true })) {\n if (!TSCONFIG_PATTERN.test(entry.name)) continue;\n if (!isRegularFile(path.join(projectDir, entry.name))) continue;\n selected.push(entry.name);\n }\n\n for (const name of [...VITEST_CONFIG_NAMES, ...ESLINT_CONFIG_NAMES]) {\n if (isRegularFile(path.join(projectDir, name))) selected.push(name);\n }\n\n return selected;\n}\n\nfunction walk(projectDir: string, relativeDir: string): string[] {\n const absoluteDir = path.join(projectDir, relativeDir);\n const collected: string[] = [];\n\n for (const entry of fs.readdirSync(absoluteDir, { withFileTypes: true })) {\n if (entry.name.startsWith('.')) continue;\n if (entry.name === 'node_modules') continue;\n\n const relative = `${relativeDir}/${entry.name}`;\n\n if (entry.isDirectory()) {\n collected.push(...walk(projectDir, relative));\n continue;\n }\n\n // Regular files only. `isFile()` is false for symlinks under\n // `withFileTypes`, so a link — wherever it points — is skipped here.\n if (entry.isFile()) {\n collected.push(relative);\n }\n }\n\n return collected;\n}\n\nfunction isRegularFile(absolute: string): boolean {\n try {\n return fs.lstatSync(absolute).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * One 512-byte ustar header. Long paths use the ustar `prefix` field\n * (155 + '/' + 100); a path that fits neither is refused with a clear error\n * rather than silently truncated.\n */\nfunction tarHeader(relativePath: string, size: number): Buffer {\n const { name, prefix } = splitUstarPath(relativePath);\n const header = Buffer.alloc(BLOCK_SIZE);\n\n header.write(name, 0, 100, 'utf8');\n writeOctal(header, 100, 8, 0o644); // mode\n writeOctal(header, 108, 8, 0); // uid\n writeOctal(header, 116, 8, 0); // gid\n writeOctal(header, 124, 12, size);\n writeOctal(header, 136, 12, FIXED_MTIME_SECONDS);\n header.fill(' ', 148, 156); // checksum placeholder: eight spaces\n header.write('0', 156, 1, 'utf8'); // typeflag: regular file\n header.write('ustar', 257, 5, 'utf8');\n header.write('00', 263, 2, 'utf8'); // version\n header.write(prefix, 345, 155, 'utf8');\n\n let checksum = 0;\n for (const byte of header) checksum += byte;\n\n // Six octal digits, NUL, space — the historical checksum encoding.\n header.write(`${checksum.toString(8).padStart(6, '0')}\\0 `, 148, 8, 'latin1');\n\n return header;\n}\n\nfunction splitUstarPath(relativePath: string): {\n name: string;\n prefix: string;\n} {\n if (Buffer.byteLength(relativePath, 'utf8') <= 100) {\n return { name: relativePath, prefix: '' };\n }\n\n // Split at a '/' so that name ≤ 100 bytes and prefix ≤ 155 bytes.\n for (let i = relativePath.length - 1; i > 0; i--) {\n if (relativePath[i] !== '/') continue;\n\n const prefix = relativePath.slice(0, i);\n const name = relativePath.slice(i + 1);\n\n if (\n Buffer.byteLength(name, 'utf8') <= 100 &&\n Buffer.byteLength(prefix, 'utf8') <= 155\n ) {\n return { name, prefix };\n }\n }\n\n throw validationError(\n `Cannot pack \"${relativePath}\": the path is too long for a tar entry.`,\n 'Shorten the file path (tar limits one segment to 100 bytes and the ' +\n 'directory prefix to 155).',\n );\n}\n\nfunction writeOctal(\n header: Buffer,\n offset: number,\n length: number,\n value: number,\n): void {\n header.write(\n `${value.toString(8).padStart(length - 1, '0')}\\0`,\n offset,\n length,\n 'latin1',\n );\n}\n"]}
1
+ {"version":3,"file":"pack.js","sourceRoot":"","sources":["../src/pack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC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EAAE,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACnD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC5C,CAAC;IAED,kEAAkE;IAClE,KAAK,IAAI,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,GAAG;YAAE,SAAS;QAEtC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAEvC,IACE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG;YACtC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,GAAG,EACxC,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,MAAM,eAAe,CACnB,gBAAgB,YAAY,0CAA0C,EACtE,qEAAqE;QACnE,2BAA2B,CAC9B,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,MAAc,EACd,MAAc,EACd,MAAc,EACd,KAAa;IAEb,MAAM,CAAC,KAAK,CACV,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,CAAC,IAAI,EAClD,MAAM,EACN,MAAM,EACN,QAAQ,CACT,CAAC;AACJ,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as zlib from 'node:zlib';\n\nimport { preconditionError, validationError } from './errors';\nimport { ESLINT_CONFIG_NAMES, VITEST_CONFIG_NAMES } from './project-checks';\n\n/**\n * Deterministic project packing for `ekanos publish`.\n *\n * A minimal ustar writer over Node's built-ins — no `tar` dependency. The\n * selection is deliberately a WHITELIST, not \"everything minus a blocklist\":\n * the submission is reviewed by an operator and installed into Ekanos, so the\n * archive must contain exactly the files the toolchain knows about and\n * nothing a working directory happens to hold.\n *\n * - `ekanos.json`, `package.json` (required)\n * - `README.md` (when present)\n * - `contract.json` (when present): the hosted gate's `checks/contract-emit`\n * compares it to what the code derives and refuses an archive without it\n * - `tsconfig*.json` at the project root (when present)\n * - a vitest/vite config at the project root (when present — see\n * `VITEST_CONFIG_NAMES`)\n * - an ESLint flat config at the project root (when present — see\n * `ESLINT_CONFIG_NAMES`): the gate's `checks/capability-lint` runs the\n * capability preset from it, and refuses an archive without one\n * - everything under `src/`, recursively\n *\n * The tsconfig/vitest entries exist because the hosted gate's\n * `checks/typecheck` and `checks/tests` stages run the project's OWN `tsc`\n * and `vitest` — over the ARCHIVE, not the partner's working directory — so\n * without them there is no `tsconfig.json` to compile against (`tsc --noEmit`\n * falls back to printing its help text and exiting 1, not a type error) and\n * no test config to load the SDK's server-inline block. `ekanos init`\n * scaffolds both at the project root, so a project published straight from\n * `init` always has them; this walk just stops silently dropping them.\n *\n * Excluded everywhere: dotfiles and dot-directories (which covers `.ekanos`,\n * `.git`, `.env`), `node_modules`, and anything that is not a regular file\n * (symlinks are skipped, not followed — a link pointing outside the project\n * must never pull foreign bytes into a submission).\n *\n * Determinism: entries are sorted by path and every header carries a fixed\n * mtime, so packing the same tree twice yields byte-identical archives and a\n * stable sha256.\n */\n\nconst BLOCK_SIZE = 512;\n\n/** Fixed header mtime — determinism over provenance (the VCS owns history). */\nconst FIXED_MTIME_SECONDS = 0;\n\n/** The server refuses archives over 5 MiB; fail fast on the client too. */\n// 4 MiB — mirrors the server route's cap, which itself sits under Vercel's\n// ~4.5 MB request-body ceiling so oversize is caught here with a clear error\n// instead of by an opaque platform 413.\nexport const MAX_ARCHIVE_BYTES = 4 * 1024 * 1024;\n\nexport interface PackedProject {\n /** The gzipped tarball. */\n archive: Buffer;\n /** Project-relative POSIX paths, in the order they were packed. */\n files: string[];\n}\n\nexport function packProject(projectDir: string): PackedProject {\n const files = selectProjectFiles(projectDir);\n\n const blocks: Buffer[] = [];\n\n for (const relative of files) {\n const absolute = path.join(projectDir, relative);\n const content = fs.readFileSync(absolute);\n\n blocks.push(tarHeader(relative, content.length));\n blocks.push(content);\n\n const remainder = content.length % BLOCK_SIZE;\n if (remainder !== 0) {\n blocks.push(Buffer.alloc(BLOCK_SIZE - remainder));\n }\n }\n\n // End-of-archive: two zero blocks.\n blocks.push(Buffer.alloc(BLOCK_SIZE * 2));\n\n const archive = zlib.gzipSync(Buffer.concat(blocks), { level: 9 });\n\n if (archive.length > MAX_ARCHIVE_BYTES) {\n throw validationError(\n `The packed archive is ${archive.length} bytes, over the ` +\n `${MAX_ARCHIVE_BYTES}-byte submission limit.`,\n 'Reduce the project to source only — large binary assets do not ' +\n 'belong in an integration submission.',\n );\n }\n\n return { archive, files };\n}\n\n/**\n * The whitelist walk. Exported for tests: the selection rules are the part\n * with security consequences, so they are asserted directly.\n */\nexport function selectProjectFiles(projectDir: string): string[] {\n for (const required of ['ekanos.json', 'package.json']) {\n if (!isRegularFile(path.join(projectDir, required))) {\n throw preconditionError(\n `Cannot pack ${projectDir}: ${required} is missing.`,\n `Run \"ekanos publish\" from an integration project (or pass --dir), ` +\n `and run \"ekanos init\" first if this is a new project.`,\n );\n }\n }\n\n const selected = ['ekanos.json', 'package.json'];\n\n if (isRegularFile(path.join(projectDir, 'README.md'))) {\n selected.push('README.md');\n }\n\n if (isRegularFile(path.join(projectDir, 'contract.json'))) {\n selected.push('contract.json');\n }\n\n selected.push(...selectRootConfigFiles(projectDir));\n\n const srcDir = path.join(projectDir, 'src');\n // lstat, not stat: `src` itself as a symlink must not pull a foreign tree\n // into the archive — the same rule walk() applies to every entry inside.\n if (fs.existsSync(srcDir) && fs.lstatSync(srcDir).isDirectory()) {\n selected.push(...walk(projectDir, 'src'));\n }\n\n return selected.sort();\n}\n\n/** `tsconfig.json`, plus any sibling a root `tsconfig.json` might `extends`\n * (e.g. `tsconfig.build.json`) — matched by name, not content, since packing\n * runs before anything parses JSON with comments. Root-level only: this is\n * about the build/test config the gate's own stages need, not a recursive\n * search. */\nconst TSCONFIG_PATTERN = /^tsconfig(\\.[^./]+)?\\.json$/;\n\n/**\n * The project-root config files the hosted gate's `checks/typecheck`,\n * `checks/tests` and `checks/capability-lint` stages need to run the project's OWN `tsc`/`vitest`\n * meaningfully — see the module doc comment above. Each is included only\n * when present as a regular file (never a symlink, matching every other\n * entry point in this walk), so a project without one of these (unusual, but\n * not invalid) packs exactly as before.\n */\nfunction selectRootConfigFiles(projectDir: string): string[] {\n const selected: string[] = [];\n\n for (const entry of fs.readdirSync(projectDir, { withFileTypes: true })) {\n if (!TSCONFIG_PATTERN.test(entry.name)) continue;\n if (!isRegularFile(path.join(projectDir, entry.name))) continue;\n selected.push(entry.name);\n }\n\n for (const name of [...VITEST_CONFIG_NAMES, ...ESLINT_CONFIG_NAMES]) {\n if (isRegularFile(path.join(projectDir, name))) selected.push(name);\n }\n\n return selected;\n}\n\nfunction walk(projectDir: string, relativeDir: string): string[] {\n const absoluteDir = path.join(projectDir, relativeDir);\n const collected: string[] = [];\n\n for (const entry of fs.readdirSync(absoluteDir, { withFileTypes: true })) {\n if (entry.name.startsWith('.')) continue;\n if (entry.name === 'node_modules') continue;\n\n const relative = `${relativeDir}/${entry.name}`;\n\n if (entry.isDirectory()) {\n collected.push(...walk(projectDir, relative));\n continue;\n }\n\n // Regular files only. `isFile()` is false for symlinks under\n // `withFileTypes`, so a link — wherever it points — is skipped here.\n if (entry.isFile()) {\n collected.push(relative);\n }\n }\n\n return collected;\n}\n\nfunction isRegularFile(absolute: string): boolean {\n try {\n return fs.lstatSync(absolute).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * One 512-byte ustar header. Long paths use the ustar `prefix` field\n * (155 + '/' + 100); a path that fits neither is refused with a clear error\n * rather than silently truncated.\n */\nfunction tarHeader(relativePath: string, size: number): Buffer {\n const { name, prefix } = splitUstarPath(relativePath);\n const header = Buffer.alloc(BLOCK_SIZE);\n\n header.write(name, 0, 100, 'utf8');\n writeOctal(header, 100, 8, 0o644); // mode\n writeOctal(header, 108, 8, 0); // uid\n writeOctal(header, 116, 8, 0); // gid\n writeOctal(header, 124, 12, size);\n writeOctal(header, 136, 12, FIXED_MTIME_SECONDS);\n header.fill(' ', 148, 156); // checksum placeholder: eight spaces\n header.write('0', 156, 1, 'utf8'); // typeflag: regular file\n header.write('ustar', 257, 5, 'utf8');\n header.write('00', 263, 2, 'utf8'); // version\n header.write(prefix, 345, 155, 'utf8');\n\n let checksum = 0;\n for (const byte of header) checksum += byte;\n\n // Six octal digits, NUL, space — the historical checksum encoding.\n header.write(`${checksum.toString(8).padStart(6, '0')}\\0 `, 148, 8, 'latin1');\n\n return header;\n}\n\nfunction splitUstarPath(relativePath: string): {\n name: string;\n prefix: string;\n} {\n if (Buffer.byteLength(relativePath, 'utf8') <= 100) {\n return { name: relativePath, prefix: '' };\n }\n\n // Split at a '/' so that name ≤ 100 bytes and prefix ≤ 155 bytes.\n for (let i = relativePath.length - 1; i > 0; i--) {\n if (relativePath[i] !== '/') continue;\n\n const prefix = relativePath.slice(0, i);\n const name = relativePath.slice(i + 1);\n\n if (\n Buffer.byteLength(name, 'utf8') <= 100 &&\n Buffer.byteLength(prefix, 'utf8') <= 155\n ) {\n return { name, prefix };\n }\n }\n\n throw validationError(\n `Cannot pack \"${relativePath}\": the path is too long for a tar entry.`,\n 'Shorten the file path (tar limits one segment to 100 bytes and the ' +\n 'directory prefix to 155).',\n );\n}\n\nfunction writeOctal(\n header: Buffer,\n offset: number,\n length: number,\n value: number,\n): void {\n header.write(\n `${value.toString(8).padStart(length - 1, '0')}\\0`,\n offset,\n length,\n 'latin1',\n );\n}\n"]}
@@ -0,0 +1,13 @@
1
+ type Kinded = {
2
+ kind: 'feature' | 'experience' | 'integration';
3
+ };
4
+ /**
5
+ * Whether a list came from a host that predates the Features rename
6
+ * (2026-10-28), where a built-in capability was called an `experience`. Such a
7
+ * host never says `feature`, while every current host has built-in Features, so
8
+ * a list with none is from an older one.
9
+ */
10
+ export declare function hostPredatesFeatures(products: readonly Kinded[]): boolean;
11
+ /** The display group of a product: Features, Experiences or Integrations. */
12
+ export declare function productGroup(product: Kinded, legacyHost: boolean): 'feature' | 'experience' | 'integration';
13
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Whether a list came from a host that predates the Features rename
3
+ * (2026-10-28), where a built-in capability was called an `experience`. Such a
4
+ * host never says `feature`, while every current host has built-in Features, so
5
+ * a list with none is from an older one.
6
+ */
7
+ export function hostPredatesFeatures(products) {
8
+ return (products.some((product) => product.kind === 'experience') &&
9
+ !products.some((product) => product.kind === 'feature'));
10
+ }
11
+ /** The display group of a product: Features, Experiences or Integrations. */
12
+ export function productGroup(product, legacyHost) {
13
+ if (product.kind === 'experience' && legacyHost)
14
+ return 'feature';
15
+ return product.kind;
16
+ }
17
+ //# sourceMappingURL=product-kinds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-kinds.js","sourceRoot":"","sources":["../src/product-kinds.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAA2B;IAC9D,OAAO,CACL,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC;QACzD,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CACxD,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAC1B,OAAe,EACf,UAAmB;IAEnB,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,IAAI,UAAU;QAAE,OAAO,SAAS,CAAC;IAClE,OAAO,OAAO,CAAC,IAAI,CAAC;AACtB,CAAC","sourcesContent":["type Kinded = { kind: 'feature' | 'experience' | 'integration' };\n\n/**\n * Whether a list came from a host that predates the Features rename\n * (2026-10-28), where a built-in capability was called an `experience`. Such a\n * host never says `feature`, while every current host has built-in Features, so\n * a list with none is from an older one.\n */\nexport function hostPredatesFeatures(products: readonly Kinded[]): boolean {\n return (\n products.some((product) => product.kind === 'experience') &&\n !products.some((product) => product.kind === 'feature')\n );\n}\n\n/** The display group of a product: Features, Experiences or Integrations. */\nexport function productGroup(\n product: Kinded,\n legacyHost: boolean,\n): 'feature' | 'experience' | 'integration' {\n if (product.kind === 'experience' && legacyHost) return 'feature';\n return product.kind;\n}\n"]}
@@ -80,3 +80,10 @@ export declare function collectHostCompilerRulesFindings(projectDir: string): Fi
80
80
  * Silent when there is no `package.json` (nothing installable to inspect).
81
81
  */
82
82
  export declare function collectLintToolingFindings(projectDir: string): Finding[];
83
+ /**
84
+ * The hosted gate installs the archive's `package.json` on its own, so
85
+ * `@types/node` hoisted from a repo root or pulled in transitively is not
86
+ * there. A vitest config that imports `node:*` (the scaffold's does) then
87
+ * fails `checks/typecheck` with TS2307 unless the project declares it.
88
+ */
89
+ export declare function collectNodeTypesFindings(projectDir: string): Finding[];
@@ -328,4 +328,51 @@ export function collectLintToolingFindings(projectDir) {
328
328
  },
329
329
  ];
330
330
  }
331
+ const NODE_IMPORT_PATTERN = /\bfrom\s+['"]node:/;
332
+ /**
333
+ * The hosted gate installs the archive's `package.json` on its own, so
334
+ * `@types/node` hoisted from a repo root or pulled in transitively is not
335
+ * there. A vitest config that imports `node:*` (the scaffold's does) then
336
+ * fails `checks/typecheck` with TS2307 unless the project declares it.
337
+ */
338
+ export function collectNodeTypesFindings(projectDir) {
339
+ var _a, _b;
340
+ const manifestPath = path.join(projectDir, 'package.json');
341
+ if (!fs.existsSync(manifestPath))
342
+ return [];
343
+ let manifest;
344
+ try {
345
+ manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
346
+ }
347
+ catch (_c) {
348
+ return [];
349
+ }
350
+ if (((_a = manifest.dependencies) === null || _a === void 0 ? void 0 : _a['@types/node']) ||
351
+ ((_b = manifest.devDependencies) === null || _b === void 0 ? void 0 : _b['@types/node'])) {
352
+ return [];
353
+ }
354
+ const importer = [
355
+ ...VITEST_CONFIG_NAMES,
356
+ ...fs.readdirSync(projectDir).filter((name) => /\.[cm]?tsx?$/.test(name)),
357
+ ].find((name) => {
358
+ const file = path.join(projectDir, name);
359
+ return (fs.existsSync(file) &&
360
+ fs.statSync(file).isFile() &&
361
+ NODE_IMPORT_PATTERN.test(fs.readFileSync(file, 'utf8')));
362
+ });
363
+ if (!importer)
364
+ return [];
365
+ return [
366
+ {
367
+ check: 'project.node-types',
368
+ severity: 'error',
369
+ file: path.join(projectDir, importer),
370
+ message: `${importer} imports a "node:" module but package.json declares no ` +
371
+ `@types/node. The publish gate installs this package on its own, so ` +
372
+ `types hoisted from a repo root or pulled in transitively are not ` +
373
+ `there and typecheck fails with TS2307.`,
374
+ hint: 'Add @types/node to devDependencies (e.g. "@types/node": "^22.10.0").',
375
+ },
376
+ ];
377
+ }
331
378
  //# sourceMappingURL=project-checks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"project-checks.js","sourceRoot":"","sources":["../src/project-checks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAsB,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,iBAAiB;CAClB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,m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O;QACL;YACE,KAAK,EAAE,iCAAiC;YACxC,QAAQ,EAAE,MAAM;YAChB,OAAO,EACL,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,0CAA0C;gBAClE,qEAAqE;YACvE,IAAI,EACF,QAAQ,GAAG,wDAAwD;gBACnE,mEAAmE;gBACnE,6DAA6D;gBAC7D,sDAAsD;gBACtD,qDAAqD;gBACrD,oBAAoB;gBACpB,gEAAgE;gBAChE,qLAAqL;gBACrL,0BAA0B;gBAC1B,IAAI;SACP;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Finding } from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { installCommand, detectPackageManager } from './package-manager';\nimport { type EkanosProject, isDocUrl } from './project';\n\n/**\n * Every vitest/vite config basename `ekanos init` might have scaffolded (or a\n * partner might have renamed to). Exported so `pack.ts` can pack exactly the\n * same set it checks here — one list, so packing and validating this project\n * property can never disagree on what \"the test config\" even is.\n */\nexport const VITEST_CONFIG_NAMES = [\n 'vitest.config.ts',\n 'vitest.config.mts',\n 'vitest.config.cts',\n 'vitest.config.js',\n 'vitest.config.mjs',\n 'vitest.config.cjs',\n 'vite.config.ts',\n 'vite.config.mts',\n 'vite.config.js',\n 'vite.config.mjs',\n];\n\n/**\n * The ESLint flat-config basenames the hosted gate's `checks/capability-lint`\n * looks for in the ARCHIVE — the same four, so a project that lints locally\n * is never refused for a config `ekanos publish` left behind.\n */\nexport const ESLINT_CONFIG_NAMES = [\n 'eslint.config.mjs',\n 'eslint.config.js',\n 'eslint.config.cjs',\n 'eslint.config.ts',\n];\n\n/** The exact block the hint quotes — the one config that makes the SDK load. */\nconst REQUIRED_INLINE_BLOCK = [\n 'test: {',\n ' server: {',\n ' deps: {',\n \" inline: ['@ekanos/sdk'],\",\n ' },',\n ' },',\n '}',\n].join('\\n');\n\n/**\n * The host's own compiler-strictness overlay a project's tsconfig should\n * already satisfy — mirrors the exact flags (`HOST_TSC_FLAGS`) the gate's\n * own SECOND `tsc --noEmit` pass checks, read from the host's real tsconfig\n * (source of truth for the values themselves). Hardcoded here for the same\n * reason it is hardcoded there: this package ships to a partner's local\n * machine, so it cannot read a file inside the host's own repo at runtime.\n * Rules-as-data via `/api/partner/toolchain` supersedes this hardcoded copy\n * later — until then, keep both copies in sync by hand.\n */\nexport const HOST_COMPILER_RULES: Record<string, boolean> = {\n strict: true,\n noUncheckedIndexedAccess: true,\n};\n\n/** Matches `tsconfig.json`, `tsconfig.build.json`, etc. — mirrors the pattern\n * `pack.ts` and the gate's `typecheck.ts` use to find a project's tsconfig. */\nconst TSCONFIG_PATTERN = /^tsconfig(\\.[^./]+)?\\.json$/;\n\n/**\n * Project-level integrity checks that read files in the project root (next to\n * ekanos.json), NOT the integration definition. These are deliberately kept\n * out of the schema package's definition collectors: the definition is valid or\n * not on its own; whether the partner's TEST runner is configured to load the\n * published SDK is a property of THIS project.\n *\n * The highest-value check: a partner's vitest must inline `@ekanos/sdk`. The\n * published SDK dist imports extensionless `next/link`, so without\n * `test.server.deps.inline: ['@ekanos/sdk']` vitest fails to load the SDK, the\n * test file silently imports nothing, and vitest reports green over zero tests.\n *\n * The check is conditional: if the project declares NO vitest/vite config at\n * all, there is nothing to assert (the `test` verb would surface a missing\n * runner on its own). If a config IS present, it MUST inline the SDK.\n */\nexport function collectProjectFindings(projectDir: string): Finding[] {\n const configFile = VITEST_CONFIG_NAMES.map((name) =>\n path.join(projectDir, name),\n ).find((candidate) => fs.existsSync(candidate));\n\n if (!configFile) return [];\n\n const source = fs.readFileSync(configFile, 'utf8');\n if (vitestInlinesSdk(source)) return [];\n\n return [\n {\n check: 'project.vitest-inline-sdk',\n severity: 'error',\n file: configFile,\n message:\n `${path.basename(configFile)} does not inline @ekanos/sdk. The ` +\n `published SDK dist imports extensionless \"next/link\", so without ` +\n `test.server.deps.inline including \"@ekanos/sdk\", vitest cannot load ` +\n `the SDK — the test file imports nothing and vitest reports green ` +\n `over zero tests.`,\n hint:\n `Add this to your vitest config's defineConfig so the SDK is ` +\n `transformed for the test runner:\\n\\n${REQUIRED_INLINE_BLOCK}`,\n },\n ];\n}\n\n/**\n * Advisory check on the `docs` array: a relative entry that resolves to\n * nothing on disk gets a WARNING — never an error, because a missing doc file\n * must not block a publish (the gate refuses only error-severity findings).\n * URLs are never checked: `validate` does no network, ever, and an agent\n * dereferences them at authoring time instead.\n */\nexport function collectDocsFindings(\n project: EkanosProject,\n projectDir: string,\n): Finding[] {\n const findings: Finding[] = [];\n\n for (const entry of project.docs ?? []) {\n if (isDocUrl(entry)) continue;\n\n const resolved = path.resolve(projectDir, entry);\n if (fs.existsSync(resolved)) continue;\n\n findings.push({\n check: 'docs/missing-file',\n severity: 'warn',\n file: resolved,\n message:\n `ekanos.json lists \"${entry}\" under \"docs\", but no file exists ` +\n `there (resolved to ${resolved}).`,\n hint:\n `Create ${entry}, or fix the path in ekanos.json's \"docs\" array so ` +\n 'it points at real API documentation.',\n });\n }\n\n return findings;\n}\n\n/**\n * WARN when the project's tsconfig does not already set the host's\n * compiler-strictness overlay (`HOST_COMPILER_RULES`). This exists because a\n * project can pass its own `checks/typecheck` cleanly, publish, and only THEN\n * discover `checks/typecheck-host-rules` (the gate's second, stricter pass)\n * fails on the exact same source — e.g. `noUncheckedIndexedAccess` catching a\n * possibly-`undefined` array/record access `strict` alone allows. WARN, not\n * ERROR: this check reads a partner's local tsconfig, not the gate's own\n * verdict, so it must never block a publish that is actually fine — a\n * project whose tsconfig extends something odd, or omits `compilerOptions`\n * intentionally, still gets to publish and find out from the real gate.\n * `publish` escalates this specific check to ERROR locally (see its\n * severity-escalation list) so a submission that WOULD fail the gate never\n * gets uploaded in the first place.\n *\n * Absent tsconfig is not this check's concern — `checks/typecheck` (and its\n * host-rules sibling) already report that loudly on their own.\n */\nexport function collectHostCompilerRulesFindings(\n projectDir: string,\n): Finding[] {\n const tsconfigPath = findTsconfigPath(projectDir);\n if (!tsconfigPath) return [];\n\n const raw = fs.readFileSync(tsconfigPath, 'utf8');\n const tsconfigName = path.basename(tsconfigPath);\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(stripJsonComments(raw));\n } catch {\n // An unparseable tsconfig is a real defect, but not one THIS check can\n // reason about — `tsc` itself will refuse it far more usefully. info\n // severity: surfaced, but never blocks anything.\n return [\n {\n check: 'project.host-compiler-rules',\n severity: 'info',\n file: tsconfigPath,\n message:\n `${tsconfigName} could not be parsed as JSON (even tolerating ` +\n `comments and trailing commas), so this check could not verify it ` +\n `sets the host's compiler rules ` +\n `(${Object.keys(HOST_COMPILER_RULES).join(', ')}).`,\n hint: `Fix ${tsconfigName}'s syntax, then re-run validate.`,\n },\n ];\n }\n\n const compilerOptions =\n typeof parsed === 'object' &&\n parsed !== null &&\n typeof (parsed as { compilerOptions?: unknown }).compilerOptions ===\n 'object' &&\n (parsed as { compilerOptions?: unknown }).compilerOptions !== null\n ? ((parsed as { compilerOptions: Record<string, unknown> })\n .compilerOptions ?? {})\n : {};\n\n const missing = Object.entries(HOST_COMPILER_RULES)\n .filter(([name, required]) => compilerOptions[name] !== required)\n .map(([name]) => name);\n\n if (missing.length === 0) return [];\n\n return [\n {\n check: 'project.host-compiler-rules',\n severity: 'warn',\n file: tsconfigPath,\n message:\n `${tsconfigName} does not set ${missing.join(' and ')} in ` +\n `compilerOptions. The gate re-checks your submission under the ` +\n `host's own stricter compiler rules — a project that typechecks ` +\n `cleanly under its own laxer tsconfig can still fail that pass.`,\n hint:\n `Add ${missing.map((name) => `\"${name}\": true`).join(', ')} to ` +\n `compilerOptions in ${tsconfigName}.`,\n },\n ];\n}\n\n/** `tsconfig.json` if present (matching what a bare `tsc --noEmit` would\n * auto-discover), else the first `tsconfig.*.json` found. */\nfunction findTsconfigPath(projectDir: string): string | undefined {\n let names: string[];\n try {\n names = fs\n .readdirSync(projectDir, { withFileTypes: true })\n .filter((entry) => entry.isFile() && TSCONFIG_PATTERN.test(entry.name))\n .map((entry) => entry.name);\n } catch {\n return undefined;\n }\n if (names.length === 0) return undefined;\n const name = names.includes('tsconfig.json')\n ? 'tsconfig.json'\n : [...names].sort()[0];\n return name ? path.join(projectDir, name) : undefined;\n}\n\n/**\n * A minimal, string-literal-aware strip of `//` and `/* *\\/` comments —\n * tsconfig.json is conventionally JSONC, but nothing in this package's\n * dependency graph parses it as such. Not a full JSONC parser: it does not\n * touch trailing commas beyond the one cleanup pass below, and it makes no\n * attempt to validate the result — `JSON.parse` does that, and a project\n * with genuinely malformed JSON falls through to this check's `info`-severity\n * catch, never a crash.\n */\nfunction stripJsonComments(source: string): string {\n let out = '';\n let inString = false;\n let quote = '';\n\n for (let i = 0; i < source.length; i++) {\n const char = source[i] ?? '';\n\n if (inString) {\n out += char;\n if (char === '\\\\') {\n out += source[++i] ?? '';\n continue;\n }\n if (char === quote) inString = false;\n continue;\n }\n\n if (char === '\"' || char === \"'\") {\n inString = true;\n quote = char;\n out += char;\n continue;\n }\n\n if (char === '/' && source[i + 1] === '/') {\n while (i < source.length && source[i] !== '\\n') i++;\n out += '\\n';\n continue;\n }\n\n if (char === '/' && source[i + 1] === '*') {\n i += 2;\n while (\n i < source.length &&\n !(source[i] === '*' && source[i + 1] === '/')\n ) {\n i++;\n }\n i++; // consume the closing '/'\n continue;\n }\n\n out += char;\n }\n\n // Trailing commas before a closing brace/bracket.\n return out.replace(/,(\\s*[}\\]])/g, '$1');\n}\n\n/**\n * True when the config source contains an `inline: [ … ]` array that lists\n * `@ekanos/sdk`. Textual on purpose — evaluating a partner's config module\n * would run arbitrary code; a lint-style scan does not.\n */\nfunction vitestInlinesSdk(source: string): boolean {\n const inlineArrayPattern = /inline\\s*:\\s*\\[([\\s\\S]*?)\\]/g;\n for (\n let match = inlineArrayPattern.exec(source);\n match !== null;\n match = inlineArrayPattern.exec(source)\n ) {\n if (/['\"]@ekanos\\/sdk['\"]/.test(match[1] ?? '')) return true;\n }\n return false;\n}\n\n/**\n * The hosted gate's `checks/capability-lint` runs THE PROJECT'S OWN ESLint\n * (its pinned `node_modules/.bin/eslint`, its `eslint.config.*` spreading\n * `@ekanos/sdk/eslint`) and refuses a submission without them: a control the\n * submission can leave out is not a control, so the gate does not fall back to\n * an ESLint of its own. `ekanos init` scaffolds both; a repo created before\n * that, or by hand, has neither and is refused at publish time. Say so here,\n * locally, with the exact fix, as a warning (the refusal is the gate's).\n *\n * Silent when there is no `package.json` (nothing installable to inspect).\n */\nexport function collectLintToolingFindings(projectDir: string): Finding[] {\n if (!fs.existsSync(path.join(projectDir, 'package.json'))) return [];\n\n const hasEslint = fs.existsSync(\n path.join(projectDir, 'node_modules', 'eslint', 'package.json'),\n );\n const hasConfig = ESLINT_CONFIG_NAMES.some((name) =>\n fs.existsSync(path.join(projectDir, name)),\n );\n if (hasEslint && hasConfig) return [];\n\n const missing = [\n ...(hasEslint ? [] : ['eslint is not installed']),\n ...(hasConfig ? [] : ['there is no eslint.config.mjs']),\n ];\n const add = installCommand(detectPackageManager(projectDir), [\n 'eslint',\n '@typescript-eslint/parser',\n ]);\n\n return [\n {\n check: 'project.capability-lint-tooling',\n severity: 'warn',\n message:\n `${missing.join(' and ')}, so the publish gate's capability lint ` +\n '(@ekanos/sdk/eslint) cannot run on this project and will refuse it.',\n hint:\n `Run \"${add}\" (as devDependencies), then add an eslint.config.mjs ` +\n 'that spreads the presets — \"ekanos init\" prints the scaffold, or ' +\n 'copy templates/eslint.config.mjs.tmpl from @ekanos/cli:\\n\\n' +\n \"import capabilityPreset from '@ekanos/sdk/eslint';\\n\" +\n \"import tsParser from '@typescript-eslint/parser';\\n\" +\n 'export default [\\n' +\n \" { ignores: ['dist/**', 'node_modules/**', '.ekanos/**'] },\\n\" +\n \" { files: ['src/**/*.ts', 'src/**/*.tsx'], languageOptions: { parser: tsParser, ecmaVersion: 'latest', sourceType: 'module', parserOptions: { ecmaFeatures: { jsx: true } } } },\\n\" +\n ' ...capabilityPreset,\\n' +\n '];',\n },\n ];\n}\n"]}
1
+ {"version":3,"file":"project-checks.js","sourceRoot":"","sources":["../src/project-checks.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AO,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IACE,CAAA,MAAA,QAAQ,CAAC,YAAY,0CAAG,aAAa,CAAC;SACtC,MAAA,QAAQ,CAAC,eAAe,0CAAG,aAAa,CAAC,CAAA,EACzC,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG;QACf,GAAG,mBAAmB;QACtB,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC1E,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACzC,OAAO,CACL,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;YACnB,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;YAC1B,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CACxD,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,CAAC;IAEzB,OAAO;QACL;YACE,KAAK,EAAE,oBAAoB;YAC3B,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC;YACrC,OAAO,EACL,GAAG,QAAQ,yDAAyD;gBACpE,qEAAqE;gBACrE,mEAAmE;gBACnE,wCAAwC;YAC1C,IAAI,EAAE,sEAAsE;SAC7E;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { Finding } from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport { installCommand, detectPackageManager } from './package-manager';\nimport { type EkanosProject, isDocUrl } from './project';\n\n/**\n * Every vitest/vite config basename `ekanos init` might have scaffolded (or a\n * partner might have renamed to). Exported so `pack.ts` can pack exactly the\n * same set it checks here — one list, so packing and validating this project\n * property can never disagree on what \"the test config\" even is.\n */\nexport const VITEST_CONFIG_NAMES = [\n 'vitest.config.ts',\n 'vitest.config.mts',\n 'vitest.config.cts',\n 'vitest.config.js',\n 'vitest.config.mjs',\n 'vitest.config.cjs',\n 'vite.config.ts',\n 'vite.config.mts',\n 'vite.config.js',\n 'vite.config.mjs',\n];\n\n/**\n * The ESLint flat-config basenames the hosted gate's `checks/capability-lint`\n * looks for in the ARCHIVE — the same four, so a project that lints locally\n * is never refused for a config `ekanos publish` left behind.\n */\nexport const ESLINT_CONFIG_NAMES = [\n 'eslint.config.mjs',\n 'eslint.config.js',\n 'eslint.config.cjs',\n 'eslint.config.ts',\n];\n\n/** The exact block the hint quotes — the one config that makes the SDK load. */\nconst REQUIRED_INLINE_BLOCK = [\n 'test: {',\n ' server: {',\n ' deps: {',\n \" inline: ['@ekanos/sdk'],\",\n ' },',\n ' },',\n '}',\n].join('\\n');\n\n/**\n * The host's own compiler-strictness overlay a project's tsconfig should\n * already satisfy — mirrors the exact flags (`HOST_TSC_FLAGS`) the gate's\n * own SECOND `tsc --noEmit` pass checks, read from the host's real tsconfig\n * (source of truth for the values themselves). Hardcoded here for the same\n * reason it is hardcoded there: this package ships to a partner's local\n * machine, so it cannot read a file inside the host's own repo at runtime.\n * Rules-as-data via `/api/partner/toolchain` supersedes this hardcoded copy\n * later — until then, keep both copies in sync by hand.\n */\nexport const HOST_COMPILER_RULES: Record<string, boolean> = {\n strict: true,\n noUncheckedIndexedAccess: true,\n};\n\n/** Matches `tsconfig.json`, `tsconfig.build.json`, etc. — mirrors the pattern\n * `pack.ts` and the gate's `typecheck.ts` use to find a project's tsconfig. */\nconst TSCONFIG_PATTERN = /^tsconfig(\\.[^./]+)?\\.json$/;\n\n/**\n * Project-level integrity checks that read files in the project root (next to\n * ekanos.json), NOT the integration definition. These are deliberately kept\n * out of the schema package's definition collectors: the definition is valid or\n * not on its own; whether the partner's TEST runner is configured to load the\n * published SDK is a property of THIS project.\n *\n * The highest-value check: a partner's vitest must inline `@ekanos/sdk`. The\n * published SDK dist imports extensionless `next/link`, so without\n * `test.server.deps.inline: ['@ekanos/sdk']` vitest fails to load the SDK, the\n * test file silently imports nothing, and vitest reports green over zero tests.\n *\n * The check is conditional: if the project declares NO vitest/vite config at\n * all, there is nothing to assert (the `test` verb would surface a missing\n * runner on its own). If a config IS present, it MUST inline the SDK.\n */\nexport function collectProjectFindings(projectDir: string): Finding[] {\n const configFile = VITEST_CONFIG_NAMES.map((name) =>\n path.join(projectDir, name),\n ).find((candidate) => fs.existsSync(candidate));\n\n if (!configFile) return [];\n\n const source = fs.readFileSync(configFile, 'utf8');\n if (vitestInlinesSdk(source)) return [];\n\n return [\n {\n check: 'project.vitest-inline-sdk',\n severity: 'error',\n file: configFile,\n message:\n `${path.basename(configFile)} does not inline @ekanos/sdk. The ` +\n `published SDK dist imports extensionless \"next/link\", so without ` +\n `test.server.deps.inline including \"@ekanos/sdk\", vitest cannot load ` +\n `the SDK — the test file imports nothing and vitest reports green ` +\n `over zero tests.`,\n hint:\n `Add this to your vitest config's defineConfig so the SDK is ` +\n `transformed for the test runner:\\n\\n${REQUIRED_INLINE_BLOCK}`,\n },\n ];\n}\n\n/**\n * Advisory check on the `docs` array: a relative entry that resolves to\n * nothing on disk gets a WARNING — never an error, because a missing doc file\n * must not block a publish (the gate refuses only error-severity findings).\n * URLs are never checked: `validate` does no network, ever, and an agent\n * dereferences them at authoring time instead.\n */\nexport function collectDocsFindings(\n project: EkanosProject,\n projectDir: string,\n): Finding[] {\n const findings: Finding[] = [];\n\n for (const entry of project.docs ?? []) {\n if (isDocUrl(entry)) continue;\n\n const resolved = path.resolve(projectDir, entry);\n if (fs.existsSync(resolved)) continue;\n\n findings.push({\n check: 'docs/missing-file',\n severity: 'warn',\n file: resolved,\n message:\n `ekanos.json lists \"${entry}\" under \"docs\", but no file exists ` +\n `there (resolved to ${resolved}).`,\n hint:\n `Create ${entry}, or fix the path in ekanos.json's \"docs\" array so ` +\n 'it points at real API documentation.',\n });\n }\n\n return findings;\n}\n\n/**\n * WARN when the project's tsconfig does not already set the host's\n * compiler-strictness overlay (`HOST_COMPILER_RULES`). This exists because a\n * project can pass its own `checks/typecheck` cleanly, publish, and only THEN\n * discover `checks/typecheck-host-rules` (the gate's second, stricter pass)\n * fails on the exact same source — e.g. `noUncheckedIndexedAccess` catching a\n * possibly-`undefined` array/record access `strict` alone allows. WARN, not\n * ERROR: this check reads a partner's local tsconfig, not the gate's own\n * verdict, so it must never block a publish that is actually fine — a\n * project whose tsconfig extends something odd, or omits `compilerOptions`\n * intentionally, still gets to publish and find out from the real gate.\n * `publish` escalates this specific check to ERROR locally (see its\n * severity-escalation list) so a submission that WOULD fail the gate never\n * gets uploaded in the first place.\n *\n * Absent tsconfig is not this check's concern — `checks/typecheck` (and its\n * host-rules sibling) already report that loudly on their own.\n */\nexport function collectHostCompilerRulesFindings(\n projectDir: string,\n): Finding[] {\n const tsconfigPath = findTsconfigPath(projectDir);\n if (!tsconfigPath) return [];\n\n const raw = fs.readFileSync(tsconfigPath, 'utf8');\n const tsconfigName = path.basename(tsconfigPath);\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(stripJsonComments(raw));\n } catch {\n // An unparseable tsconfig is a real defect, but not one THIS check can\n // reason about — `tsc` itself will refuse it far more usefully. info\n // severity: surfaced, but never blocks anything.\n return [\n {\n check: 'project.host-compiler-rules',\n severity: 'info',\n file: tsconfigPath,\n message:\n `${tsconfigName} could not be parsed as JSON (even tolerating ` +\n `comments and trailing commas), so this check could not verify it ` +\n `sets the host's compiler rules ` +\n `(${Object.keys(HOST_COMPILER_RULES).join(', ')}).`,\n hint: `Fix ${tsconfigName}'s syntax, then re-run validate.`,\n },\n ];\n }\n\n const compilerOptions =\n typeof parsed === 'object' &&\n parsed !== null &&\n typeof (parsed as { compilerOptions?: unknown }).compilerOptions ===\n 'object' &&\n (parsed as { compilerOptions?: unknown }).compilerOptions !== null\n ? ((parsed as { compilerOptions: Record<string, unknown> })\n .compilerOptions ?? {})\n : {};\n\n const missing = Object.entries(HOST_COMPILER_RULES)\n .filter(([name, required]) => compilerOptions[name] !== required)\n .map(([name]) => name);\n\n if (missing.length === 0) return [];\n\n return [\n {\n check: 'project.host-compiler-rules',\n severity: 'warn',\n file: tsconfigPath,\n message:\n `${tsconfigName} does not set ${missing.join(' and ')} in ` +\n `compilerOptions. The gate re-checks your submission under the ` +\n `host's own stricter compiler rules — a project that typechecks ` +\n `cleanly under its own laxer tsconfig can still fail that pass.`,\n hint:\n `Add ${missing.map((name) => `\"${name}\": true`).join(', ')} to ` +\n `compilerOptions in ${tsconfigName}.`,\n },\n ];\n}\n\n/** `tsconfig.json` if present (matching what a bare `tsc --noEmit` would\n * auto-discover), else the first `tsconfig.*.json` found. */\nfunction findTsconfigPath(projectDir: string): string | undefined {\n let names: string[];\n try {\n names = fs\n .readdirSync(projectDir, { withFileTypes: true })\n .filter((entry) => entry.isFile() && TSCONFIG_PATTERN.test(entry.name))\n .map((entry) => entry.name);\n } catch {\n return undefined;\n }\n if (names.length === 0) return undefined;\n const name = names.includes('tsconfig.json')\n ? 'tsconfig.json'\n : [...names].sort()[0];\n return name ? path.join(projectDir, name) : undefined;\n}\n\n/**\n * A minimal, string-literal-aware strip of `//` and `/* *\\/` comments —\n * tsconfig.json is conventionally JSONC, but nothing in this package's\n * dependency graph parses it as such. Not a full JSONC parser: it does not\n * touch trailing commas beyond the one cleanup pass below, and it makes no\n * attempt to validate the result — `JSON.parse` does that, and a project\n * with genuinely malformed JSON falls through to this check's `info`-severity\n * catch, never a crash.\n */\nfunction stripJsonComments(source: string): string {\n let out = '';\n let inString = false;\n let quote = '';\n\n for (let i = 0; i < source.length; i++) {\n const char = source[i] ?? '';\n\n if (inString) {\n out += char;\n if (char === '\\\\') {\n out += source[++i] ?? '';\n continue;\n }\n if (char === quote) inString = false;\n continue;\n }\n\n if (char === '\"' || char === \"'\") {\n inString = true;\n quote = char;\n out += char;\n continue;\n }\n\n if (char === '/' && source[i + 1] === '/') {\n while (i < source.length && source[i] !== '\\n') i++;\n out += '\\n';\n continue;\n }\n\n if (char === '/' && source[i + 1] === '*') {\n i += 2;\n while (\n i < source.length &&\n !(source[i] === '*' && source[i + 1] === '/')\n ) {\n i++;\n }\n i++; // consume the closing '/'\n continue;\n }\n\n out += char;\n }\n\n // Trailing commas before a closing brace/bracket.\n return out.replace(/,(\\s*[}\\]])/g, '$1');\n}\n\n/**\n * True when the config source contains an `inline: [ … ]` array that lists\n * `@ekanos/sdk`. Textual on purpose — evaluating a partner's config module\n * would run arbitrary code; a lint-style scan does not.\n */\nfunction vitestInlinesSdk(source: string): boolean {\n const inlineArrayPattern = /inline\\s*:\\s*\\[([\\s\\S]*?)\\]/g;\n for (\n let match = inlineArrayPattern.exec(source);\n match !== null;\n match = inlineArrayPattern.exec(source)\n ) {\n if (/['\"]@ekanos\\/sdk['\"]/.test(match[1] ?? '')) return true;\n }\n return false;\n}\n\n/**\n * The hosted gate's `checks/capability-lint` runs THE PROJECT'S OWN ESLint\n * (its pinned `node_modules/.bin/eslint`, its `eslint.config.*` spreading\n * `@ekanos/sdk/eslint`) and refuses a submission without them: a control the\n * submission can leave out is not a control, so the gate does not fall back to\n * an ESLint of its own. `ekanos init` scaffolds both; a repo created before\n * that, or by hand, has neither and is refused at publish time. Say so here,\n * locally, with the exact fix, as a warning (the refusal is the gate's).\n *\n * Silent when there is no `package.json` (nothing installable to inspect).\n */\nexport function collectLintToolingFindings(projectDir: string): Finding[] {\n if (!fs.existsSync(path.join(projectDir, 'package.json'))) return [];\n\n const hasEslint = fs.existsSync(\n path.join(projectDir, 'node_modules', 'eslint', 'package.json'),\n );\n const hasConfig = ESLINT_CONFIG_NAMES.some((name) =>\n fs.existsSync(path.join(projectDir, name)),\n );\n if (hasEslint && hasConfig) return [];\n\n const missing = [\n ...(hasEslint ? [] : ['eslint is not installed']),\n ...(hasConfig ? [] : ['there is no eslint.config.mjs']),\n ];\n const add = installCommand(detectPackageManager(projectDir), [\n 'eslint',\n '@typescript-eslint/parser',\n ]);\n\n return [\n {\n check: 'project.capability-lint-tooling',\n severity: 'warn',\n message:\n `${missing.join(' and ')}, so the publish gate's capability lint ` +\n '(@ekanos/sdk/eslint) cannot run on this project and will refuse it.',\n hint:\n `Run \"${add}\" (as devDependencies), then add an eslint.config.mjs ` +\n 'that spreads the presets — \"ekanos init\" prints the scaffold, or ' +\n 'copy templates/eslint.config.mjs.tmpl from @ekanos/cli:\\n\\n' +\n \"import capabilityPreset from '@ekanos/sdk/eslint';\\n\" +\n \"import tsParser from '@typescript-eslint/parser';\\n\" +\n 'export default [\\n' +\n \" { ignores: ['dist/**', 'node_modules/**', '.ekanos/**'] },\\n\" +\n \" { files: ['src/**/*.ts', 'src/**/*.tsx'], languageOptions: { parser: tsParser, ecmaVersion: 'latest', sourceType: 'module', parserOptions: { ecmaFeatures: { jsx: true } } } },\\n\" +\n ' ...capabilityPreset,\\n' +\n '];',\n },\n ];\n}\n\nconst NODE_IMPORT_PATTERN = /\\bfrom\\s+['\"]node:/;\n\n/**\n * The hosted gate installs the archive's `package.json` on its own, so\n * `@types/node` hoisted from a repo root or pulled in transitively is not\n * there. A vitest config that imports `node:*` (the scaffold's does) then\n * fails `checks/typecheck` with TS2307 unless the project declares it.\n */\nexport function collectNodeTypesFindings(projectDir: string): Finding[] {\n const manifestPath = path.join(projectDir, 'package.json');\n if (!fs.existsSync(manifestPath)) return [];\n\n let manifest: {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n };\n try {\n manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));\n } catch {\n return [];\n }\n if (\n manifest.dependencies?.['@types/node'] ||\n manifest.devDependencies?.['@types/node']\n ) {\n return [];\n }\n\n const importer = [\n ...VITEST_CONFIG_NAMES,\n ...fs.readdirSync(projectDir).filter((name) => /\\.[cm]?tsx?$/.test(name)),\n ].find((name) => {\n const file = path.join(projectDir, name);\n return (\n fs.existsSync(file) &&\n fs.statSync(file).isFile() &&\n NODE_IMPORT_PATTERN.test(fs.readFileSync(file, 'utf8'))\n );\n });\n if (!importer) return [];\n\n return [\n {\n check: 'project.node-types',\n severity: 'error',\n file: path.join(projectDir, importer),\n message:\n `${importer} imports a \"node:\" module but package.json declares no ` +\n `@types/node. The publish gate installs this package on its own, so ` +\n `types hoisted from a repo root or pulled in transitively are not ` +\n `there and typecheck fails with TS2307.`,\n hint: 'Add @types/node to devDependencies (e.g. \"@types/node\": \"^22.10.0\").',\n },\n ];\n}\n"]}