@cleocode/cleo 2026.4.11 → 2026.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/cli/commands/add.d.ts.map +1 -1
- package/dist/cli/commands/add.js +123 -19
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/commands/agent.d.ts.map +1 -1
- package/dist/cli/commands/agent.js +64 -20
- package/dist/cli/commands/agent.js.map +1 -1
- package/dist/cli/commands/backup.d.ts +1 -0
- package/dist/cli/commands/backup.d.ts.map +1 -1
- package/dist/cli/commands/backup.js +7 -1
- package/dist/cli/commands/backup.js.map +1 -1
- package/dist/cli/commands/complete.d.ts.map +1 -1
- package/dist/cli/commands/complete.js +55 -6
- package/dist/cli/commands/complete.js.map +1 -1
- package/dist/cli/commands/find.d.ts.map +1 -1
- package/dist/cli/commands/find.js +75 -11
- package/dist/cli/commands/find.js.map +1 -1
- package/dist/cli/commands/list.d.ts.map +1 -1
- package/dist/cli/commands/list.js +84 -12
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/observe.d.ts +3 -0
- package/dist/cli/commands/observe.d.ts.map +1 -1
- package/dist/cli/commands/observe.js +12 -9
- package/dist/cli/commands/observe.js.map +1 -1
- package/dist/cli/commands/restore.d.ts +1 -0
- package/dist/cli/commands/restore.d.ts.map +1 -1
- package/dist/cli/commands/restore.js +4 -0
- package/dist/cli/commands/restore.js.map +1 -1
- package/dist/cli/commands/schema.d.ts +27 -0
- package/dist/cli/commands/schema.d.ts.map +1 -0
- package/dist/cli/commands/schema.js +160 -0
- package/dist/cli/commands/schema.js.map +1 -0
- package/dist/cli/commands/show.d.ts.map +1 -1
- package/dist/cli/commands/show.js +24 -4
- package/dist/cli/commands/show.js.map +1 -1
- package/dist/cli/help-generator.d.ts +74 -0
- package/dist/cli/help-generator.d.ts.map +1 -0
- package/dist/cli/help-generator.js +229 -0
- package/dist/cli/help-generator.js.map +1 -0
- package/dist/cli/index.js +342 -107991
- package/dist/cli/index.js.map +1 -7
- package/dist/cli/renderers/index.d.ts +35 -7
- package/dist/cli/renderers/index.d.ts.map +1 -1
- package/dist/cli/renderers/index.js +64 -10
- package/dist/cli/renderers/index.js.map +1 -1
- package/dist/cli/renderers/lafs-validator.d.ts +27 -33
- package/dist/cli/renderers/lafs-validator.d.ts.map +1 -1
- package/dist/cli/renderers/lafs-validator.js +45 -98
- package/dist/cli/renderers/lafs-validator.js.map +1 -1
- package/dist/dispatch/adapters/cli.d.ts.map +1 -1
- package/dist/dispatch/adapters/cli.js +16 -2
- package/dist/dispatch/adapters/cli.js.map +1 -1
- package/dist/dispatch/dispatcher.js +7 -7
- package/dist/dispatch/dispatcher.js.map +1 -1
- package/dist/dispatch/domains/_base.js +4 -4
- package/dist/dispatch/domains/_base.js.map +1 -1
- package/dist/dispatch/domains/_meta.d.ts +3 -3
- package/dist/dispatch/domains/_meta.d.ts.map +1 -1
- package/dist/dispatch/domains/_meta.js +2 -2
- package/dist/dispatch/domains/admin.js +19 -19
- package/dist/dispatch/domains/admin.js.map +1 -1
- package/dist/dispatch/domains/check.js +3 -3
- package/dist/dispatch/domains/check.js.map +1 -1
- package/dist/dispatch/domains/nexus.js +2 -2
- package/dist/dispatch/domains/nexus.js.map +1 -1
- package/dist/dispatch/domains/orchestrate.js +3 -3
- package/dist/dispatch/domains/orchestrate.js.map +1 -1
- package/dist/dispatch/domains/pipeline.js +1 -1
- package/dist/dispatch/domains/pipeline.js.map +1 -1
- package/dist/dispatch/domains/sticky.js +1 -1
- package/dist/dispatch/domains/sticky.js.map +1 -1
- package/dist/dispatch/domains/tasks.js +1 -1
- package/dist/dispatch/domains/tasks.js.map +1 -1
- package/dist/dispatch/domains/tools.js +5 -5
- package/dist/dispatch/domains/tools.js.map +1 -1
- package/dist/dispatch/engines/_error.d.ts +34 -0
- package/dist/dispatch/engines/_error.d.ts.map +1 -1
- package/dist/dispatch/engines/_error.js +44 -0
- package/dist/dispatch/engines/_error.js.map +1 -1
- package/dist/dispatch/engines/session-engine.d.ts.map +1 -1
- package/dist/dispatch/engines/session-engine.js +18 -68
- package/dist/dispatch/engines/session-engine.js.map +1 -1
- package/dist/dispatch/engines/system-engine.d.ts.map +1 -1
- package/dist/dispatch/engines/system-engine.js +29 -37
- package/dist/dispatch/engines/system-engine.js.map +1 -1
- package/dist/dispatch/engines/task-engine.d.ts +1 -1
- package/dist/dispatch/engines/task-engine.d.ts.map +1 -1
- package/dist/dispatch/engines/task-engine.js +35 -229
- package/dist/dispatch/engines/task-engine.js.map +1 -1
- package/dist/dispatch/lib/budget.d.ts +1 -0
- package/dist/dispatch/lib/budget.d.ts.map +1 -1
- package/dist/dispatch/lib/budget.js +36 -29
- package/dist/dispatch/lib/budget.js.map +1 -1
- package/dist/dispatch/lib/config.d.ts +1 -1
- package/dist/dispatch/lib/config.d.ts.map +1 -1
- package/dist/dispatch/lib/defaults.d.ts +0 -2
- package/dist/dispatch/lib/defaults.d.ts.map +1 -1
- package/dist/dispatch/lib/defaults.js +3 -0
- package/dist/dispatch/lib/defaults.js.map +1 -1
- package/dist/dispatch/lib/exit-codes.d.ts +35 -0
- package/dist/dispatch/lib/exit-codes.d.ts.map +1 -0
- package/dist/dispatch/lib/exit-codes.js +60 -0
- package/dist/dispatch/lib/exit-codes.js.map +1 -0
- package/dist/dispatch/lib/gateway-meta.d.ts +1 -1
- package/dist/dispatch/lib/meta.d.ts +2 -2
- package/dist/dispatch/lib/meta.d.ts.map +1 -1
- package/dist/dispatch/lib/meta.js +1 -1
- package/dist/dispatch/lib/meta.js.map +1 -1
- package/dist/dispatch/lib/param-utils.d.ts +1 -1
- package/dist/dispatch/lib/param-utils.d.ts.map +1 -1
- package/dist/dispatch/lib/param-utils.js +1 -1
- package/dist/dispatch/lib/param-utils.js.map +1 -1
- package/dist/dispatch/lib/proto-envelope.d.ts +56 -0
- package/dist/dispatch/lib/proto-envelope.d.ts.map +1 -0
- package/dist/dispatch/lib/proto-envelope.js +17 -0
- package/dist/dispatch/lib/proto-envelope.js.map +1 -0
- package/dist/dispatch/middleware/field-filter.d.ts +1 -0
- package/dist/dispatch/middleware/field-filter.d.ts.map +1 -1
- package/dist/dispatch/middleware/field-filter.js +10 -5
- package/dist/dispatch/middleware/field-filter.js.map +1 -1
- package/dist/dispatch/middleware/projection.js +1 -1
- package/dist/dispatch/middleware/projection.js.map +1 -1
- package/dist/dispatch/middleware/protocol-enforcement.d.ts +6 -3
- package/dist/dispatch/middleware/protocol-enforcement.d.ts.map +1 -1
- package/dist/dispatch/middleware/protocol-enforcement.js +28 -17
- package/dist/dispatch/middleware/protocol-enforcement.js.map +1 -1
- package/dist/dispatch/middleware/rate-limiter.js +2 -2
- package/dist/dispatch/middleware/rate-limiter.js.map +1 -1
- package/dist/dispatch/middleware/sanitizer.js +1 -1
- package/dist/dispatch/middleware/sanitizer.js.map +1 -1
- package/dist/dispatch/middleware/verification-gates.js +2 -2
- package/dist/dispatch/middleware/verification-gates.js.map +1 -1
- package/dist/dispatch/types.d.ts +5 -1
- package/dist/dispatch/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/templates/cleoos-hub/pi-extensions/cleo-cant-bridge.ts +180 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI `schema` command — operation introspection for agents.
|
|
3
|
+
*
|
|
4
|
+
* Allows agents to inspect the full parameter signature and declared precondition
|
|
5
|
+
* gates for any CLEO operation before calling it, replacing trial-and-error.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* cleo schema <domain.operation>
|
|
9
|
+
* cleo schema tasks.add
|
|
10
|
+
* cleo schema tasks.add --format human
|
|
11
|
+
* cleo schema tasks.add --include-examples
|
|
12
|
+
*
|
|
13
|
+
* @task T340
|
|
14
|
+
* @epic T335
|
|
15
|
+
*/
|
|
16
|
+
import { describeOperation } from '@cleocode/lafs';
|
|
17
|
+
import { OPERATIONS } from '../../dispatch/registry.js';
|
|
18
|
+
import { cliError, cliOutput } from '../renderers/index.js';
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Helpers
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
/**
|
|
23
|
+
* Resolve the target `OperationDef` from a `"domain.operation"` key.
|
|
24
|
+
*
|
|
25
|
+
* @param operationArg - The user-supplied string (e.g. `"tasks.add"`).
|
|
26
|
+
* @returns The matching `OperationDef`, or `null` if not found.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* The first dot separates domain from operation, so dotted operation names
|
|
30
|
+
* like `"complexity.estimate"` are handled correctly.
|
|
31
|
+
*/
|
|
32
|
+
function resolveOperationDef(operationArg) {
|
|
33
|
+
const dotIdx = operationArg.indexOf('.');
|
|
34
|
+
if (dotIdx === -1) {
|
|
35
|
+
// No domain separator — search all domains for unambiguous match
|
|
36
|
+
const matches = OPERATIONS.filter((op) => op.operation === operationArg);
|
|
37
|
+
if (matches.length === 1) {
|
|
38
|
+
return matches[0] ?? null;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const domain = operationArg.slice(0, dotIdx);
|
|
43
|
+
const operation = operationArg.slice(dotIdx + 1);
|
|
44
|
+
return OPERATIONS.find((op) => op.domain === domain && op.operation === operation) ?? null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Format an `OperationSchema` as a human-readable summary table.
|
|
48
|
+
*
|
|
49
|
+
* @param schema - The operation schema to render.
|
|
50
|
+
* @returns Multi-line human-readable string.
|
|
51
|
+
*/
|
|
52
|
+
function renderSchemaHuman(schema) {
|
|
53
|
+
const lines = [];
|
|
54
|
+
lines.push(`Operation : ${schema.operation}`);
|
|
55
|
+
lines.push(`Gateway : ${schema.gateway}`);
|
|
56
|
+
lines.push(`Description: ${schema.description}`);
|
|
57
|
+
lines.push('');
|
|
58
|
+
lines.push('Parameters:');
|
|
59
|
+
if (schema.params.length === 0) {
|
|
60
|
+
lines.push(' (none declared)');
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
for (const p of schema.params) {
|
|
64
|
+
const req = p.required ? '[required]' : '[optional]';
|
|
65
|
+
const enumStr = p.enum ? ` enum: ${p.enum.join(' | ')}` : '';
|
|
66
|
+
let cliStr = '';
|
|
67
|
+
if (p.cli) {
|
|
68
|
+
const parts = [];
|
|
69
|
+
if (p.cli.positional)
|
|
70
|
+
parts.push('positional');
|
|
71
|
+
if (p.cli.short)
|
|
72
|
+
parts.push(`short: ${p.cli.short}`);
|
|
73
|
+
if (p.cli.flag)
|
|
74
|
+
parts.push(`flag: --${p.cli.flag}`);
|
|
75
|
+
if (parts.length > 0)
|
|
76
|
+
cliStr = ` cli: ${parts.join(', ')}`;
|
|
77
|
+
}
|
|
78
|
+
lines.push(` ${p.name} (${p.type}) ${req}`);
|
|
79
|
+
lines.push(` ${p.description}${enumStr}${cliStr}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (schema.gates !== undefined) {
|
|
83
|
+
lines.push('');
|
|
84
|
+
lines.push('Gates:');
|
|
85
|
+
if (schema.gates.length === 0) {
|
|
86
|
+
lines.push(' (none declared — see note on static gate table)');
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
for (const g of schema.gates) {
|
|
90
|
+
lines.push(` ${g.name} → ${g.errorCode}`);
|
|
91
|
+
lines.push(` ${g.description}`);
|
|
92
|
+
for (const t of g.triggers) {
|
|
93
|
+
lines.push(` - ${t}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (schema.examples !== undefined && schema.examples.length > 0) {
|
|
99
|
+
lines.push('');
|
|
100
|
+
lines.push('Examples:');
|
|
101
|
+
for (const ex of schema.examples) {
|
|
102
|
+
lines.push(` ${ex.command}`);
|
|
103
|
+
lines.push(` ${ex.description}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return lines.join('\n');
|
|
107
|
+
}
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
// Command registration
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
/**
|
|
112
|
+
* Register the `cleo schema <operation>` command.
|
|
113
|
+
*
|
|
114
|
+
* @param program - The root ShimCommand to register against.
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* Does NOT dispatch through the main dispatcher — schema introspection is
|
|
118
|
+
* pure metadata over the registry and does not require a live session or DB.
|
|
119
|
+
*/
|
|
120
|
+
export function registerSchemaCommand(program) {
|
|
121
|
+
program
|
|
122
|
+
.command('schema <operation>')
|
|
123
|
+
.description('Introspect a CLEO operation: show params, types, enums, and declared gates')
|
|
124
|
+
.option('--format <format>', 'Output format: json (default) or human (pretty table)', 'json')
|
|
125
|
+
.option('--include-gates', 'Include precondition gates in output (default: true)')
|
|
126
|
+
.option('--no-include-gates', 'Exclude precondition gates from output')
|
|
127
|
+
.option('--include-examples', 'Include usage examples in output (default: false)')
|
|
128
|
+
.action(async (operationArg, opts) => {
|
|
129
|
+
const format = opts.format ?? 'json';
|
|
130
|
+
// When --no-include-gates is passed, Commander sets includeGates=false
|
|
131
|
+
const includeGates = opts.includeGates !== false;
|
|
132
|
+
const includeExamples = opts.includeExamples === true;
|
|
133
|
+
// Resolve operation from registry
|
|
134
|
+
const def = resolveOperationDef(operationArg);
|
|
135
|
+
if (def === null) {
|
|
136
|
+
cliError(`Unknown operation: "${operationArg}". Run \`cleo schema --list\` to see all operations.`, 4, {
|
|
137
|
+
name: 'E_NOT_FOUND',
|
|
138
|
+
fix: 'cleo schema --list',
|
|
139
|
+
});
|
|
140
|
+
process.exit(4);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
// Build schema via LAFS discovery
|
|
144
|
+
const schema = describeOperation(def, {
|
|
145
|
+
includeGates,
|
|
146
|
+
includeExamples,
|
|
147
|
+
});
|
|
148
|
+
if (format === 'human') {
|
|
149
|
+
console.log(renderSchemaHuman(schema));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// JSON output — go through cliOutput for LAFS envelope compliance
|
|
153
|
+
cliOutput(schema, {
|
|
154
|
+
command: 'schema',
|
|
155
|
+
operation: `schema.${operationArg}`,
|
|
156
|
+
message: `Schema for ${schema.operation}`,
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/cli/commands/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,iBAAiB,EAAwB,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE5D,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,SAAS,mBAAmB,CAAC,YAAoB;IAC/C,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;QAClB,iEAAiE;QACjE,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC;QACzE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QAC5B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEjD,OAAO,UAAU,CAAC,IAA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AAC,YAAY,CAAC,CAAC;QAE9C,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,QAAQ,CACN,uBAAuB,YAAY,sDAAsD,EACzF,CAAC,EACD;gBACE,IAAI,EAAE,aAAa;gBACnB,GAAG,EAAE,oBAAoB;aAC1B,CACF,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAChB,OAAO;QACT,CAAC;QAED,kCAAkC;QAClC,MAAM,MAAM,GAAoB,iBAAiB,CAAC,GAAG,EAAE;YACrD,YAAY;YACZ,eAAe;SAChB,CAAC,CAAC;QAEH,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;YACvC,OAAO;QACT,CAAC;QAED,kEAAkE;QAClE,SAAS,CAAC,MAAM,EAAE;YAChB,OAAO,EAAE,QAAQ;YACjB,SAAS,EAAE,UAAU,YAAY,EAAE;YACnC,OAAO,EAAE,cAAc,MAAM,CAAC,SAAS,EAAE;SAC1C,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/show.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/show.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,WAAW,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAmBnE;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAa1D"}
|
|
@@ -4,16 +4,36 @@
|
|
|
4
4
|
* @epic T4454
|
|
5
5
|
*/
|
|
6
6
|
import { dispatchFromCli } from '../../dispatch/adapters/cli.js';
|
|
7
|
+
import { applyParamDefsToCommand, buildOperationHelp } from '../help-generator.js';
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// ParamDef array for tasks.show
|
|
10
|
+
//
|
|
11
|
+
// Mirrors STATIC_PARAMS_TABLE in packages/lafs/src/operation-gates.ts.
|
|
12
|
+
// Will be upstreamed into registry.ts during the T4897 migration.
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
const SHOW_PARAMS = [
|
|
15
|
+
{
|
|
16
|
+
name: 'taskId',
|
|
17
|
+
type: 'string',
|
|
18
|
+
required: true,
|
|
19
|
+
description: 'ID of the task to retrieve',
|
|
20
|
+
cli: { positional: true },
|
|
21
|
+
},
|
|
22
|
+
];
|
|
7
23
|
/**
|
|
8
24
|
* Register the show command.
|
|
9
25
|
* @task T4460
|
|
10
26
|
* @task T4666
|
|
11
27
|
*/
|
|
12
28
|
export function registerShowCommand(program) {
|
|
13
|
-
program
|
|
14
|
-
.command('show
|
|
15
|
-
.description('Show full task details by ID')
|
|
16
|
-
|
|
29
|
+
const cmd = program
|
|
30
|
+
.command('show')
|
|
31
|
+
.description(buildOperationHelp('tasks.show', 'Show full task details by ID', SHOW_PARAMS));
|
|
32
|
+
// Auto-generate the <taskId> positional arg from the ParamDef registry.
|
|
33
|
+
// Replaces the previous hard-coded 'show <taskId>' in the command name string
|
|
34
|
+
// and surfaces the task-exists gate in --help output.
|
|
35
|
+
applyParamDefsToCommand(cmd, SHOW_PARAMS, 'tasks.show');
|
|
36
|
+
cmd.action(async (taskId) => {
|
|
17
37
|
await dispatchFromCli('query', 'tasks', 'show', { taskId }, { command: 'show' });
|
|
18
38
|
});
|
|
19
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show.js","sourceRoot":"","sources":["../../../src/cli/commands/show.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGjE;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;
|
|
1
|
+
{"version":3,"file":"show.js","sourceRoot":"","sources":["../../../src/cli/commands/show.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGjE,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,8EAA8E;AAC9E,gCAAgC;AAChC,EAAE;AACF,uEAAuE;AACvE,kEAAkE;AAClE,8EAA8E;AAC9E,MAAM,WAAW,GAAwB;IACvC;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,4BAA4B;QACzC,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;KAC1B;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,MAAM,GAAG,GAAG,OAAO;SAChB,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,kBAAkB,CAAC,YAAY,EAAE,8BAA8B,EAAE,WAAW,CAAC,CAAC,CAAC;IAE9F,wEAAwE;IACxE,8EAA8E;IAC9E,sDAAsD;IACtD,uBAAuB,CAAC,GAAG,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IAExD,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;QAClC,MAAM,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ParamDef-driven Commander help generator.
|
|
3
|
+
*
|
|
4
|
+
* Provides two functions:
|
|
5
|
+
* - `buildOperationHelp()` — emits a multi-section help string (Description,
|
|
6
|
+
* USAGE, ARGUMENTS, OPTIONS, PRECONDITIONS) from a ParamDef array and the
|
|
7
|
+
* static LAFS gate table.
|
|
8
|
+
* - `applyParamDefsToCommand()` — replaces hand-written `.option()` chains on
|
|
9
|
+
* a ShimCommand with generated calls derived from the same ParamDef array.
|
|
10
|
+
*
|
|
11
|
+
* Both functions read exactly the same source of truth that the dispatch
|
|
12
|
+
* registry and `cleo schema` use, eliminating the duplication that caused
|
|
13
|
+
* missing enum values, absent required indicators, and hidden gate docs.
|
|
14
|
+
*
|
|
15
|
+
* Gate lookup uses `describeOperation()` from `@cleocode/lafs`, which is the
|
|
16
|
+
* public API over the static LAFS gate table in `operation-gates.ts`.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
* @epic T335
|
|
20
|
+
* @task T339
|
|
21
|
+
*/
|
|
22
|
+
import type { ParamDef } from '../dispatch/types.js';
|
|
23
|
+
import type { ShimCommand } from './commander-shim.js';
|
|
24
|
+
/**
|
|
25
|
+
* Build a multi-section Commander-compatible help string from a ParamDef
|
|
26
|
+
* array and the static LAFS gate table.
|
|
27
|
+
*
|
|
28
|
+
* Sections emitted:
|
|
29
|
+
* - `Description:` — one-line operation summary
|
|
30
|
+
* - `USAGE:` — positional args listed in required/optional angle/square brackets
|
|
31
|
+
* - `ARGUMENTS:` — positional params with descriptions (omitted when none)
|
|
32
|
+
* - `OPTIONS:` — flag params with type, enum values, and required indicator
|
|
33
|
+
* - `PRECONDITIONS:` — gates sourced from `packages/lafs/src/operation-gates.ts`
|
|
34
|
+
* via `describeOperation()` (omitted when the gate table has no entry for
|
|
35
|
+
* this operation key)
|
|
36
|
+
* - `Examples:` — pre-canned examples for the five seeded operations
|
|
37
|
+
*
|
|
38
|
+
* @param operationKey - Fully-qualified operation key, e.g. `"tasks.add"`.
|
|
39
|
+
* @param description - One-line summary of the operation.
|
|
40
|
+
* @param params - ParamDef array for the operation.
|
|
41
|
+
* @returns Multi-line help string.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildOperationHelp(operationKey: string, description: string, params: readonly ParamDef[]): string;
|
|
44
|
+
/**
|
|
45
|
+
* Register Commander options and positional arguments on a ShimCommand from
|
|
46
|
+
* a ParamDef array.
|
|
47
|
+
*
|
|
48
|
+
* Replaces hand-written `.option(...)` chains with a single call.
|
|
49
|
+
*
|
|
50
|
+
* Handles:
|
|
51
|
+
* - Positional args (`cli.positional === true`) → `.argument()`
|
|
52
|
+
* - Short aliases (`cli.short`) → `-s, --flag <type>`
|
|
53
|
+
* - Flag name overrides (`cli.flag`) → `--custom-flag`
|
|
54
|
+
* - Boolean flags (type === `'boolean'`) → no value placeholder
|
|
55
|
+
* - Custom parse functions (`cli.parse`) → forwarded to `.option()`
|
|
56
|
+
* - Enum constraints surfaced in the option description
|
|
57
|
+
* - Required vs optional indicators appended to the description
|
|
58
|
+
*
|
|
59
|
+
* **Note:** The caller is still responsible for the `.action(...)` callback
|
|
60
|
+
* because action bodies are command-specific and cannot be auto-generated.
|
|
61
|
+
*
|
|
62
|
+
* **Hybrid pattern:** Some commands keep hand-written `.option()` calls after
|
|
63
|
+
* this call for options that have no ParamDef entry (e.g. `--dry-run`,
|
|
64
|
+
* `--field`, `--format`, `--desc`). That is intentional — those options are
|
|
65
|
+
* CLI-surface-only and do not belong in the dispatch registry.
|
|
66
|
+
*
|
|
67
|
+
* @param command - The ShimCommand returned by `.command(nameAndArgs)`.
|
|
68
|
+
* @param params - The ParamDef array for this operation.
|
|
69
|
+
* @param operationKey - `"tasks.add"` etc. Reserved for future hook or tracing
|
|
70
|
+
* use; currently not mutated on the shim since ShimCommand has no first-class
|
|
71
|
+
* help-text override API.
|
|
72
|
+
*/
|
|
73
|
+
export declare function applyParamDefsToCommand(command: ShimCommand, params: readonly ParamDef[], operationKey: string): void;
|
|
74
|
+
//# sourceMappingURL=help-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-generator.d.ts","sourceRoot":"","sources":["../../src/cli/help-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAsEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,SAAS,QAAQ,EAAE,GAC1B,MAAM,CAwFR;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,SAAS,QAAQ,EAAE,EAC3B,YAAY,EAAE,MAAM,GACnB,IAAI,CAmCN"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ParamDef-driven Commander help generator.
|
|
3
|
+
*
|
|
4
|
+
* Provides two functions:
|
|
5
|
+
* - `buildOperationHelp()` — emits a multi-section help string (Description,
|
|
6
|
+
* USAGE, ARGUMENTS, OPTIONS, PRECONDITIONS) from a ParamDef array and the
|
|
7
|
+
* static LAFS gate table.
|
|
8
|
+
* - `applyParamDefsToCommand()` — replaces hand-written `.option()` chains on
|
|
9
|
+
* a ShimCommand with generated calls derived from the same ParamDef array.
|
|
10
|
+
*
|
|
11
|
+
* Both functions read exactly the same source of truth that the dispatch
|
|
12
|
+
* registry and `cleo schema` use, eliminating the duplication that caused
|
|
13
|
+
* missing enum values, absent required indicators, and hidden gate docs.
|
|
14
|
+
*
|
|
15
|
+
* Gate lookup uses `describeOperation()` from `@cleocode/lafs`, which is the
|
|
16
|
+
* public API over the static LAFS gate table in `operation-gates.ts`.
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
* @epic T335
|
|
20
|
+
* @task T339
|
|
21
|
+
*/
|
|
22
|
+
import { describeOperation } from '@cleocode/lafs';
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Internal helpers
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
/**
|
|
27
|
+
* Convert a camelCase identifier to kebab-case CLI flag name.
|
|
28
|
+
*
|
|
29
|
+
* @param name - camelCase string (e.g. `"dryRun"`)
|
|
30
|
+
* @returns kebab-case string (e.g. `"dry-run"`)
|
|
31
|
+
*/
|
|
32
|
+
function toKebab(name) {
|
|
33
|
+
return name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Retrieve precondition gates for an operation key using the public
|
|
37
|
+
* `describeOperation()` API from `@cleocode/lafs`.
|
|
38
|
+
*
|
|
39
|
+
* Parses `"tasks.add"` → `{ domain: "tasks", operation: "add" }` and calls
|
|
40
|
+
* `describeOperation` with the minimum required fields so that the static
|
|
41
|
+
* LAFS gate table lookup succeeds.
|
|
42
|
+
*
|
|
43
|
+
* @param operationKey - Fully-qualified operation key, e.g. `"tasks.add"`.
|
|
44
|
+
* @param params - ParamDef array for the operation (may be empty).
|
|
45
|
+
* @returns Array of {@link OperationGateSchema} entries, possibly empty.
|
|
46
|
+
*/
|
|
47
|
+
function getGatesForOperation(operationKey, params) {
|
|
48
|
+
const dotIdx = operationKey.indexOf('.');
|
|
49
|
+
if (dotIdx === -1)
|
|
50
|
+
return [];
|
|
51
|
+
const domain = operationKey.slice(0, dotIdx);
|
|
52
|
+
const operation = operationKey.slice(dotIdx + 1);
|
|
53
|
+
const schema = describeOperation({
|
|
54
|
+
gateway: 'query',
|
|
55
|
+
domain,
|
|
56
|
+
operation,
|
|
57
|
+
description: '',
|
|
58
|
+
params: params,
|
|
59
|
+
requiredParams: [],
|
|
60
|
+
}, { includeGates: true });
|
|
61
|
+
return schema.gates ?? [];
|
|
62
|
+
}
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
// buildOperationHelp
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
/**
|
|
67
|
+
* Build a multi-section Commander-compatible help string from a ParamDef
|
|
68
|
+
* array and the static LAFS gate table.
|
|
69
|
+
*
|
|
70
|
+
* Sections emitted:
|
|
71
|
+
* - `Description:` — one-line operation summary
|
|
72
|
+
* - `USAGE:` — positional args listed in required/optional angle/square brackets
|
|
73
|
+
* - `ARGUMENTS:` — positional params with descriptions (omitted when none)
|
|
74
|
+
* - `OPTIONS:` — flag params with type, enum values, and required indicator
|
|
75
|
+
* - `PRECONDITIONS:` — gates sourced from `packages/lafs/src/operation-gates.ts`
|
|
76
|
+
* via `describeOperation()` (omitted when the gate table has no entry for
|
|
77
|
+
* this operation key)
|
|
78
|
+
* - `Examples:` — pre-canned examples for the five seeded operations
|
|
79
|
+
*
|
|
80
|
+
* @param operationKey - Fully-qualified operation key, e.g. `"tasks.add"`.
|
|
81
|
+
* @param description - One-line summary of the operation.
|
|
82
|
+
* @param params - ParamDef array for the operation.
|
|
83
|
+
* @returns Multi-line help string.
|
|
84
|
+
*/
|
|
85
|
+
export function buildOperationHelp(operationKey, description, params) {
|
|
86
|
+
// Derive the CLI noun from the operation key ("tasks.add" → "add")
|
|
87
|
+
const cliName = operationKey.split('.').slice(1).join('.');
|
|
88
|
+
const positionals = params.filter((p) => p.cli?.positional && !p.hidden);
|
|
89
|
+
const flags = params.filter((p) => !p.cli?.positional && !p.hidden);
|
|
90
|
+
// --- USAGE line ---
|
|
91
|
+
const argTokens = positionals.map((p) => (p.required ? `<${p.name}>` : `[${p.name}]`)).join(' ');
|
|
92
|
+
const usageLine = `USAGE: cleo ${cliName}` +
|
|
93
|
+
(flags.length > 0 ? ' [OPTIONS]' : '') +
|
|
94
|
+
(argTokens ? ` ${argTokens}` : '');
|
|
95
|
+
const lines = [];
|
|
96
|
+
lines.push(`Description: ${description}`);
|
|
97
|
+
lines.push('');
|
|
98
|
+
lines.push(usageLine);
|
|
99
|
+
// --- ARGUMENTS section ---
|
|
100
|
+
if (positionals.length > 0) {
|
|
101
|
+
lines.push('');
|
|
102
|
+
lines.push('ARGUMENTS:');
|
|
103
|
+
for (const p of positionals) {
|
|
104
|
+
const indicator = p.required ? '(required)' : '(optional)';
|
|
105
|
+
const namePad = p.name.padEnd(16);
|
|
106
|
+
lines.push(` ${namePad} ${p.description} ${indicator}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// --- OPTIONS section ---
|
|
110
|
+
if (flags.length > 0) {
|
|
111
|
+
lines.push('');
|
|
112
|
+
lines.push('OPTIONS:');
|
|
113
|
+
for (const p of flags) {
|
|
114
|
+
const flagName = p.cli?.flag ?? toKebab(p.name);
|
|
115
|
+
const short = p.cli?.short;
|
|
116
|
+
const typeLabel = p.type !== 'boolean' ? ` <${p.type}>` : '';
|
|
117
|
+
const flagStr = short
|
|
118
|
+
? `${short}, --${flagName}${typeLabel}`
|
|
119
|
+
: ` --${flagName}${typeLabel}`;
|
|
120
|
+
const enumSuffix = p.enum && p.enum.length > 0 ? ` [enum: ${p.enum.join('|')}]` : '';
|
|
121
|
+
const reqSuffix = p.required ? ' [required]' : '';
|
|
122
|
+
lines.push(` ${flagStr.padEnd(32)} ${p.description}${enumSuffix}${reqSuffix}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// --- PRECONDITIONS section ---
|
|
126
|
+
const gates = getGatesForOperation(operationKey, params);
|
|
127
|
+
if (gates.length > 0) {
|
|
128
|
+
lines.push('');
|
|
129
|
+
lines.push('PRECONDITIONS (gates that may fire):');
|
|
130
|
+
for (const gate of gates) {
|
|
131
|
+
lines.push(` - ${gate.errorCode} [${gate.name}]: ${gate.description}`);
|
|
132
|
+
for (const trigger of gate.triggers) {
|
|
133
|
+
lines.push(` * ${trigger}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// --- Examples section ---
|
|
138
|
+
const EXAMPLES = {
|
|
139
|
+
'tasks.add': [
|
|
140
|
+
" cleo add 'My task title'",
|
|
141
|
+
" cleo add 'My task' --priority high --parent T100",
|
|
142
|
+
" cleo add 'Fix login bug' --type bug --size small --acceptance 'Reproducer passes|CI green'",
|
|
143
|
+
],
|
|
144
|
+
'tasks.complete': [
|
|
145
|
+
' cleo complete T123',
|
|
146
|
+
' cleo complete T123 --force',
|
|
147
|
+
" cleo complete T123 --verification-note 'All ACs verified in PR #456'",
|
|
148
|
+
],
|
|
149
|
+
'tasks.show': [' cleo show T123'],
|
|
150
|
+
'tasks.find': [' cleo find "auth"', ' cleo find --status active --limit 10'],
|
|
151
|
+
'tasks.list': [' cleo list --parent T100', ' cleo list --status active --priority high'],
|
|
152
|
+
};
|
|
153
|
+
const examples = EXAMPLES[operationKey];
|
|
154
|
+
if (examples && examples.length > 0) {
|
|
155
|
+
lines.push('');
|
|
156
|
+
lines.push('Examples:');
|
|
157
|
+
for (const ex of examples) {
|
|
158
|
+
lines.push(ex);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return lines.join('\n');
|
|
162
|
+
}
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
// applyParamDefsToCommand
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
/**
|
|
167
|
+
* Register Commander options and positional arguments on a ShimCommand from
|
|
168
|
+
* a ParamDef array.
|
|
169
|
+
*
|
|
170
|
+
* Replaces hand-written `.option(...)` chains with a single call.
|
|
171
|
+
*
|
|
172
|
+
* Handles:
|
|
173
|
+
* - Positional args (`cli.positional === true`) → `.argument()`
|
|
174
|
+
* - Short aliases (`cli.short`) → `-s, --flag <type>`
|
|
175
|
+
* - Flag name overrides (`cli.flag`) → `--custom-flag`
|
|
176
|
+
* - Boolean flags (type === `'boolean'`) → no value placeholder
|
|
177
|
+
* - Custom parse functions (`cli.parse`) → forwarded to `.option()`
|
|
178
|
+
* - Enum constraints surfaced in the option description
|
|
179
|
+
* - Required vs optional indicators appended to the description
|
|
180
|
+
*
|
|
181
|
+
* **Note:** The caller is still responsible for the `.action(...)` callback
|
|
182
|
+
* because action bodies are command-specific and cannot be auto-generated.
|
|
183
|
+
*
|
|
184
|
+
* **Hybrid pattern:** Some commands keep hand-written `.option()` calls after
|
|
185
|
+
* this call for options that have no ParamDef entry (e.g. `--dry-run`,
|
|
186
|
+
* `--field`, `--format`, `--desc`). That is intentional — those options are
|
|
187
|
+
* CLI-surface-only and do not belong in the dispatch registry.
|
|
188
|
+
*
|
|
189
|
+
* @param command - The ShimCommand returned by `.command(nameAndArgs)`.
|
|
190
|
+
* @param params - The ParamDef array for this operation.
|
|
191
|
+
* @param operationKey - `"tasks.add"` etc. Reserved for future hook or tracing
|
|
192
|
+
* use; currently not mutated on the shim since ShimCommand has no first-class
|
|
193
|
+
* help-text override API.
|
|
194
|
+
*/
|
|
195
|
+
export function applyParamDefsToCommand(command, params, operationKey) {
|
|
196
|
+
// operationKey is reserved for future tracing/hook use.
|
|
197
|
+
void operationKey;
|
|
198
|
+
for (const p of params) {
|
|
199
|
+
// Hidden params have no CLI surface — skip entirely.
|
|
200
|
+
if (p.hidden)
|
|
201
|
+
continue;
|
|
202
|
+
if (p.cli?.positional) {
|
|
203
|
+
// Positional arguments are registered via .argument()
|
|
204
|
+
const spec = p.required ? `<${p.name}>` : `[${p.name}]`;
|
|
205
|
+
command.argument(spec, p.description);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
// Build the flag string
|
|
209
|
+
const flagName = p.cli?.flag ?? toKebab(p.name);
|
|
210
|
+
const short = p.cli?.short;
|
|
211
|
+
const typeLabel = p.type !== 'boolean' ? ` <${p.type}>` : '';
|
|
212
|
+
const flagPart = short ? `${short}, --${flagName}${typeLabel}` : `--${flagName}${typeLabel}`;
|
|
213
|
+
// Augment description with enum hint so agents see allowed values in --help
|
|
214
|
+
const enumHint = p.enum && p.enum.length > 0 ? ` (${p.enum.join('|')})` : '';
|
|
215
|
+
const reqHint = p.required ? ' [required]' : '';
|
|
216
|
+
const fullDescription = `${p.description}${enumHint}${reqHint}`;
|
|
217
|
+
if (p.required && p.type !== 'boolean') {
|
|
218
|
+
// Use requiredOption for non-boolean required flags
|
|
219
|
+
command.requiredOption(flagPart, fullDescription);
|
|
220
|
+
}
|
|
221
|
+
else if (p.cli?.parse) {
|
|
222
|
+
command.option(flagPart, fullDescription, p.cli.parse);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
command.option(flagPart, fullDescription);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=help-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-generator.js","sourceRoot":"","sources":["../../src/cli/help-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,iBAAiB,EAA4B,MAAM,gBAAgB,CAAC;AAI7E,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E;;;;;GAKG;AACH,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,oBAAoB,CAC3B,YAAoB,EACpB,MAA2B;IAE3B,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,MAAM,KAAK,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAE7B,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEjD,MAAM,MAAM,GAAG,iBAAiB,CAC9B;QACE,OAAO,EAAE,OAAO;QAChB,MAAM;QACN,SAAS;QACT,WAAW,EAAE,EAAE;QACf,MAAM,EAAE,MAaN;QACF,cAAc,EAAE,EAAE;KACnB,EACD,EAAE,YAAY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