@synopackageland/cli 0.53.7 → 0.53.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.53.9 (2026-11-11)
4
+
5
+ - The v2 operation registry accepts the SDK 0.53.34 fields `ctl` and `gateway`. `ctl: hidden` keeps an operation off ctl (it can only narrow, like `mcp`). `gateway: "<method>"` routes an operation's ctl command through a dedicated hidden `invoke` operation, for Apps that run ctl through an audited engine. The gateway needs the same permission and audit class, at least the same effect, a JSON RPC route, and serves one operation. `ctl generate`, `check` and description validation refuse invalid values with the same messages as the SDK.
6
+ - A gatewayed ctl command keeps its name, CLI path and semantics but calls the gateway with the gateway's params and checks the gateway's result. `ctl tool` runs it the same way; `ctl tool` on a `ctl: hidden` tool returns `CTL_AI_NOT_EXPOSED`. `ctl tools --mcp` shows the gateway's params, result and flow; `generated/tools.json` keeps the business schema and adds `gateway` and `ctl` only when declared. `generated/operations.md` writes `ctl: … via …` and `No ctl exposure.`.
7
+ - `CTL_FLOW_UNSUPPORTED` checks only operations that are ctl commands, so `ctl: hidden` stream and HTTP routes are accepted.
8
+ - `audit: sensitive-read` is accepted on write and destructive operations; `read` and `none` stay refused for changes.
9
+ - A registry may declare shared top-level `$defs` that operation schemas reference. Generation moves identical per-operation definitions into the shared set in the descriptor and runtime registry, while ctl commands and tools stay self-contained. Without top-level `$defs` nothing is rewritten.
10
+ - Registries without the new fields generate byte-identical artifacts. Apps that declare them need CLI 0.53.9 or later to read their descriptions with ctl.
11
+
12
+ ## 0.53.8 (2026-11-11)
13
+
14
+ - The ready-to-paste `ui_secret_ignores` entry printed by `build` and project `check` now lists every flagged text. Texts longer than 200 characters were left out, which in minified output (non-ASCII escaped as `\uXXXX`) dropped long translated strings; now every text up to the 4096-character `match` limit is listed untruncated, exactly as `match` needs it. Error lines stay truncated, and known token signatures are still never printed.
15
+ - `check` prints one entry per file instead of one per finding, so a file with several kinds of hits no longer gets duplicate entries. When the file already has an entry, the paste is a complete replacement that keeps its reviewed texts, drops stale ones and adds the new hits.
16
+ - Pasted values are written as ASCII-only YAML strings, so they parse back to exactly the flagged text.
17
+
3
18
  ## 0.53.7 (2026-11-11)
4
19
 
5
20
  - The v2 operation registry accepts the SDK 0.53.33 AI semantics: `ai` classes `propose`, `local` and `one-click`, and optional `consent`, `targets`, `risk`, `tier`, `undo`, `audit`, `mcp`, `dynamicProvider` and `labels`. `ctl generate`, `check` and description validation refuse invalid values with the field named.
package/dist/bin.js CHANGED
File without changes
@@ -28,6 +28,8 @@ export declare function listAiTools(client: CtlClient, appName: string, options?
28
28
  mcp?: "exposed" | "hidden" | "human-only" | undefined;
29
29
  labels?: Record<string, string> | undefined;
30
30
  dynamicProvider?: boolean | undefined;
31
+ ctl?: "exposed" | "hidden" | undefined;
32
+ gateway?: string | undefined;
31
33
  execution: string;
32
34
  preview?: string | undefined;
33
35
  name: string;
@@ -5,7 +5,7 @@ export async function listAiTools(client, appName, options = {}) {
5
5
  const app = client.selectApp(await client.discover(options), appName);
6
6
  if (app.version === 1 || app.version === 2 && !app.payload.operations)
7
7
  throw new CtlError('CTL_AI_REGISTRY_REQUIRED', 'AI tools require an operation registry.', 'Migrate the App operation registry.', 5);
8
- return { package: app.payload.package, sha256: app.sha256, tools: registryTools({ operations: app.version === 3 ? app.payload.commands : app.payload.operations }, { mcp: options.mcp }), ...(app.payload.execution ? { auth: await client.nativeState(app), credentialGuidance: 'Ask the user to run ctl auth in their own terminal. Never request credentials in chat.' } : {}) };
8
+ return { package: app.payload.package, sha256: app.sha256, tools: registryTools({ operations: app.version === 3 ? app.payload.commands : app.payload.operations, ...(app.version === 2 && app.payload.$defs ? { $defs: app.payload.$defs } : {}) }, { mcp: options.mcp }), ...(app.payload.execution ? { auth: await client.nativeState(app), credentialGuidance: 'Ask the user to run ctl auth in their own terminal. Never request credentials in chat.' } : {}) };
9
9
  }
10
10
  /** A draft is always a preview and plan. This API has no write-confirmation input.
11
11
  * Humans can execute the reviewed ctl plan separately with the normal --yes guard.
@@ -16,6 +16,8 @@ export async function listAiTools(client, appName, options = {}) {
16
16
  export async function runAiTool(client, appName, method, params, options = {}) {
17
17
  const app = client.selectApp(await client.discover(options), appName);
18
18
  const op = app.version !== 1 ? app.payload.commands[method] : undefined;
19
+ if (!op && app.version === 2 && isToolClass(app.payload.operations?.[method]?.ai))
20
+ throw new CtlError('CTL_AI_NOT_EXPOSED', 'AI tool is not exposed to ctl.', 'Use the App\'s own chat for this tool.', 4);
19
21
  if (!op || !isToolClass(op.ai))
20
22
  throw new CtlError('CTL_AI_NOT_EXPOSED', 'Operation is not an AI tool.', 'Use the generated tool list.', 4);
21
23
  const args = ['--input', '-'], stdin = JSON.stringify(params);
@@ -87,6 +87,7 @@ export interface ApiPayload {
87
87
  external?: Record<string, {
88
88
  method: string;
89
89
  }>;
90
+ $defs?: import('./shared-defs.js').SharedDefs;
90
91
  }
91
92
  export interface Descriptor {
92
93
  format: 'synopkgland.api';
@@ -1,4 +1,4 @@
1
- import { validateRegistry, INFRASTRUCTURE_METHODS } from './registry.js';
1
+ import { validateRegistry, ctlCommands, INFRASTRUCTURE_METHODS } from './registry.js';
2
2
  import { readFileSync } from 'node:fs';
3
3
  import { createHash } from 'node:crypto';
4
4
  import { canonicalize } from 'json-canonicalize';
@@ -36,12 +36,12 @@ export function validateDescriptor(value, id, version) {
36
36
  if (value.version === 2) {
37
37
  try {
38
38
  if (value.version === 2)
39
- validateRegistry({ format: 'synopkgland.api', version: 2, operations: p.operations });
39
+ validateRegistry({ format: 'synopkgland.api', version: 2, ...(p.$defs !== undefined ? { $defs: p.$defs } : {}), operations: p.operations });
40
40
  }
41
41
  catch {
42
42
  return fail('Invalid operation registry.');
43
43
  }
44
- const expected = Object.fromEntries(Object.entries(p.operations).filter(([, op]) => op.ai !== 'hidden'));
44
+ const expected = ctlCommands({ operations: p.operations, $defs: p.$defs });
45
45
  if (canonicalize(expected) !== canonicalize(p.commands))
46
46
  return fail('Commands differ from the operation registry.');
47
47
  for (const [name, op] of Object.entries(p.operations)) {
@@ -24,14 +24,20 @@ export interface OperationSemantics {
24
24
  mcp?: 'exposed' | 'hidden' | 'human-only';
25
25
  labels?: Record<string, string>;
26
26
  dynamicProvider?: boolean;
27
+ ctl?: 'exposed' | 'hidden';
28
+ gateway?: string;
27
29
  }
28
- export declare const SEMANTIC_FIELDS: readonly ["consent", "targets", "risk", "tier", "undo", "audit", "mcp", "labels", "dynamicProvider"];
30
+ export declare const SEMANTIC_FIELDS: readonly ["consent", "targets", "risk", "tier", "undo", "audit", "mcp", "labels", "dynamicProvider", "ctl", "gateway"];
29
31
  export declare const isToolClass: (ai: unknown) => boolean;
30
32
  /** Effective defaults follow from ai and effect alone. */
31
33
  export declare function auditClass(op: {
32
34
  audit?: string;
33
35
  effect: string;
34
36
  }): string;
37
+ export declare function ctlExposure(op: {
38
+ ctl?: string;
39
+ ai?: string;
40
+ }): string;
35
41
  export declare function mcpExposure(op: {
36
42
  mcp?: string;
37
43
  ai?: string;
@@ -1,7 +1,7 @@
1
1
  /** Optional v2 AI semantics. Every field is metadata for the App/SDK runtime;
2
2
  * none grants authority. Omitted fields keep earlier v2 output unchanged. */
3
3
  export const TOOL_CLASSES = ['read', 'preview', 'draft', 'propose', 'local', 'one-click'];
4
- export const SEMANTIC_FIELDS = ['consent', 'targets', 'risk', 'tier', 'undo', 'audit', 'mcp', 'labels', 'dynamicProvider'];
4
+ export const SEMANTIC_FIELDS = ['consent', 'targets', 'risk', 'tier', 'undo', 'audit', 'mcp', 'labels', 'dynamicProvider', 'ctl', 'gateway'];
5
5
  const TOKEN = /^[a-z][a-z0-9-]{0,31}$/, TIER = /^[A-Za-z0-9][A-Za-z0-9_-]{0,15}$/, PARAM = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
6
6
  export const isToolClass = (ai) => TOOL_CLASSES.includes(ai);
7
7
  const record = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
@@ -11,6 +11,8 @@ const head = (p) => p.slice(1).split('/')[0].replaceAll('~1', '/').replaceAll('~
11
11
  const hasParam = (schema, name) => !record(schema?.properties) || Object.hasOwn(schema.properties, name);
12
12
  /** Effective defaults follow from ai and effect alone. */
13
13
  export function auditClass(op) { return op.audit ?? (op.effect === 'read' ? 'read' : 'change'); }
14
+ export function ctlExposure(op) { return op.ctl ?? (op.ai === 'hidden' ? 'hidden' : 'exposed'); }
15
+ const EFFECT_RANK = { read: 0, write: 1, destructive: 2 };
14
16
  export function mcpExposure(op) { return op.mcp ?? (isToolClass(op.ai) ? 'exposed' : op.ai === 'human-only' ? 'human-only' : 'hidden'); }
15
17
  /** Returns the first problem as `field: reason`, or undefined. Mirrors the SDK's Go validation. */
16
18
  export function semanticsProblem(name, op, ops) {
@@ -53,8 +55,8 @@ export function semanticsProblem(name, op, ops) {
53
55
  if (op.audit !== undefined) {
54
56
  if (!['change', 'sensitive-read', 'read', 'none'].includes(op.audit))
55
57
  return 'audit must be change, sensitive-read, read or none';
56
- if (op.audit !== 'change' && op.effect !== 'read')
57
- return 'audit of a change must be change';
58
+ if (['read', 'none'].includes(op.audit) && op.effect !== 'read')
59
+ return 'audit of a change must be change or sensitive-read';
58
60
  }
59
61
  if (op.mcp !== undefined) {
60
62
  if (!['exposed', 'hidden', 'human-only'].includes(op.mcp))
@@ -64,6 +66,29 @@ export function semanticsProblem(name, op, ops) {
64
66
  if (op.mcp === 'human-only' && op.ai === 'hidden')
65
67
  return 'mcp cannot expose a hidden operation';
66
68
  }
69
+ if (op.ctl !== undefined) {
70
+ if (!['exposed', 'hidden'].includes(op.ctl))
71
+ return 'ctl must be exposed or hidden';
72
+ if (op.ctl === 'exposed' && op.ai === 'hidden')
73
+ return 'ctl cannot expose a hidden operation';
74
+ }
75
+ if (op.gateway !== undefined) {
76
+ const g = typeof op.gateway === 'string' && Object.hasOwn(ops, op.gateway) ? ops[op.gateway] : undefined;
77
+ if (ctlExposure(op) !== 'exposed')
78
+ return 'gateway applies only to an operation exposed to ctl';
79
+ if (op.gateway === name || !g)
80
+ return 'gateway must name another registered operation';
81
+ if (g.ai !== 'hidden' || g.flow?.type !== 'invoke' || g.gateway !== undefined)
82
+ return 'gateway must name a hidden invoke operation without its own gateway';
83
+ if (g.permission !== op.permission)
84
+ return 'gateway must name an operation with the same permission';
85
+ if (EFFECT_RANK[g.effect] < EFFECT_RANK[op.effect])
86
+ return "gateway effect must be at least the operation's effect";
87
+ if (auditClass(g) !== auditClass(op))
88
+ return "gateway audit must equal the operation's audit class";
89
+ if (Object.entries(ops).some(([other, spec]) => other < name && spec?.gateway === op.gateway))
90
+ return 'gateway serves only one operation';
91
+ }
67
92
  if (op.dynamicProvider !== undefined && (typeof op.dynamicProvider !== 'boolean' || op.dynamicProvider && !isToolClass(op.ai)))
68
93
  return 'dynamicProvider requires an AI tool class';
69
94
  const l = op.labels;
@@ -1,5 +1,6 @@
1
1
  import { type Operation } from './descriptor.js';
2
2
  import { type OperationSemantics } from './operation-semantics.js';
3
+ import { type SharedDefs } from './shared-defs.js';
3
4
  export declare const AI_CLASSES: readonly ["read", "preview", "draft", "propose", "local", "one-click", "human-only", "hidden"];
4
5
  export type AIClass = typeof AI_CLASSES[number];
5
6
  export type RegisteredOperation = Operation & OperationSemantics & {
@@ -18,6 +19,7 @@ export interface OperationRegistry {
18
19
  format: 'synopkgland.api';
19
20
  version: 2 | 3;
20
21
  nativeHttp?: import('./native-types.js').NativeHttp;
22
+ $defs?: SharedDefs;
21
23
  operations: Record<string, RegisteredOperation>;
22
24
  }
23
25
  export declare const INFRASTRUCTURE_METHODS: Set<string>;
@@ -29,10 +31,17 @@ export declare function checkRouteEquality(registry: OperationRegistry, routes:
29
31
  permission: string;
30
32
  }[]): void;
31
33
  export declare function registryPermissions(registry: OperationRegistry): string;
34
+ /** ctl commands: every operation except hidden and `ctl: hidden` ones. A
35
+ * gatewayed operation keeps its name, cli and semantics; ctl calls its gateway
36
+ * with the gateway's params and checks the gateway's result. Command schemas
37
+ * are self-contained even when the registry shares `$defs`. */
38
+ export declare function ctlCommands(registry: Pick<OperationRegistry, 'operations' | '$defs'>): Record<string, RegisteredOperation>;
32
39
  /** Model-facing tools. Semantic fields appear only when declared, so earlier
33
40
  * registries generate byte-identical tools.json. With mcp, only tools an
34
- * external MCP client may list (exposed, or human-only as a card) remain. */
35
- export declare function registryTools(registry: Pick<OperationRegistry, 'operations'>, options?: {
41
+ * external MCP client may list (exposed, or human-only as a card) remain, and
42
+ * a gatewayed tool shows the call an external client makes: the gateway's
43
+ * params, result and flow. The chat view keeps the business shape. */
44
+ export declare function registryTools(registry: Pick<OperationRegistry, 'operations' | '$defs'>, options?: {
36
45
  mcp?: boolean;
37
46
  }): {
38
47
  consent?: import("./operation-semantics.js").OperationConsent | undefined;
@@ -44,6 +53,8 @@ export declare function registryTools(registry: Pick<OperationRegistry, 'operati
44
53
  mcp?: "exposed" | "hidden" | "human-only" | undefined;
45
54
  labels?: Record<string, string> | undefined;
46
55
  dynamicProvider?: boolean | undefined;
56
+ ctl?: "exposed" | "hidden" | undefined;
57
+ gateway?: string | undefined;
47
58
  execution: string;
48
59
  preview?: string | undefined;
49
60
  name: string;
@@ -3,7 +3,8 @@ import { dirname, join, resolve, relative, isAbsolute } from 'node:path';
3
3
  import { strictJson } from './json.js';
4
4
  import { ajv, safeSchema, validateFlow } from './descriptor.js';
5
5
  import { validateNativeRegistry } from './native-registry.js';
6
- import { semanticsProblem, declaredSemantics, isToolClass, mcpExposure, TOOL_EXECUTION } from './operation-semantics.js';
6
+ import { semanticsProblem, declaredSemantics, isToolClass, mcpExposure, ctlExposure, TOOL_EXECUTION } from './operation-semantics.js';
7
+ import { expandOperations, sharedClosure } from './shared-defs.js';
7
8
  export const AI_CLASSES = ['read', 'preview', 'draft', 'propose', 'local', 'one-click', 'human-only', 'hidden'];
8
9
  export const INFRASTRUCTURE_METHODS = new Set(['synopkgland.describe', 'identity.status', 'identity.login', 'identity.session', 'identity.logout']);
9
10
  const METHOD = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/;
@@ -25,8 +26,23 @@ export function validateRegistry(value) {
25
26
  return;
26
27
  }
27
28
  const fail = (why) => { throw Error('CTL_REGISTRY_INVALID: ' + why); };
28
- if (!value || value.format !== 'synopkgland.api' || value.version !== 2 || !value.operations || Array.isArray(value.operations) || typeof value.operations !== 'object' || Object.keys(value.operations).length > 1024 || Object.keys(value).some(k => !['format', 'version', 'operations'].includes(k)))
29
+ if (!value || value.format !== 'synopkgland.api' || value.version !== 2 || !value.operations || Array.isArray(value.operations) || typeof value.operations !== 'object' || Object.keys(value.operations).length > 1024 || Object.keys(value).some(k => !['format', 'version', 'operations', '$defs'].includes(k)))
29
30
  fail('expected synopkgland.api v2 operations.');
31
+ const shared = value.$defs;
32
+ if (shared !== undefined) {
33
+ if (!shared || typeof shared !== 'object' || Array.isArray(shared) || Object.keys(shared).length > 4096)
34
+ fail('$defs must be an object of JSON schemas.');
35
+ for (const [def, schema] of Object.entries(shared)) {
36
+ if (!def || typeof schema !== 'boolean' && (!schema || typeof schema !== 'object' || Array.isArray(schema)))
37
+ fail(`$defs entries must be JSON schemas: ${def}.`);
38
+ try {
39
+ safeSchema(schema);
40
+ }
41
+ catch {
42
+ fail(`$defs entries must be JSON schemas: ${def}.`);
43
+ }
44
+ }
45
+ }
30
46
  const bindings = {};
31
47
  const paths = new Set();
32
48
  for (const [name, op] of Object.entries(value.operations)) {
@@ -47,8 +63,17 @@ export function validateRegistry(value) {
47
63
  for (const schema of [op.paramsSchema, op.resultSchema]) {
48
64
  if (!schema || typeof schema !== 'object' || Array.isArray(schema))
49
65
  fail(`${name}: params/result schemas are required.`);
66
+ if (!shared) {
67
+ safeSchema(schema);
68
+ ajv.compile(schema);
69
+ continue;
70
+ }
71
+ const { defs, missing } = sharedClosure(schema, shared);
72
+ if (missing !== undefined)
73
+ fail(`${name}: schema reference #/$defs/${missing} is not defined.`);
74
+ const names = Object.keys(defs);
50
75
  safeSchema(schema);
51
- ajv.compile(schema);
76
+ ajv.compile(names.length ? { ...schema, $defs: { ...(schema.$defs ?? {}), ...defs } } : schema);
52
77
  }
53
78
  if (['read', 'preview'].includes(op.ai) && op.effect !== 'read')
54
79
  fail(`${name}: read/preview tools must be non-mutating.`);
@@ -107,6 +132,17 @@ export function checkRouteEquality(registry, routes) {
107
132
  export function registryPermissions(registry) {
108
133
  return JSON.stringify({ schema: 1, default: 'administrators', methods: Object.fromEntries(Object.entries(registry.operations).sort(([a], [b]) => a.localeCompare(b)).map(([name, op]) => [name, op.permission])) }, null, 2) + '\n';
109
134
  }
135
+ /** ctl commands: every operation except hidden and `ctl: hidden` ones. A
136
+ * gatewayed operation keeps its name, cli and semantics; ctl calls its gateway
137
+ * with the gateway's params and checks the gateway's result. Command schemas
138
+ * are self-contained even when the registry shares `$defs`. */
139
+ export function ctlCommands(registry) {
140
+ const ops = expandOperations(registry);
141
+ return Object.fromEntries(Object.entries(ops).filter(([, op]) => op.ai !== 'hidden' && ctlExposure(op) !== 'hidden').map(([name, op]) => {
142
+ const gateway = op.gateway ? ops[op.gateway] : undefined;
143
+ return [name, gateway ? { ...op, effect: gateway.effect, paramsSchema: gateway.paramsSchema, resultSchema: gateway.resultSchema, flow: { type: 'invoke', method: op.gateway } } : op];
144
+ }));
145
+ }
110
146
  function toolResultSchema(op) {
111
147
  if (!op.http || !['paginate-http', 'ndjson'].includes(op.flow.type))
112
148
  return op.resultSchema;
@@ -115,9 +151,15 @@ function toolResultSchema(op) {
115
151
  }
116
152
  /** Model-facing tools. Semantic fields appear only when declared, so earlier
117
153
  * registries generate byte-identical tools.json. With mcp, only tools an
118
- * external MCP client may list (exposed, or human-only as a card) remain. */
154
+ * external MCP client may list (exposed, or human-only as a card) remain, and
155
+ * a gatewayed tool shows the call an external client makes: the gateway's
156
+ * params, result and flow. The chat view keeps the business shape. */
119
157
  export function registryTools(registry, options = {}) {
120
- return Object.entries(registry.operations).sort(([a], [b]) => a.localeCompare(b)).filter(([, op]) => isToolClass(op.ai) && (!options.mcp || mcpExposure(op) !== 'hidden')).map(([name, op]) => ({ name, description: op.summary, inputSchema: op.paramsSchema, outputSchema: toolResultSchema(op), annotations: { readOnlyHint: op.effect === 'read', destructiveHint: op.effect === 'destructive', openWorldHint: false }, ai: op.ai, flow: op.flow, ...(op.preview ? { preview: op.preview } : {}), execution: TOOL_EXECUTION[op.ai], ...declaredSemantics(op) }));
158
+ const ops = expandOperations(registry);
159
+ return Object.entries(ops).sort(([a], [b]) => a.localeCompare(b)).filter(([, op]) => isToolClass(op.ai) && (!options.mcp || mcpExposure(op) !== 'hidden')).map(([name, op]) => {
160
+ const call = options.mcp && op.gateway ? { ...ops[op.gateway], flow: { type: 'invoke', method: op.gateway } } : op;
161
+ return { name, description: op.summary, inputSchema: call.paramsSchema, outputSchema: toolResultSchema(call), annotations: { readOnlyHint: call.effect === 'read', destructiveHint: call.effect === 'destructive', openWorldHint: false }, ai: op.ai, flow: call.flow, ...(op.preview ? { preview: op.preview } : {}), execution: TOOL_EXECUTION[op.ai], ...declaredSemantics(op) };
162
+ });
121
163
  }
122
164
  function semanticsLine(op) {
123
165
  const parts = [];
@@ -135,6 +177,8 @@ function semanticsLine(op) {
135
177
  parts.push(`audit: ${op.audit}`);
136
178
  if (op.mcp)
137
179
  parts.push(`MCP: ${op.mcp}`);
180
+ if (op.ctl)
181
+ parts.push(`ctl: ${op.ctl}`);
138
182
  if (op.dynamicProvider)
139
183
  parts.push('runtime tools: the App adds tools that call this operation at runtime');
140
184
  if (op.labels)
@@ -142,7 +186,7 @@ function semanticsLine(op) {
142
186
  return parts.length ? `${parts.join('; ').replaceAll('<', '&lt;')}\n\n` : '';
143
187
  }
144
188
  export function registryReference(registry) {
145
- return '<!-- Generated by synopkgland ctl generate; edit the operation registry. -->\n# App operations\n\n' + Object.entries(registry.operations).sort(([a], [b]) => a.localeCompare(b)).map(([name, op]) => `## ${name}\n\n${op.summary.replaceAll('<', '&lt;')}\n\nAI: ${op.ai}; effect: ${op.effect}; permission: ${op.permission}; flow: ${op.flow.type}\n\n${semanticsLine(op)}${op.ai === 'hidden' ? 'No ctl or AI exposure.' : `ctl: \`${op.cli.join(' ')}\``}\n${op.preview ? `\nPreview: \`${op.preview}\`; obtain human confirmation before execution.\n` : ''}`).join('\n');
189
+ return '<!-- Generated by synopkgland ctl generate; edit the operation registry. -->\n# App operations\n\n' + Object.entries(registry.operations).sort(([a], [b]) => a.localeCompare(b)).map(([name, op]) => `## ${name}\n\n${op.summary.replaceAll('<', '&lt;')}\n\nAI: ${op.ai}; effect: ${op.effect}; permission: ${op.permission}; flow: ${op.flow.type}\n\n${semanticsLine(op)}${op.ai === 'hidden' ? 'No ctl or AI exposure.' : ctlExposure(op) === 'hidden' ? 'No ctl exposure.' : `ctl: \`${op.cli.join(' ')}\`${op.gateway ? ` via \`${op.gateway}\`` : ''}`}\n${op.preview ? `\nPreview: \`${op.preview}\`; obtain human confirmation before execution.\n` : ''}`).join('\n');
146
190
  }
147
191
  export function writeGenerated(path, contents, check) {
148
192
  if (check) {
@@ -0,0 +1,30 @@
1
+ /** Optional registry-level `$defs`. An operation schema's `#/$defs/<name>`
2
+ * reference resolves to its own `$defs` first, then to the shared ones.
3
+ * Generators inline what a schema uses, so every emitted tool and ctl
4
+ * command schema stays self-contained. Registries without `$defs` are
5
+ * never rewritten. */
6
+ export type SharedDefs = Record<string, unknown>;
7
+ type Schemas = {
8
+ paramsSchema: Record<string, any>;
9
+ resultSchema: Record<string, any>;
10
+ };
11
+ /** Shared definitions a schema needs, followed transitively; a name the schema defines locally always resolves locally. */
12
+ export declare function sharedClosure(schema: Record<string, any>, shared: SharedDefs): {
13
+ defs: SharedDefs;
14
+ missing?: string;
15
+ };
16
+ export declare function expandSchema<T extends Record<string, any>>(schema: T, shared: SharedDefs): T;
17
+ /** Operations with self-contained schemas. Without shared `$defs` the operations are returned unchanged. */
18
+ export declare function expandOperations<O extends Schemas>(registry: {
19
+ operations: Record<string, O>;
20
+ $defs?: SharedDefs;
21
+ }): Record<string, O>;
22
+ /** Dedupes definitions for generated artifacts: a name defined identically by
23
+ * several operation schemas moves to the shared `$defs` (the most frequent
24
+ * variant when variants differ), and every local copy equal to its shared
25
+ * definition is dropped. Only for registries that declare `$defs`. */
26
+ export declare function compactRegistry<R extends {
27
+ operations: Record<string, O>;
28
+ $defs?: SharedDefs;
29
+ }, O extends Schemas>(registry: R): R;
30
+ export {};
@@ -0,0 +1,92 @@
1
+ import { canonicalize } from 'json-canonicalize';
2
+ const PREFIX = '#/$defs/';
3
+ const record = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
4
+ function refs(value, into) {
5
+ if (Array.isArray(value)) {
6
+ for (const item of value)
7
+ refs(item, into);
8
+ return;
9
+ }
10
+ if (!record(value))
11
+ return;
12
+ for (const [key, item] of Object.entries(value)) {
13
+ if (key === '$ref' && typeof item === 'string' && item.startsWith(PREFIX))
14
+ into.add(item.slice(PREFIX.length).split('/')[0].replaceAll('~1', '/').replaceAll('~0', '~'));
15
+ else
16
+ refs(item, into);
17
+ }
18
+ }
19
+ /** Shared definitions a schema needs, followed transitively; a name the schema defines locally always resolves locally. */
20
+ export function sharedClosure(schema, shared) {
21
+ const local = record(schema.$defs) ? schema.$defs : {};
22
+ let pending = new Set();
23
+ refs(schema, pending);
24
+ const defs = {};
25
+ while (pending.size) {
26
+ const next = new Set();
27
+ for (const name of [...pending].sort()) {
28
+ if (Object.hasOwn(local, name) || Object.hasOwn(defs, name))
29
+ continue;
30
+ if (!Object.hasOwn(shared, name))
31
+ return { defs, missing: name };
32
+ defs[name] = shared[name];
33
+ refs(shared[name], next);
34
+ }
35
+ pending = next;
36
+ }
37
+ return { defs };
38
+ }
39
+ export function expandSchema(schema, shared) {
40
+ const { defs } = sharedClosure(schema, shared);
41
+ const names = Object.keys(defs).sort();
42
+ if (!names.length)
43
+ return schema;
44
+ return { ...schema, $defs: { ...(record(schema.$defs) ? schema.$defs : {}), ...Object.fromEntries(names.map(name => [name, defs[name]])) } };
45
+ }
46
+ /** Operations with self-contained schemas. Without shared `$defs` the operations are returned unchanged. */
47
+ export function expandOperations(registry) {
48
+ const shared = registry.$defs;
49
+ if (!shared)
50
+ return registry.operations;
51
+ return Object.fromEntries(Object.entries(registry.operations).map(([name, op]) => [name, { ...op, paramsSchema: expandSchema(op.paramsSchema, shared), resultSchema: expandSchema(op.resultSchema, shared) }]));
52
+ }
53
+ /** Dedupes definitions for generated artifacts: a name defined identically by
54
+ * several operation schemas moves to the shared `$defs` (the most frequent
55
+ * variant when variants differ), and every local copy equal to its shared
56
+ * definition is dropped. Only for registries that declare `$defs`. */
57
+ export function compactRegistry(registry) {
58
+ if (!registry.$defs)
59
+ return registry;
60
+ const shared = { ...registry.$defs };
61
+ const variants = new Map();
62
+ for (const op of Object.values(registry.operations))
63
+ for (const schema of [op.paramsSchema, op.resultSchema]) {
64
+ if (!record(schema?.$defs))
65
+ continue;
66
+ for (const [name, value] of Object.entries(schema.$defs)) {
67
+ if (Object.hasOwn(shared, name))
68
+ continue;
69
+ const byText = variants.get(name) ?? new Map(), text = canonicalize(value), seen = byText.get(text);
70
+ byText.set(text, { count: (seen?.count ?? 0) + 1, value });
71
+ variants.set(name, byText);
72
+ }
73
+ }
74
+ for (const [name, byText] of variants) {
75
+ const [text, best] = [...byText].sort(([a, x], [b, y]) => y.count - x.count || (a < b ? -1 : a > b ? 1 : 0))[0];
76
+ if (best.count > 1 && text)
77
+ shared[name] = best.value;
78
+ }
79
+ const texts = new Map(Object.entries(shared).map(([name, value]) => [name, canonicalize(value)]));
80
+ const compact = (schema) => {
81
+ if (!record(schema?.$defs))
82
+ return schema;
83
+ const kept = Object.entries(schema.$defs).filter(([name, value]) => texts.get(name) !== canonicalize(value));
84
+ if (kept.length === Object.keys(schema.$defs).length)
85
+ return schema;
86
+ const { $defs: _, ...rest } = schema;
87
+ return kept.length ? { ...schema, $defs: Object.fromEntries(kept) } : rest;
88
+ };
89
+ const names = Object.keys(shared).sort();
90
+ return { ...registry, $defs: Object.fromEntries(names.map(name => [name, shared[name]])),
91
+ operations: Object.fromEntries(Object.entries(registry.operations).map(([name, op]) => [name, { ...op, paramsSchema: compact(op.paramsSchema), resultSchema: compact(op.resultSchema) }])) };
92
+ }
@@ -1,13 +1,14 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { appSdkVersion, sdkSource } from '../runtime/sdk-source.js';
3
3
  import { join } from 'node:path';
4
- import { readRegistry, registryFile, registryArtifacts, registryPermissions, writeGenerated, checkRouteEquality } from '../ctl/registry.js';
4
+ import { readRegistry, registryFile, registryArtifacts, registryPermissions, writeGenerated, checkRouteEquality, ctlCommands } from '../ctl/registry.js';
5
+ import { compactRegistry } from '../ctl/shared-defs.js';
5
6
  import { makeDescriptor, validateDescriptor, flowMethods } from '../ctl/descriptor.js';
6
7
  import { readApiPermissions, API_PERMISSIONS_FILE } from './api-permissions.js';
7
8
  import { sdkBackend } from './manifest.js';
8
9
  import { describeApiRoutes } from './api-description.js';
9
10
  import { generateNativeOperations } from './native-http.js';
10
- import { descriptionFindings } from '../ctl/operation-semantics.js';
11
+ import { descriptionFindings, ctlExposure } from '../ctl/operation-semantics.js';
11
12
  /** Tool summary lint. Warnings by default; ctl.descriptions: error refuses generation. */
12
13
  export function descriptionWarnings(m, operations) {
13
14
  const findings = descriptionFindings(operations).map(f => f.message);
@@ -21,12 +22,14 @@ export function operationRegistry(m) {
21
22
  return readRegistry(registryFile(m.root, m.ctl.registry));
22
23
  }
23
24
  export function registryDescriptor(m, registry = operationRegistry(m)) {
24
- const operations = registry.operations;
25
+ // Shared $defs: operations carry deduplicated schemas, commands stay self-contained.
26
+ const shared = registry.$defs ? compactRegistry(registry) : undefined;
27
+ const operations = shared ? shared.operations : registry.operations;
25
28
  const bindings = Object.fromEntries(Object.entries(operations).map(([name, op]) => [name, { effect: op.effect, permission: op.permission }]));
26
29
  if (m.capabilities.identity)
27
30
  for (const name of ['identity.session', 'identity.logout'])
28
31
  bindings[name] = { effect: 'write', permission: 'public' };
29
- const commands = Object.fromEntries(Object.entries(operations).filter(([, op]) => op.ai !== 'hidden'));
32
+ const commands = ctlCommands(shared ?? registry);
30
33
  const external = m.ctl?.external;
31
34
  if (external)
32
35
  for (const entry of Object.values(external)) {
@@ -34,7 +37,7 @@ export function registryDescriptor(m, registry = operationRegistry(m)) {
34
37
  if (!op || op.ai !== 'hidden' || op.permission !== 'administrators' || op.effect !== 'destructive')
35
38
  throw Error('CTL_EXTERNAL_ENTRY: external entry must be a hidden destructive administrator operation.');
36
39
  }
37
- const description = makeDescriptor({ package: { id: m.package, version: m.spkVersion, displayName: m.displayname }, aliases: m.ctl?.aliases ?? [m.package.toLowerCase()], provenance: { developedBy: m.ctl?.developedBy ?? 'unknown', generator: 'synopkgland-cli' }, entry: m.entry ?? 'policy', transport: { path: `/webman/3rdparty/${m.package}/cgi/api.cgi`, auth: m.capabilities.identity ? 'dsm-app-session' : 'dsm-session' }, operations, commands, bindings, ...(external ? { external } : {}) });
40
+ const description = makeDescriptor({ package: { id: m.package, version: m.spkVersion, displayName: m.displayname }, aliases: m.ctl?.aliases ?? [m.package.toLowerCase()], provenance: { developedBy: m.ctl?.developedBy ?? 'unknown', generator: 'synopkgland-cli' }, entry: m.entry ?? 'policy', transport: { path: `/webman/3rdparty/${m.package}/cgi/api.cgi`, auth: m.capabilities.identity ? 'dsm-app-session' : 'dsm-session' }, operations, commands, bindings, ...(external ? { external } : {}), ...(shared ? { $defs: shared.$defs } : {}) });
38
41
  return validateDescriptor(description, m.package, m.spkVersion);
39
42
  }
40
43
  /** Generation writes metadata only. The exporter constructs routes without running handlers. */
@@ -69,7 +72,7 @@ export async function generateOperations(m, run, check = false, bridgeMethods) {
69
72
  registry.operations[route.method] = { ...structuredClone(spec), permission: route.permission };
70
73
  }
71
74
  }
72
- writeGenerated(runtimeFile, JSON.stringify(registry, null, 2) + '\n', check);
75
+ writeGenerated(runtimeFile, JSON.stringify(compactRegistry(registry), null, 2) + '\n', check);
73
76
  checkRouteEquality(registry, routes);
74
77
  const kinds = new Map(routes.map(route => [route.method, route.kind ?? 'json']));
75
78
  if (m.ctl?.external) {
@@ -79,9 +82,12 @@ export async function generateOperations(m, run, check = false, bridgeMethods) {
79
82
  if (kinds.get(entry.method) !== 'json')
80
83
  throw Error('CTL_EXTERNAL_ENTRY: external entries require JSON RPC handlers.');
81
84
  }
85
+ // Only ctl commands need a ctl transport; a gatewayed command runs its gateway, a JSON RPC route.
82
86
  for (const [name, op] of Object.entries(registry.operations))
83
- if (op.ai !== 'hidden') {
84
- for (const method of flowMethods(op.flow))
87
+ if (op.ai !== 'hidden' && ctlExposure(op) !== 'hidden') {
88
+ if (op.gateway && kinds.get(op.gateway) !== 'json')
89
+ throw Error('CTL_FLOW_UNSUPPORTED: gateway must be a JSON RPC route: ' + name);
90
+ for (const method of flowMethods(op.gateway ? { type: 'invoke', method: op.gateway } : op.flow))
85
91
  if (['http', 'integration'].includes(kinds.get(method) ?? ''))
86
92
  throw Error('CTL_FLOW_UNSUPPORTED: exposed flows require RPC or SDK transfer handlers: ' + name);
87
93
  }
@@ -64,11 +64,21 @@ export declare function staleUiIgnores(problems: UiProblem[], ignores: ResolvedU
64
64
  export declare function showUiMatch(text: string, limit?: number): string;
65
65
  /** A logical file with a bundler-looking hash (Name-AbCd1234.js) becomes Name-[hash].js. */
66
66
  export declare function suggestUiIgnoreFile(file: string): string;
67
+ /** The longest `match` text readUiSecretIgnores accepts. */
68
+ export declare const UI_MATCH_LIMIT = 4096;
67
69
  /**
68
- * A ready-to-paste ui_secret_ignores block for reviewed false positives. Texts that
69
- * look like real tokens or exceed 200 characters are left for the developer to copy.
70
+ * A YAML double-quoted scalar that parses back to exactly `text`. Only printable
71
+ * ASCII is written raw, so no YAML line-break or BOM rule can alter the value.
70
72
  */
71
- export declare function uiIgnoreSuggestion(problems: UiProblem[], moduleVersion?: string): string;
73
+ export declare function yamlQuote(text: string): string;
74
+ /**
75
+ * A ready-to-paste ui_secret_ignores block for reviewed false positives, one entry per
76
+ * file with every flagged text, untruncated, exactly as `match` needs it. Pass the
77
+ * resolved ignores so a file that already has an entry gets a complete replacement.
78
+ * Texts that look like real tokens are never printed, and texts over UI_MATCH_LIMIT
79
+ * cannot be listed; both leave a comment instead.
80
+ */
81
+ export declare function uiIgnoreSuggestion(problems: UiProblem[], moduleVersion?: string, ignores?: ResolvedUiSecretIgnore[]): string;
72
82
  export declare function describeUiProblem(problem: UiProblem): string;
73
83
  export declare function scanUiTree(root: string, ignores?: ResolvedUiSecretIgnore[], moduleVersion?: string, packed?: boolean): UiProblem[];
74
84
  /** Returns the resolved ignores; record them with storedUiSecretIgnores. */
@@ -28,7 +28,7 @@ export function readUiSecretIgnores(value) {
28
28
  if (match === undefined)
29
29
  return item.file.includes(UI_HASH_TOKEN);
30
30
  return !match.length || new Set(match).size !== match.length ||
31
- match.some(text => typeof text !== "string" || !text || text.length > 4096);
31
+ match.some(text => typeof text !== "string" || !text || text.length > UI_MATCH_LIMIT);
32
32
  }))
33
33
  throw invalid();
34
34
  // Replace one token with an inert character so the exact-path rules still reject
@@ -253,35 +253,53 @@ export function showUiMatch(text, limit = 80) {
253
253
  export function suggestUiIgnoreFile(file) {
254
254
  return file.replace(/^(.*\/)?([^/]*[-.])[A-Za-z0-9_-]{8}(\.[A-Za-z0-9]+)$/, (_all, dir = "", stem, ext) => `${dir}${stem}${UI_HASH_TOKEN}${ext}`);
255
255
  }
256
+ /** The longest `match` text readUiSecretIgnores accepts. */
257
+ export const UI_MATCH_LIMIT = 4096;
256
258
  /**
257
- * A ready-to-paste ui_secret_ignores block for reviewed false positives. Texts that
258
- * look like real tokens or exceed 200 characters are left for the developer to copy.
259
+ * A YAML double-quoted scalar that parses back to exactly `text`. Only printable
260
+ * ASCII is written raw, so no YAML line-break or BOM rule can alter the value.
259
261
  */
260
- export function uiIgnoreSuggestion(problems, moduleVersion) {
262
+ export function yamlQuote(text) {
263
+ return JSON.stringify(text).replace(/[^\x20-\x7e]/g, char => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`);
264
+ }
265
+ /**
266
+ * A ready-to-paste ui_secret_ignores block for reviewed false positives, one entry per
267
+ * file with every flagged text, untruncated, exactly as `match` needs it. Pass the
268
+ * resolved ignores so a file that already has an entry gets a complete replacement.
269
+ * Texts that look like real tokens are never printed, and texts over UI_MATCH_LIMIT
270
+ * cannot be listed; both leave a comment instead.
271
+ */
272
+ export function uiIgnoreSuggestion(problems, moduleVersion, ignores = []) {
261
273
  const byFile = new Map();
262
- const manual = new Set();
263
274
  for (const problem of problems) {
264
275
  if (SOURCE_MAP_PATTERNS.includes(problem.pattern) || !problem.matches)
265
276
  continue;
266
277
  const file = logicalUiFile(problem.file, moduleVersion);
267
- const texts = byFile.get(file) ?? [];
278
+ const entry = byFile.get(file) ?? { texts: [], redacted: 0, long: 0 };
268
279
  for (const text of problem.matches) {
269
- if (text.length > 200 || showUiMatch(text, Infinity).startsWith("<redacted"))
270
- manual.add(file);
280
+ if (showUiMatch(text, Infinity).startsWith("<redacted"))
281
+ entry.redacted++;
282
+ else if (text.length > UI_MATCH_LIMIT)
283
+ entry.long++;
271
284
  else
272
- texts.push(text);
285
+ entry.texts.push(text);
273
286
  }
274
- byFile.set(file, texts);
287
+ byFile.set(file, entry);
275
288
  }
276
289
  if (!byFile.size)
277
290
  return "";
278
291
  const lines = ["ui_secret_ignores:"];
279
- for (const [file, texts] of byFile) {
280
- lines.push(` - file: ${JSON.stringify(suggestUiIgnoreFile(file))}`, " reason: \"<why this is a false positive>\"", " match:");
281
- for (const text of unique(texts))
282
- lines.push(` - ${JSON.stringify(text)}`);
283
- if (manual.has(file) || !texts.length)
284
- lines.push(` # copy any other flagged text from ui/${file} after review`);
292
+ for (const [file, { texts, redacted, long }] of byFile) {
293
+ const existing = ignores.find(item => item.file === file);
294
+ if (existing)
295
+ lines.push(` # replaces the existing entry for ui/${existing.pattern ?? existing.file}`);
296
+ lines.push(` - file: ${yamlQuote(existing?.pattern ?? suggestUiIgnoreFile(file))}`, ` reason: ${existing ? yamlQuote(existing.reason) : "\"<why this is a false positive>\""}`, " match:");
297
+ for (const text of unique([...existing?.match ?? [], ...texts]))
298
+ lines.push(` - ${yamlQuote(text)}`);
299
+ if (redacted)
300
+ lines.push(` # copy from ui/${file} after review: ${redacted} flagged text(s) look like real tokens and are not printed`);
301
+ if (long)
302
+ lines.push(` # ${long} flagged text(s) in ui/${file} exceed ${UI_MATCH_LIMIT} characters and cannot be listed; shorten them`);
285
303
  }
286
304
  return lines.join("\n");
287
305
  }
@@ -322,7 +340,7 @@ export function enforcePublicUi(root, ignores = [], moduleVersion) {
322
340
  console.warn(`[UI_SECRET_IGNORED] ui/${problem.file}: ${problem.pattern}; ${problem.ignoredBy ? `matched ui/${problem.ignoredBy}; ` : ""}reason: ${problem.ignored}`);
323
341
  const errors = problems.filter(item => !item.ignored);
324
342
  if (errors.length) {
325
- const paste = uiIgnoreSuggestion(errors, moduleVersion);
343
+ const paste = uiIgnoreSuggestion(errors, moduleVersion, resolved);
326
344
  throw Object.assign(new Error(errors.map(describeUiProblem).join("\n") +
327
345
  (paste ? `\nOnly if every hit is a reviewed false positive, add to dsm-package.yaml:\n${paste}` : "")), { code: "PUBLIC_UI_UNSAFE", hint: "Files under ui/ are public. Remove credentials and source maps; only false positives may use ui_secret_ignores with a reason and match." });
328
346
  }
package/dist/validate.js CHANGED
@@ -78,14 +78,24 @@ export function validateProject(project, _options = {}) {
78
78
  try {
79
79
  // Scan JS/CSS as build packs it (minified), so printed match texts agree with build.
80
80
  const raw = scanUiTree(dir, [], undefined, true).map(item => ({ ...item, file: prefix + item.file }));
81
- for (const stale of staleUiIgnores(raw, ignores))
81
+ const staleList = staleUiIgnores(raw, ignores);
82
+ for (const stale of staleList)
82
83
  problems.push({
83
84
  code: "UI_SECRET_IGNORE_STALE", span: { file: "dsm-package.yaml", line: 1, column: 1 },
84
85
  message: `ui_secret_ignores ui/${stale.entry} match ${showUiMatch(stale.match)} no longer occurs in ui/${stale.file}`,
85
86
  suggestion: "Remove the stale match (or the whole entry) after reviewing the file again.",
86
87
  });
87
- for (const item of applyUiIgnores(raw, ignores)) {
88
- const paste = item.ignored ? "" : uiIgnoreSuggestion([item]);
88
+ const applied = applyUiIgnores(raw, ignores);
89
+ // One complete entry per file, on its first unexempted finding, so pasting never duplicates a file.
90
+ const pasted = new Set();
91
+ // A replacement entry keeps only listed texts that still occur.
92
+ const current = ignores.map(ignore => ignore.match
93
+ ? { ...ignore, match: ignore.match.filter(text => !staleList.some(stale => stale.file === ignore.file && stale.match === text)) } : ignore);
94
+ for (const item of applied) {
95
+ const paste = item.ignored || pasted.has(item.file) ? "" :
96
+ uiIgnoreSuggestion(applied.filter(other => !other.ignored && other.file === item.file), undefined, current);
97
+ if (paste)
98
+ pasted.add(item.file);
89
99
  const finding = {
90
100
  code: item.ignored ? "UI_SECRET_IGNORED" : "PUBLIC_UI_UNSAFE",
91
101
  span: { file: `ui/${item.file}`, line: 1, column: 1 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.53.7",
3
+ "version": "0.53.9",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,20 +25,6 @@
25
25
  "docs/compose-admin.md",
26
26
  "docs/install-memory.md"
27
27
  ],
28
- "scripts": {
29
- "check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
30
- "build": "rm -rf dist && node scripts/prepare-native-http.mjs && tsc",
31
- "test": "pnpm run build && node --import tsx --import ./test/helpers/strict-dsm-setup.ts --test --test-concurrency=${SYNOPKGLAND_GATE_JOBS:-3} test/*.test.ts test/ctl/*.test.ts",
32
- "test:glossary": "node --test scripts/test/glossary-drift.test.mjs",
33
- "test:scripts": "node --test scripts/test/gate.test.mjs scripts/test/release.test.mjs scripts/test/pack-docker.test.mjs scripts/test/npm-pack.test.mjs scripts/test/executor-bump.test.mjs scripts/test/smoke-exports.test.mjs scripts/test/parallel.test.mjs scripts/test/scaffold-matrix.test.mjs scripts/test/frontend-deps.test.mjs scripts/test/docker-gate.test.mjs scripts/test/gate-plan.test.mjs scripts/test/gates.test.mjs && python3 scripts/test/npm-publish.py",
34
- "gates": "bash scripts/ci/gates.sh",
35
- "gates:fast": "bash scripts/ci/gates.sh",
36
- "prepublishOnly": "pnpm run build && node --input-type=module -e 'import {enforceRepositorySecrets} from \"./dist/secret-files.js\"; enforceRepositorySecrets(process.cwd())'",
37
- "gates:full": "bash scripts/ci/gates.sh --full",
38
- "test:basic": "node --import tsx --test test/schema.test.ts test/standalone-manifest.test.ts test/native-arch.test.ts test/archive-inventory.test.ts test/secret-files.test.ts",
39
- "check:dsm-contract": "node scripts/check-dsm-api-contract.mjs",
40
- "check:dsm-hub": "node scripts/check-dsm-api-hub.mjs"
41
- },
42
28
  "dependencies": {
43
29
  "@napi-rs/keyring": "^2.1.1",
44
30
  "@synopackageland/templates": "~0.42.0",
@@ -99,5 +85,17 @@
99
85
  "./native-layout": "./dist/standalone/native-layout.js",
100
86
  "./e2e": "./dist/e2e/dsm.js"
101
87
  },
102
- "packageManager": "pnpm@12.18.0"
103
- }
88
+ "scripts": {
89
+ "check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
90
+ "build": "rm -rf dist && node scripts/prepare-native-http.mjs && tsc",
91
+ "test": "pnpm run build && node --import tsx --import ./test/helpers/strict-dsm-setup.ts --test --test-concurrency=${SYNOPKGLAND_GATE_JOBS:-3} test/*.test.ts test/ctl/*.test.ts",
92
+ "test:glossary": "node --test scripts/test/glossary-drift.test.mjs",
93
+ "test:scripts": "node --test scripts/test/gate.test.mjs scripts/test/release.test.mjs scripts/test/pack-docker.test.mjs scripts/test/npm-pack.test.mjs scripts/test/executor-bump.test.mjs scripts/test/smoke-exports.test.mjs scripts/test/parallel.test.mjs scripts/test/scaffold-matrix.test.mjs scripts/test/frontend-deps.test.mjs scripts/test/docker-gate.test.mjs scripts/test/gate-plan.test.mjs scripts/test/gates.test.mjs && python3 scripts/test/npm-publish.py",
94
+ "gates": "bash scripts/ci/gates.sh",
95
+ "gates:fast": "bash scripts/ci/gates.sh",
96
+ "gates:full": "bash scripts/ci/gates.sh --full",
97
+ "test:basic": "node --import tsx --test test/schema.test.ts test/standalone-manifest.test.ts test/native-arch.test.ts test/archive-inventory.test.ts test/secret-files.test.ts",
98
+ "check:dsm-contract": "node scripts/check-dsm-api-contract.mjs",
99
+ "check:dsm-hub": "node scripts/check-dsm-api-hub.mjs"
100
+ }
101
+ }
@@ -174,6 +174,16 @@
174
174
  "additionalProperties": {
175
175
  "$ref": "#/$defs/operation"
176
176
  }
177
+ },
178
+ "$defs": {
179
+ "type": "object",
180
+ "maxProperties": 4096,
181
+ "additionalProperties": {
182
+ "type": [
183
+ "object",
184
+ "boolean"
185
+ ]
186
+ }
177
187
  }
178
188
  },
179
189
  "required": [
@@ -593,6 +603,17 @@
593
603
  },
594
604
  "dynamicProvider": {
595
605
  "type": "boolean"
606
+ },
607
+ "ctl": {
608
+ "enum": [
609
+ "exposed",
610
+ "hidden"
611
+ ]
612
+ },
613
+ "gateway": {
614
+ "type": "string",
615
+ "maxLength": 128,
616
+ "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$"
596
617
  }
597
618
  },
598
619
  "required": [
@@ -275,7 +275,7 @@ Each real method has one English `summary`, `paramsSchema`, `resultSchema`,
275
275
  | `propose` | Write that stores a proposal when the turn allows changes; a human reviews and applies it |
276
276
  | `local` | Reversible App-local write; runs only with the turn's Allow changes, otherwise a card the person presses |
277
277
  | `one-click` | Never runs on a model call; returns a card the person presses |
278
- | `human-only` | ctl with normal confirmation; absent from AI tools |
278
+ | `human-only` | ctl with normal confirmation unless `ctl: hidden`; absent from AI tools |
279
279
  | `hidden` | Runtime spec only; absent from ctl and AI tools |
280
280
 
281
281
  A draft names its non-mutating `preview` method; both handlers must accept the
@@ -287,10 +287,29 @@ operations fail.
287
287
  Optional AI semantics, all omitted by default: `consent` (`{category}` or
288
288
  `{param: "/json/pointer"}`), `targets` (`{max: 0..1000, traceable}`), `risk`
289
289
  (`low|medium|high`), `tier` (App token), `undo` (`{method, from, param}` receipt
290
- contract), `audit` (`change|sensitive-read|read|none`; writes stay `change`),
291
- `mcp` (`exposed|hidden|human-only`, narrowing only), `dynamicProvider: true` for an
292
- operation that runtime tools bind to, and `labels` (App strings, never for
293
- authorization). Generated `tools.json` adds a field only when it is declared.
290
+ contract), `audit` (`change|sensitive-read|read|none`; a write is `change` or
291
+ `sensitive-read`), `mcp` (`exposed|hidden|human-only`, narrowing only), `ctl`
292
+ (`exposed|hidden`, narrowing only: `hidden` keeps an operation off ctl),
293
+ `gateway` (see below), `dynamicProvider: true` for an operation that runtime
294
+ tools bind to, and `labels` (App strings, never for authorization). Generated
295
+ `tools.json` adds a field only when it is declared.
296
+
297
+ An App that runs ctl through an audited engine declares `gateway: "<method>"`
298
+ on each served operation. The gateway is its own registered hidden `invoke`
299
+ operation with the same permission and audit class and at least the same
300
+ effect, serving exactly one operation, on a JSON RPC route. The ctl command keeps
301
+ the served operation's name, CLI path and semantics but calls the gateway with
302
+ the gateway's params and checks the gateway's result; `--yes` follows the
303
+ gateway's effect. `ctl tools --mcp` shows the gateway's schemas; `tools.json`
304
+ keeps the business schema for the App's own chat. `operations.md` writes
305
+ ``ctl: `path` via `gateway` `` and `No ctl exposure.` for `ctl: hidden`.
306
+
307
+ A large registry may declare shared `$defs` at the top level. An operation
308
+ schema's `#/$defs/<name>` resolves to its own `$defs` first, then the shared
309
+ ones. Generation moves identical per-operation definitions into the shared set
310
+ for the descriptor and runtime registry; ctl commands and tools stay
311
+ self-contained. Without top-level `$defs` nothing is rewritten.
312
+
294
313
  The SDK's AI operation semantics guide has the full rules and the runtime
295
314
  namespace API. Apps using them need an SDK and CLI release that lists these
296
315
  fields in its changelog; older ctl clients refuse such descriptions.
@@ -19,7 +19,8 @@ ui_secret_ignores:
19
19
 
20
20
  Only listed texts are exempt: a new hit in the same file still fails, and a
21
21
  listed text that disappears fails as stale. `build` and `check` print a
22
- ready-to-paste entry for each failing file; paste it only after review.
22
+ ready-to-paste entry for each failing file that lists every flagged text in
23
+ full (or replaces the file's existing entry); paste it only after review.
23
24
  Exceptions are recorded in the SPK as resolved files and reported during
24
25
  inspection. They never allow source maps and do not bypass repository secret
25
26
  checks. See docs/release-checks.md.