@ekanos/cli 0.28.0 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/auth/ekanos-api.d.ts +8 -1
- package/dist/auth/ekanos-api.js +14 -2
- package/dist/auth/ekanos-api.js.map +1 -1
- package/dist/bin.js +4 -1
- package/dist/bin.js.map +1 -1
- package/dist/commands/feedback.d.ts +38 -0
- package/dist/commands/feedback.js +234 -0
- package/dist/commands/feedback.js.map +1 -0
- package/dist/commands/sources.js +4 -1
- package/dist/commands/sources.js.map +1 -1
- package/dist/context.d.ts +10 -0
- package/dist/context.js +10 -0
- package/dist/context.js.map +1 -1
- package/dist/feedback-api.d.ts +70 -0
- package/dist/feedback-api.js +111 -0
- package/dist/feedback-api.js.map +1 -0
- package/dist/feedback-context.d.ts +31 -0
- package/dist/feedback-context.js +209 -0
- package/dist/feedback-context.js.map +1 -0
- package/dist/feedback-updates.d.ts +16 -0
- package/dist/feedback-updates.js +174 -0
- package/dist/feedback-updates.js.map +1 -0
- package/dist/http-trace.d.ts +19 -0
- package/dist/http-trace.js +47 -0
- package/dist/http-trace.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +143 -10
- package/dist/index.js.map +1 -1
- package/dist/last-error.d.ts +17 -0
- package/dist/last-error.js +56 -0
- package/dist/last-error.js.map +1 -0
- package/package.json +2 -2
- package/templates/AGENTS.md.tmpl +19 -0
- package/templates/claude-skill.md.tmpl +18 -0
- package/templates/experience/package.json.tmpl +4 -4
- package/templates/package.json.tmpl +4 -4
- package/templates/skills/build-agent/SKILL.md +18 -0
- package/templates/skills/build-integration/SKILL.md +18 -0
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import { runApps } from './commands/apps.js';
|
|
|
18
18
|
import { runAudiences } from './commands/audiences.js';
|
|
19
19
|
import { runCatalog } from './commands/catalog.js';
|
|
20
20
|
import { runDev } from './commands/dev.js';
|
|
21
|
+
import { runFeedback } from './commands/feedback.js';
|
|
21
22
|
import { EXPERIENCE_COMMANDS } from './commands/index-experience.js';
|
|
22
23
|
import { runInit } from './commands/init.js';
|
|
23
24
|
import { runKnowledge } from './commands/knowledge.js';
|
|
@@ -39,10 +40,15 @@ import { runUse } from './commands/use.js';
|
|
|
39
40
|
import { runValidate } from './commands/validate.js';
|
|
40
41
|
import { runWhoami } from './commands/whoami.js';
|
|
41
42
|
import { runWorkflows } from './commands/workflows.js';
|
|
43
|
+
import { cliVersion } from './compatibility.js';
|
|
42
44
|
import { CliContext } from './context.js';
|
|
43
45
|
import { SDK_DOCS_URL, docsPage } from './docs-links.js';
|
|
44
46
|
import { preconditionError, toCliError, usageError } from './errors.js';
|
|
45
|
-
import {
|
|
47
|
+
import { commandPathOf, flagNamesOf } from './feedback-context.js';
|
|
48
|
+
import { startFeedbackUpdatesCheck, } from './feedback-updates.js';
|
|
49
|
+
import { lastHttpResponse, resetHttpTrace } from './http-trace.js';
|
|
50
|
+
import { cli, detectInvocation, setInvocation, } from './invocation.js';
|
|
51
|
+
import { writeLastError } from './last-error.js';
|
|
46
52
|
import { parseArgv } from './parse-argv.js';
|
|
47
53
|
import { unknownCommand } from './unknown-command.js';
|
|
48
54
|
export { CliContext } from './context.js';
|
|
@@ -772,6 +778,23 @@ const COMMAND_SPECS = {
|
|
|
772
778
|
description: 'With --wait: give up after this many minutes (default 30; exit 11)',
|
|
773
779
|
},
|
|
774
780
|
},
|
|
781
|
+
feedback: {
|
|
782
|
+
host: HOST,
|
|
783
|
+
source: SOURCE,
|
|
784
|
+
dir: DIR,
|
|
785
|
+
kind: {
|
|
786
|
+
type: 'string',
|
|
787
|
+
description: 'bug|confusing|missing|other (default: bug with --last-error, else other)',
|
|
788
|
+
},
|
|
789
|
+
'last-error': {
|
|
790
|
+
type: 'boolean',
|
|
791
|
+
description: "Attach the last failed command's context: its path, flag names, codes, the host's status and request id",
|
|
792
|
+
},
|
|
793
|
+
command: {
|
|
794
|
+
type: 'string',
|
|
795
|
+
description: 'The ekanos command it is about; only its path and flag names are sent, never values',
|
|
796
|
+
},
|
|
797
|
+
},
|
|
775
798
|
upgrade: {
|
|
776
799
|
dir: DIR,
|
|
777
800
|
host: HOST,
|
|
@@ -822,6 +845,8 @@ const POSITIONAL_COMMANDS = {
|
|
|
822
845
|
workflows: ['subcommand', 'workflow-or-verb', 'id'],
|
|
823
846
|
// `triggers <key> add event <trigger-key>` is the longest form: five tokens.
|
|
824
847
|
agents: ['subcommand', 'key-or-path', 'action', 'arg', 'value'],
|
|
848
|
+
// `feedback "<message>"`, or `feedback list`.
|
|
849
|
+
feedback: ['message'],
|
|
825
850
|
};
|
|
826
851
|
for (const command of EXPERIENCE_COMMANDS) {
|
|
827
852
|
COMMAND_SPECS[command.name] = command.specs;
|
|
@@ -883,7 +908,10 @@ const USAGE = [
|
|
|
883
908
|
' roles delete <role> [--yes] (owner, admin and member are system',
|
|
884
909
|
" roles: never changed or deleted; a held role isn't deleted) |",
|
|
885
910
|
' people [--search <text>] [--page <n>] (everyone with access, one',
|
|
886
|
-
' row per person, with their teams and role on each)',
|
|
911
|
+
' row per person, with their teams and role on each) |',
|
|
912
|
+
' feedback [status|enable|disable] (whether "ekanos feedback"',
|
|
913
|
+
' reports reach Vastly from this Source; on unless its Source',
|
|
914
|
+
' admin turns it off; each change is in the Admin Audit log)',
|
|
887
915
|
" audiences A source's audiences, for its Source admin (they replace product",
|
|
888
916
|
' scopes): list | show <audience> | create <name> [--products a,b |',
|
|
889
917
|
' --all-entitled] [--description <text>] [--default] [--widgets',
|
|
@@ -1134,6 +1162,14 @@ const USAGE = [
|
|
|
1134
1162
|
' first, each package gated, artifacts under .ekanos/publish/)',
|
|
1135
1163
|
' upgrade Move this toolchain to a coherent target version, with',
|
|
1136
1164
|
' verify-and-rollback (--check --yes --no-verify --host <url>)',
|
|
1165
|
+
' feedback Report a problem to Vastly: "<what you tried, what happened,',
|
|
1166
|
+
' what you expected>" (or piped on stdin) [--kind',
|
|
1167
|
+
' bug|confusing|missing|other] [--last-error] (attach the last',
|
|
1168
|
+
" failed command: its path, flag names, codes, the host's status",
|
|
1169
|
+
' and request id) [--command "<the ekanos command>"] [--source',
|
|
1170
|
+
' <slug>] | list (your own reports, and any fix that shipped).',
|
|
1171
|
+
' Never sends argument or flag values, files or the environment;',
|
|
1172
|
+
' the message is redacted first. Nothing is ever sent on its own.',
|
|
1137
1173
|
'',
|
|
1138
1174
|
'Keeping the toolchain current:',
|
|
1139
1175
|
' validate, dev and publish all check for a newer @ekanos/cli in the',
|
|
@@ -1144,7 +1180,7 @@ const USAGE = [
|
|
|
1144
1180
|
' bare "ekanos upgrade" MUTATES the project (installs the target versions,',
|
|
1145
1181
|
' verifies with validate + the test script, rolls back on any failure).',
|
|
1146
1182
|
'',
|
|
1147
|
-
'Host resolution (logout, whoami, status, sources, catalog, apps, teams, names, reviewers, routes, agents, skills, knowledge, runs, approvals, workflows, use, publish, upgrade):',
|
|
1183
|
+
'Host resolution (logout, whoami, status, sources, catalog, apps, teams, names, reviewers, routes, agents, skills, knowledge, runs, approvals, workflows, use, publish, upgrade, feedback):',
|
|
1148
1184
|
' --host, else EKANOS_HOST, else the "host" field in ekanos.json, else the',
|
|
1149
1185
|
' sole stored login. "ekanos publish" saves host and source to ekanos.json.',
|
|
1150
1186
|
' "ekanos login" never reads ekanos.json for a host (--host, else',
|
|
@@ -1166,6 +1202,23 @@ const USAGE = [
|
|
|
1166
1202
|
' --version Print the CLI version',
|
|
1167
1203
|
' --help Show this help',
|
|
1168
1204
|
].join('\n');
|
|
1205
|
+
/** Commands whose failures are the partner's own code, not the CLI's. */
|
|
1206
|
+
const NOT_REPORTED_CODES = new Set(['validation', 'gate_failed']);
|
|
1207
|
+
/**
|
|
1208
|
+
* The commands after which a fix update may be shown: the ones that reach
|
|
1209
|
+
* the host with a session. Never the auth verbs, which change the session
|
|
1210
|
+
* the check would use.
|
|
1211
|
+
*/
|
|
1212
|
+
const NO_UPDATE_CHECK_COMMANDS = new Set([
|
|
1213
|
+
'init',
|
|
1214
|
+
'validate',
|
|
1215
|
+
'dev',
|
|
1216
|
+
'test',
|
|
1217
|
+
'login',
|
|
1218
|
+
'logout',
|
|
1219
|
+
'upgrade',
|
|
1220
|
+
]);
|
|
1221
|
+
const REPORT_HINT = () => `${cli()} feedback --last-error "<what you were trying to do>"`;
|
|
1169
1222
|
/**
|
|
1170
1223
|
* The single entry point. Resolves the agent-native envelope once, dispatches
|
|
1171
1224
|
* to a verb, and guarantees exactly one terminal emission (success or error).
|
|
@@ -1173,17 +1226,76 @@ const USAGE = [
|
|
|
1173
1226
|
* `process.exit`, so this stays fully testable.
|
|
1174
1227
|
*/
|
|
1175
1228
|
export async function run(argv, options = {}) {
|
|
1176
|
-
var _a
|
|
1229
|
+
var _a;
|
|
1230
|
+
var _b, _c, _d, _e;
|
|
1177
1231
|
const jsonFlag = scanJsonFlag(argv);
|
|
1178
|
-
setInvocation((
|
|
1232
|
+
setInvocation((_b = options.invocation) !== null && _b !== void 0 ? _b : detectInvocation((_c = options.env) !== null && _c !== void 0 ? _c : process.env), COMMANDS);
|
|
1179
1233
|
const ctx = new CliContext({
|
|
1180
1234
|
jsonFlag,
|
|
1181
1235
|
stdout: options.stdout,
|
|
1182
1236
|
stderr: options.stderr,
|
|
1183
1237
|
env: options.env,
|
|
1184
1238
|
});
|
|
1185
|
-
const cwd = (
|
|
1186
|
-
const env = (
|
|
1239
|
+
const cwd = (_d = options.cwd) !== null && _d !== void 0 ? _d : process.cwd();
|
|
1240
|
+
const env = (_e = options.env) !== null && _e !== void 0 ? _e : process.env;
|
|
1241
|
+
resetHttpTrace();
|
|
1242
|
+
const trace = {
|
|
1243
|
+
command: null,
|
|
1244
|
+
positionals: [],
|
|
1245
|
+
reportHinted: false,
|
|
1246
|
+
updates: null,
|
|
1247
|
+
};
|
|
1248
|
+
const exitCode = await dispatch(argv, options, ctx, cwd, env, trace);
|
|
1249
|
+
if (exitCode !== 0 && trace.command !== 'feedback') {
|
|
1250
|
+
afterFailure(argv, options, ctx, env, trace, exitCode);
|
|
1251
|
+
}
|
|
1252
|
+
try {
|
|
1253
|
+
(_a = trace.updates) === null || _a === void 0 ? void 0 : _a.finish(ctx);
|
|
1254
|
+
}
|
|
1255
|
+
catch (_f) {
|
|
1256
|
+
// A courtesy: it never changes how a run ends.
|
|
1257
|
+
}
|
|
1258
|
+
return exitCode;
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* A command failed: tell an agent how to report it (the `claude-code-hint`
|
|
1262
|
+
* line, written only to agents and with `--json`, as every hint is), and
|
|
1263
|
+
* remember the failure for `ekanos feedback --last-error`. Neither sends
|
|
1264
|
+
* anything anywhere.
|
|
1265
|
+
*/
|
|
1266
|
+
function afterFailure(argv, options, ctx, env, trace, exitCode) {
|
|
1267
|
+
var _a;
|
|
1268
|
+
var _b, _c, _d, _e;
|
|
1269
|
+
const code = (_b = (_a = ctx.failure) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : null;
|
|
1270
|
+
if (!trace.reportHinted &&
|
|
1271
|
+
trace.command !== 'test' &&
|
|
1272
|
+
!(code && NOT_REPORTED_CODES.has(code))) {
|
|
1273
|
+
ctx.emitClaudeCodeHint({
|
|
1274
|
+
tool: 'ekanos',
|
|
1275
|
+
error: code !== null && code !== void 0 ? code : 'failed',
|
|
1276
|
+
exitCode,
|
|
1277
|
+
report: REPORT_HINT(),
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
if (!options.recordLastError)
|
|
1281
|
+
return;
|
|
1282
|
+
const http = lastHttpResponse();
|
|
1283
|
+
writeLastError(env, {
|
|
1284
|
+
failedAt: new Date().toISOString(),
|
|
1285
|
+
cliVersion: cliVersion(),
|
|
1286
|
+
host: (_c = http === null || http === void 0 ? void 0 : http.origin) !== null && _c !== void 0 ? _c : null,
|
|
1287
|
+
command: trace.command
|
|
1288
|
+
? commandPathOf([trace.command, ...trace.positionals])
|
|
1289
|
+
: null,
|
|
1290
|
+
flags: flagNamesOf(argv),
|
|
1291
|
+
errorCode: code && /^[a-z_]{1,40}$/.test(code) ? code : null,
|
|
1292
|
+
exitCode: Math.max(0, Math.min(255, exitCode)),
|
|
1293
|
+
httpStatus: (_d = http === null || http === void 0 ? void 0 : http.status) !== null && _d !== void 0 ? _d : null,
|
|
1294
|
+
requestId: (_e = http === null || http === void 0 ? void 0 : http.requestId) !== null && _e !== void 0 ? _e : null,
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
async function dispatch(argv, options, ctx, cwd, env, trace) {
|
|
1298
|
+
var _a, _b;
|
|
1187
1299
|
try {
|
|
1188
1300
|
// `--version` is global and verb-independent, so it is answered before the
|
|
1189
1301
|
// command is even resolved: `ekanos --version` and `ekanos validate
|
|
@@ -1203,20 +1315,28 @@ export async function run(argv, options = {}) {
|
|
|
1203
1315
|
error: 'unknown-command',
|
|
1204
1316
|
commands: COMMANDS,
|
|
1205
1317
|
help: 'ekanos --help',
|
|
1318
|
+
report: REPORT_HINT(),
|
|
1206
1319
|
});
|
|
1320
|
+
trace.reportHinted = true;
|
|
1207
1321
|
throw usageError(`Unknown command or flag "${argv[0]}".`, `Run one of: ${COMMANDS.join(', ')}. See "ekanos --help".`);
|
|
1208
1322
|
}
|
|
1209
1323
|
if (!COMMANDS.includes(command)) {
|
|
1210
1324
|
const unknown = unknownCommand(command, rest, COMMANDS);
|
|
1211
|
-
ctx.emitClaudeCodeHint(Object.assign(Object.assign({ tool: 'ekanos', error: 'unknown-command', given: command }, (unknown.suggestion ? { suggestion: unknown.suggestion } : {})), { commands: COMMANDS, help: 'ekanos --help' }));
|
|
1325
|
+
ctx.emitClaudeCodeHint(Object.assign(Object.assign({ tool: 'ekanos', error: 'unknown-command', given: command }, (unknown.suggestion ? { suggestion: unknown.suggestion } : {})), { commands: COMMANDS, help: 'ekanos --help', report: REPORT_HINT() }));
|
|
1326
|
+
trace.reportHinted = true;
|
|
1212
1327
|
throw unknown.error;
|
|
1213
1328
|
}
|
|
1329
|
+
trace.command = command;
|
|
1214
1330
|
const specs = Object.assign(Object.assign({}, GLOBAL_SPECS), COMMAND_SPECS[command]);
|
|
1215
1331
|
const parsed = parseArgv(rest, specs);
|
|
1332
|
+
trace.positionals = parsed.positionals;
|
|
1216
1333
|
if (parsed.flags.help === true) {
|
|
1217
1334
|
return emitCommandHelp(ctx, command);
|
|
1218
1335
|
}
|
|
1219
|
-
|
|
1336
|
+
if (options.feedbackUpdates && !NO_UPDATE_CHECK_COMMANDS.has(command)) {
|
|
1337
|
+
trace.updates = startFeedbackUpdatesCheck({ env });
|
|
1338
|
+
}
|
|
1339
|
+
const positionalNames = (_a = POSITIONAL_COMMANDS[command]) !== null && _a !== void 0 ? _a : [];
|
|
1220
1340
|
if (positionalNames.length === 0 && parsed.positionals.length > 0) {
|
|
1221
1341
|
throw usageError(`"${command}" takes no positional arguments (got "${parsed.positionals[0]}").`, `Pass options as flags, e.g. "--dir <path>". See "ekanos ${command} --help".`);
|
|
1222
1342
|
}
|
|
@@ -1227,7 +1347,7 @@ export async function run(argv, options = {}) {
|
|
|
1227
1347
|
`argument${positionalNames.length === 1 ? '' : 's'} (${usage}), ` +
|
|
1228
1348
|
`got ${parsed.positionals.length}.`, `e.g. "ekanos ${command} ${usage}". See "ekanos ${command} --help".`);
|
|
1229
1349
|
}
|
|
1230
|
-
const dir = (
|
|
1350
|
+
const dir = (_b = parsed.flags.dir) !== null && _b !== void 0 ? _b : cwd;
|
|
1231
1351
|
if (REPO_ROOT_REFUSED.has(command) && isRepoRoot(path.resolve(dir))) {
|
|
1232
1352
|
throw preconditionError(`"${command}" works on one package, and ${dir} is a repo root.`, `Run it inside a package (cd integrations/<slug> or cd experiences/<slug>), or use "ekanos publish --all" for the whole repo.`);
|
|
1233
1353
|
}
|
|
@@ -1539,6 +1659,19 @@ export async function run(argv, options = {}) {
|
|
|
1539
1659
|
stdinIsTTY: options.stdinIsTTY,
|
|
1540
1660
|
confirm: options.confirm,
|
|
1541
1661
|
});
|
|
1662
|
+
case 'feedback':
|
|
1663
|
+
return await runFeedback(ctx, {
|
|
1664
|
+
host: parsed.flags.host,
|
|
1665
|
+
source: parsed.flags.source,
|
|
1666
|
+
positionals: parsed.positionals,
|
|
1667
|
+
kind: parsed.flags.kind,
|
|
1668
|
+
lastError: parsed.flags['last-error'] === true,
|
|
1669
|
+
command: parsed.flags.command,
|
|
1670
|
+
dir,
|
|
1671
|
+
env,
|
|
1672
|
+
stdinIsTTY: options.stdinIsTTY,
|
|
1673
|
+
readStdin: options.readStdin,
|
|
1674
|
+
});
|
|
1542
1675
|
case 'upgrade':
|
|
1543
1676
|
return await runUpgrade(ctx, {
|
|
1544
1677
|
dir,
|