@ekanos/cli 0.28.1 → 0.30.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 +14 -5
- 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 +9 -1
- package/dist/bin.js.map +1 -1
- package/dist/commands/dev.js +5 -5
- package/dist/commands/dev.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/publish.js +1 -1
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/sources.js +4 -1
- package/dist/commands/sources.js.map +1 -1
- package/dist/commands/status.js +1 -1
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/validate.js +2 -2
- package/dist/commands/validate.js.map +1 -1
- package/dist/context.d.ts +11 -1
- package/dist/context.js +12 -1
- 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 +18 -0
- package/dist/index.js +172 -13
- 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/dist/toolchain-api.d.ts +2 -1
- package/dist/toolchain-api.js +2 -2
- package/dist/toolchain-api.js.map +1 -1
- package/dist/toolchain-resolve.d.ts +4 -0
- package/dist/toolchain-resolve.js +11 -7
- package/dist/toolchain-resolve.js.map +1 -1
- package/dist/update-notice.d.ts +31 -8
- package/dist/update-notice.js +161 -31
- package/dist/update-notice.js.map +1 -1
- 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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { CliContext } from '../context.js';
|
|
2
|
+
import type { ExitCode } from '../exit-codes.js';
|
|
3
|
+
export interface FeedbackArgs {
|
|
4
|
+
host?: string;
|
|
5
|
+
source?: string;
|
|
6
|
+
/** `[<message>]`, or `list`. */
|
|
7
|
+
positionals: readonly string[];
|
|
8
|
+
kind?: string;
|
|
9
|
+
lastError: boolean;
|
|
10
|
+
command?: string;
|
|
11
|
+
dir: string;
|
|
12
|
+
env: Record<string, string | undefined>;
|
|
13
|
+
stdinIsTTY?: boolean;
|
|
14
|
+
readStdin?: () => Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `feedback` — tell Vastly about a problem with the CLI or the platform:
|
|
18
|
+
* a command that failed unexpectedly, a confusing message, something
|
|
19
|
+
* missing. Nothing is ever sent on its own; a report is this command, run
|
|
20
|
+
* by a person or their agent. The message is redacted before it leaves
|
|
21
|
+
* this machine (and again on the host), and what is attached about the
|
|
22
|
+
* command is its path and flag NAMES, codes and versions: never an
|
|
23
|
+
* argument, a value, a file or the environment.
|
|
24
|
+
*
|
|
25
|
+
* `feedback list` shows your own reports, with any fix that has shipped.
|
|
26
|
+
*/
|
|
27
|
+
export declare function runFeedback(ctx: CliContext, args: FeedbackArgs): Promise<ExitCode>;
|
|
28
|
+
/**
|
|
29
|
+
* `sources feedback [status|enable|disable]` — whether this Source takes
|
|
30
|
+
* reports from `ekanos feedback`. On unless its Source admin turns it off;
|
|
31
|
+
* every change is recorded in the Admin Audit log.
|
|
32
|
+
*/
|
|
33
|
+
export declare function runSourceFeedback(ctx: CliContext, args: {
|
|
34
|
+
host?: string;
|
|
35
|
+
source?: string;
|
|
36
|
+
dir: string;
|
|
37
|
+
env: Record<string, string | undefined>;
|
|
38
|
+
}, rest: readonly string[]): Promise<ExitCode>;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { FEEDBACK_KINDS, FEEDBACK_MESSAGE_MAX_LENGTH, redactFeedbackText, } from '@ekanos/integration-schema';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import { loginHint } from '../auth/host-trust.js';
|
|
4
|
+
import { refreshStoredSession, requireSession, resolveAuthEnvironment, } from '../auth/session.js';
|
|
5
|
+
import { cliVersion } from '../compatibility.js';
|
|
6
|
+
import { authRequiredError, preconditionError, usageError } from '../errors.js';
|
|
7
|
+
import { listOwnFeedback, sourceFeedbackSetting, submitFeedback, } from '../feedback-api.js';
|
|
8
|
+
import { baseFeedbackContext, describeCommandLine } from '../feedback-context.js';
|
|
9
|
+
import { readLastError } from '../last-error.js';
|
|
10
|
+
import { resolveSourceTarget } from '../source-target.js';
|
|
11
|
+
import { shortHost } from '../ui.js';
|
|
12
|
+
const USAGE = 'Run "ekanos feedback \\"<what you tried, what happened, what you expected>\\" [--kind bug|confusing|missing|other] [--last-error] [--command \\"<the ekanos command>\\"]", or "ekanos feedback list".';
|
|
13
|
+
/**
|
|
14
|
+
* `feedback` — tell Vastly about a problem with the CLI or the platform:
|
|
15
|
+
* a command that failed unexpectedly, a confusing message, something
|
|
16
|
+
* missing. Nothing is ever sent on its own; a report is this command, run
|
|
17
|
+
* by a person or their agent. The message is redacted before it leaves
|
|
18
|
+
* this machine (and again on the host), and what is attached about the
|
|
19
|
+
* command is its path and flag NAMES, codes and versions: never an
|
|
20
|
+
* argument, a value, a file or the environment.
|
|
21
|
+
*
|
|
22
|
+
* `feedback list` shows your own reports, with any fix that has shipped.
|
|
23
|
+
*/
|
|
24
|
+
export async function runFeedback(ctx, args) {
|
|
25
|
+
var _a;
|
|
26
|
+
if (args.positionals[0] === 'list' && args.positionals.length === 1) {
|
|
27
|
+
if (args.lastError || args.kind || args.command) {
|
|
28
|
+
throw usageError('"feedback list" takes no report flags.', USAGE);
|
|
29
|
+
}
|
|
30
|
+
return runFeedbackList(ctx, args);
|
|
31
|
+
}
|
|
32
|
+
const kind = feedbackKind(args.kind, args.lastError);
|
|
33
|
+
const typed = ((_a = args.positionals[0]) === null || _a === void 0 ? void 0 : _a.trim()) || (await readPipedMessage(args));
|
|
34
|
+
if (!typed && !args.lastError) {
|
|
35
|
+
throw usageError('Say what happened: a message, or --last-error.', USAGE);
|
|
36
|
+
}
|
|
37
|
+
let context = baseFeedbackContext({
|
|
38
|
+
cliVersion: cliVersion(),
|
|
39
|
+
env: args.env,
|
|
40
|
+
});
|
|
41
|
+
if (args.lastError) {
|
|
42
|
+
const last = readLastError(args.env);
|
|
43
|
+
if (!last) {
|
|
44
|
+
throw preconditionError('No failed command is recorded on this machine.', 'Run the command that failed again, then "ekanos feedback --last-error \\"<what you were trying to do>\\"" — or describe it: "ekanos feedback \\"<what happened>\\" --command \\"<the command>\\"".');
|
|
45
|
+
}
|
|
46
|
+
context = Object.assign(Object.assign({}, context), { command: last.command, flags: last.flags, errorCode: last.errorCode, exitCode: last.exitCode, httpStatus: last.httpStatus, requestId: last.requestId, failedAt: last.failedAt });
|
|
47
|
+
}
|
|
48
|
+
if (args.command !== undefined) {
|
|
49
|
+
const described = describeCommandLine(args.command);
|
|
50
|
+
if (!described.command) {
|
|
51
|
+
throw usageError(`"${args.command.slice(0, 60)}" names no ekanos command.`, 'Pass the command it concerns, e.g. --command "ekanos teams connect".');
|
|
52
|
+
}
|
|
53
|
+
context = Object.assign(Object.assign({}, context), described);
|
|
54
|
+
}
|
|
55
|
+
const raw = typed ||
|
|
56
|
+
'Filed with --last-error; the reporter gave no description of what they were doing.';
|
|
57
|
+
const redactedText = redactFeedbackText(raw);
|
|
58
|
+
const truncated = redactedText.length > FEEDBACK_MESSAGE_MAX_LENGTH;
|
|
59
|
+
const message = redactedText.slice(0, FEEDBACK_MESSAGE_MAX_LENGTH);
|
|
60
|
+
const env = resolveAuthEnvironment(ctx, args.host, args.env, {
|
|
61
|
+
projectDir: args.dir,
|
|
62
|
+
});
|
|
63
|
+
const resolved = await resolveSourceTarget(env, requireSession(env), {
|
|
64
|
+
source: args.source,
|
|
65
|
+
dir: args.dir,
|
|
66
|
+
});
|
|
67
|
+
const client = new FeedbackClient(env, resolved.session);
|
|
68
|
+
const filed = await client.call((token) => submitFeedback(env.host, token, resolved.source, {
|
|
69
|
+
message,
|
|
70
|
+
kind,
|
|
71
|
+
context,
|
|
72
|
+
}));
|
|
73
|
+
return ctx.succeed({
|
|
74
|
+
host: env.host,
|
|
75
|
+
source: resolved.source,
|
|
76
|
+
id: filed.id,
|
|
77
|
+
number: filed.number,
|
|
78
|
+
kind,
|
|
79
|
+
redacted: redactedText !== raw,
|
|
80
|
+
truncated,
|
|
81
|
+
context,
|
|
82
|
+
}, ctx.ui.result({
|
|
83
|
+
title: `Filed feedback #${filed.number}`,
|
|
84
|
+
rows: [
|
|
85
|
+
['Id', filed.id],
|
|
86
|
+
['Kind', kind],
|
|
87
|
+
['Host', shortHost(env.host)],
|
|
88
|
+
...(context.command
|
|
89
|
+
? [['About', `ekanos ${context.command}`]]
|
|
90
|
+
: []),
|
|
91
|
+
],
|
|
92
|
+
notes: [
|
|
93
|
+
...(redactedText !== raw
|
|
94
|
+
? [
|
|
95
|
+
'Something that looked like a secret or an email was replaced with [redacted] before it was sent.',
|
|
96
|
+
]
|
|
97
|
+
: []),
|
|
98
|
+
...(truncated
|
|
99
|
+
? [
|
|
100
|
+
`The message was cut to ${FEEDBACK_MESSAGE_MAX_LENGTH} characters.`,
|
|
101
|
+
]
|
|
102
|
+
: []),
|
|
103
|
+
'When a fix ships, a later command tells you; "ekanos feedback list" shows your reports.',
|
|
104
|
+
],
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
async function runFeedbackList(ctx, args) {
|
|
108
|
+
const env = resolveAuthEnvironment(ctx, args.host, args.env, {
|
|
109
|
+
projectDir: args.dir,
|
|
110
|
+
});
|
|
111
|
+
const client = new FeedbackClient(env, requireSession(env));
|
|
112
|
+
const list = await client.call((token) => listOwnFeedback(env.host, token));
|
|
113
|
+
return ctx.succeed(Object.assign({ host: env.host }, list), ctx.ui.result({
|
|
114
|
+
title: list.reports.length === 0
|
|
115
|
+
? 'You have filed no feedback'
|
|
116
|
+
: `Your feedback on ${shortHost(env.host)}`,
|
|
117
|
+
rows: list.reports.map((report) => [
|
|
118
|
+
`#${report.number}`,
|
|
119
|
+
[
|
|
120
|
+
`${report.kind} · ${statusLabel(report)} · ${report.createdAt.slice(0, 10)}`,
|
|
121
|
+
report.excerpt,
|
|
122
|
+
...(report.note ? [`Note: ${report.note}`] : []),
|
|
123
|
+
],
|
|
124
|
+
]),
|
|
125
|
+
notes: list.reports.length === 0
|
|
126
|
+
? ['"ekanos feedback \\"<what happened>\\"" files one.']
|
|
127
|
+
: [],
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
function statusLabel(report) {
|
|
131
|
+
var _a, _b;
|
|
132
|
+
if (((_a = report.fix) === null || _a === void 0 ? void 0 : _a.kind) === 'cli') {
|
|
133
|
+
return `fixed in @ekanos/cli ${report.fix.version}`;
|
|
134
|
+
}
|
|
135
|
+
if (((_b = report.fix) === null || _b === void 0 ? void 0 : _b.kind) === 'host')
|
|
136
|
+
return 'fixed on the host';
|
|
137
|
+
return report.status.replace('_', ' ');
|
|
138
|
+
}
|
|
139
|
+
function feedbackKind(value, lastError) {
|
|
140
|
+
if (value === undefined)
|
|
141
|
+
return lastError ? 'bug' : 'other';
|
|
142
|
+
const kind = FEEDBACK_KINDS.find((entry) => entry === value.trim());
|
|
143
|
+
if (kind)
|
|
144
|
+
return kind;
|
|
145
|
+
throw usageError(`"${value}" is not a kind of feedback.`, `Pass --kind ${FEEDBACK_KINDS.join('|')}.`);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The message from stdin, when something is piped in. A terminal, or a
|
|
149
|
+
* stdin that is neither a pipe nor a file (an agent's empty one), is never
|
|
150
|
+
* waited on.
|
|
151
|
+
*/
|
|
152
|
+
async function readPipedMessage(args) {
|
|
153
|
+
var _a;
|
|
154
|
+
if (args.readStdin) {
|
|
155
|
+
return args.stdinIsTTY ? '' : (await args.readStdin()).trim();
|
|
156
|
+
}
|
|
157
|
+
if ((_a = args.stdinIsTTY) !== null && _a !== void 0 ? _a : process.stdin.isTTY)
|
|
158
|
+
return '';
|
|
159
|
+
try {
|
|
160
|
+
const stat = fs.fstatSync(0);
|
|
161
|
+
if (!stat.isFIFO() && !stat.isFile())
|
|
162
|
+
return '';
|
|
163
|
+
// Read a byte past the cap, so an over-long message is cut, not refused.
|
|
164
|
+
return fs
|
|
165
|
+
.readFileSync(0, 'utf8')
|
|
166
|
+
.slice(0, FEEDBACK_MESSAGE_MAX_LENGTH * 4)
|
|
167
|
+
.trim();
|
|
168
|
+
}
|
|
169
|
+
catch (_b) {
|
|
170
|
+
return '';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* `sources feedback [status|enable|disable]` — whether this Source takes
|
|
175
|
+
* reports from `ekanos feedback`. On unless its Source admin turns it off;
|
|
176
|
+
* every change is recorded in the Admin Audit log.
|
|
177
|
+
*/
|
|
178
|
+
export async function runSourceFeedback(ctx, args, rest) {
|
|
179
|
+
var _a;
|
|
180
|
+
const [verb = 'status', ...extra] = rest;
|
|
181
|
+
const usage = 'Run "ekanos sources feedback [status|enable|disable] [--source <slug>]".';
|
|
182
|
+
if (extra.length > 0) {
|
|
183
|
+
throw usageError(`Unexpected argument "${extra[0]}".`, usage);
|
|
184
|
+
}
|
|
185
|
+
if (verb !== 'status' && verb !== 'enable' && verb !== 'disable') {
|
|
186
|
+
throw usageError(`Unknown sources feedback subcommand "${verb}".`, usage);
|
|
187
|
+
}
|
|
188
|
+
const env = resolveAuthEnvironment(ctx, args.host, args.env, {
|
|
189
|
+
projectDir: args.dir,
|
|
190
|
+
});
|
|
191
|
+
const resolved = await resolveSourceTarget(env, requireSession(env), {
|
|
192
|
+
source: args.source,
|
|
193
|
+
dir: args.dir,
|
|
194
|
+
});
|
|
195
|
+
const client = new FeedbackClient(env, resolved.session);
|
|
196
|
+
const setting = await client.call((token) => sourceFeedbackSetting(env.host, token, resolved.source, verb === 'status' ? undefined : verb === 'enable'));
|
|
197
|
+
const state = setting.enabled ? 'on' : 'off';
|
|
198
|
+
return ctx.succeed(Object.assign({ host: env.host }, setting), ctx.ui.result({
|
|
199
|
+
title: verb === 'status'
|
|
200
|
+
? `Feedback from the CLI is ${state} for ${setting.source.slug}`
|
|
201
|
+
: setting.changed
|
|
202
|
+
? `Turned feedback from the CLI ${state} for ${setting.source.slug}`
|
|
203
|
+
: `Feedback from the CLI was already ${state} for ${setting.source.slug}`,
|
|
204
|
+
tone: setting.enabled ? 'ok' : 'warn',
|
|
205
|
+
rows: [['Source', (_a = setting.source.name) !== null && _a !== void 0 ? _a : setting.source.slug]],
|
|
206
|
+
notes: [
|
|
207
|
+
setting.enabled
|
|
208
|
+
? '"ekanos feedback" sends a report to Vastly when someone, or their agent, runs it; nothing is sent on its own.'
|
|
209
|
+
: '"ekanos feedback" is refused for this Source, and no fix updates are shown.',
|
|
210
|
+
...(verb === 'status'
|
|
211
|
+
? [
|
|
212
|
+
`Its Source admin changes it: "ekanos sources feedback ${setting.enabled ? 'disable' : 'enable'}".`,
|
|
213
|
+
]
|
|
214
|
+
: []),
|
|
215
|
+
],
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
class FeedbackClient {
|
|
219
|
+
constructor(env, session) {
|
|
220
|
+
this.env = env;
|
|
221
|
+
this.session = session;
|
|
222
|
+
}
|
|
223
|
+
async call(send) {
|
|
224
|
+
let result = await send(this.session.accessToken);
|
|
225
|
+
if (result.status === 'unauthorized') {
|
|
226
|
+
this.session = await refreshStoredSession(this.env, this.session);
|
|
227
|
+
result = await send(this.session.accessToken);
|
|
228
|
+
}
|
|
229
|
+
if (result.status === 'ok')
|
|
230
|
+
return result.data;
|
|
231
|
+
throw authRequiredError(`The session for ${this.env.host} could not authorize the feedback call.`, loginHint(this.env));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.js","sourceRoot":"","sources":["../../src/commands/feedback.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,2BAA2B,EAI3B,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAG9B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE7E,OAAO,EAEL,eAAe,EACf,qBAAqB,EACrB,cAAc,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAgBlC,MAAM,KAAK,GACT,uMAAuM,CAAC;AAE1M;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAe,EACf,IAAkB;;IAElB,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,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G;uBACZ,OAAO;IACd,CAAC;IAEJ,KAAK,CAAC,IAAI,CACR,IAA4D;QAE5D,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,MAAM,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,GAAG,MAAM,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAClE,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC,IAAI,CAAC;QAC/C,MAAM,iBAAiB,CACrB,mBAAmB,IAAI,CAAC,GAAG,CAAC,IAAI,yCAAyC,EACzE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CACpB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n FEEDBACK_KINDS,\n FEEDBACK_MESSAGE_MAX_LENGTH,\n type FeedbackContext,\n type FeedbackKind,\n type FeedbackOwnEntry,\n redactFeedbackText,\n} from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\n\nimport type { StoredSession } from '../auth/credential-store';\nimport { loginHint } from '../auth/host-trust';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport { cliVersion } from '../compatibility';\nimport type { CliContext } from '../context';\nimport { authRequiredError, preconditionError, usageError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport {\n type FeedbackApiResult,\n listOwnFeedback,\n sourceFeedbackSetting,\n submitFeedback,\n} from '../feedback-api';\nimport { baseFeedbackContext, describeCommandLine } from '../feedback-context';\nimport { readLastError } from '../last-error';\nimport { resolveSourceTarget } from '../source-target';\nimport { shortHost } from '../ui';\n\nexport interface FeedbackArgs {\n host?: string;\n source?: string;\n /** `[<message>]`, or `list`. */\n positionals: readonly string[];\n kind?: string;\n lastError: boolean;\n command?: string;\n dir: string;\n env: Record<string, string | undefined>;\n stdinIsTTY?: boolean;\n readStdin?: () => Promise<string>;\n}\n\nconst USAGE =\n 'Run \"ekanos feedback \\\\\"<what you tried, what happened, what you expected>\\\\\" [--kind bug|confusing|missing|other] [--last-error] [--command \\\\\"<the ekanos command>\\\\\"]\", or \"ekanos feedback list\".';\n\n/**\n * `feedback` — tell Vastly about a problem with the CLI or the platform:\n * a command that failed unexpectedly, a confusing message, something\n * missing. Nothing is ever sent on its own; a report is this command, run\n * by a person or their agent. The message is redacted before it leaves\n * this machine (and again on the host), and what is attached about the\n * command is its path and flag NAMES, codes and versions: never an\n * argument, a value, a file or the environment.\n *\n * `feedback list` shows your own reports, with any fix that has shipped.\n */\nexport async function runFeedback(\n ctx: CliContext,\n args: FeedbackArgs,\n): Promise<ExitCode> {\n if (args.positionals[0] === 'list' && args.positionals.length === 1) {\n if (args.lastError || args.kind || args.command) {\n throw usageError('\"feedback list\" takes no report flags.', USAGE);\n }\n return runFeedbackList(ctx, args);\n }\n\n const kind = feedbackKind(args.kind, args.lastError);\n const typed = args.positionals[0]?.trim() || (await readPipedMessage(args));\n if (!typed && !args.lastError) {\n throw usageError('Say what happened: a message, or --last-error.', USAGE);\n }\n\n let context: FeedbackContext = baseFeedbackContext({\n cliVersion: cliVersion(),\n env: args.env,\n });\n if (args.lastError) {\n const last = readLastError(args.env);\n if (!last) {\n throw preconditionError(\n 'No failed command is recorded on this machine.',\n 'Run the command that failed again, then \"ekanos feedback --last-error \\\\\"<what you were trying to do>\\\\\"\" — or describe it: \"ekanos feedback \\\\\"<what happened>\\\\\" --command \\\\\"<the command>\\\\\"\".',\n );\n }\n context = {\n ...context,\n command: last.command,\n flags: last.flags,\n errorCode: last.errorCode,\n exitCode: last.exitCode,\n httpStatus: last.httpStatus,\n requestId: last.requestId,\n failedAt: last.failedAt,\n };\n }\n if (args.command !== undefined) {\n const described = describeCommandLine(args.command);\n if (!described.command) {\n throw usageError(\n `\"${args.command.slice(0, 60)}\" names no ekanos command.`,\n 'Pass the command it concerns, e.g. --command \"ekanos teams connect\".',\n );\n }\n context = { ...context, ...described };\n }\n\n const raw =\n typed ||\n 'Filed with --last-error; the reporter gave no description of what they were doing.';\n const redactedText = redactFeedbackText(raw);\n const truncated = redactedText.length > FEEDBACK_MESSAGE_MAX_LENGTH;\n const message = redactedText.slice(0, FEEDBACK_MESSAGE_MAX_LENGTH);\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), {\n source: args.source,\n dir: args.dir,\n });\n const client = new FeedbackClient(env, resolved.session);\n const filed = await client.call((token) =>\n submitFeedback(env.host, token, resolved.source, {\n message,\n kind,\n context,\n }),\n );\n\n return ctx.succeed(\n {\n host: env.host,\n source: resolved.source,\n id: filed.id,\n number: filed.number,\n kind,\n redacted: redactedText !== raw,\n truncated,\n context,\n },\n ctx.ui.result({\n title: `Filed feedback #${filed.number}`,\n rows: [\n ['Id', filed.id],\n ['Kind', kind],\n ['Host', shortHost(env.host)],\n ...(context.command\n ? ([['About', `ekanos ${context.command}`]] as Array<\n [string, string]\n >)\n : []),\n ],\n notes: [\n ...(redactedText !== raw\n ? [\n 'Something that looked like a secret or an email was replaced with [redacted] before it was sent.',\n ]\n : []),\n ...(truncated\n ? [\n `The message was cut to ${FEEDBACK_MESSAGE_MAX_LENGTH} characters.`,\n ]\n : []),\n 'When a fix ships, a later command tells you; \"ekanos feedback list\" shows your reports.',\n ],\n }),\n );\n}\n\nasync function runFeedbackList(\n ctx: CliContext,\n args: FeedbackArgs,\n): Promise<ExitCode> {\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const client = new FeedbackClient(env, requireSession(env));\n const list = await client.call((token) => listOwnFeedback(env.host, token));\n\n return ctx.succeed(\n { host: env.host, ...list },\n ctx.ui.result({\n title:\n list.reports.length === 0\n ? 'You have filed no feedback'\n : `Your feedback on ${shortHost(env.host)}`,\n rows: list.reports.map((report): [string, string[]] => [\n `#${report.number}`,\n [\n `${report.kind} · ${statusLabel(report)} · ${report.createdAt.slice(0, 10)}`,\n report.excerpt,\n ...(report.note ? [`Note: ${report.note}`] : []),\n ],\n ]),\n notes:\n list.reports.length === 0\n ? ['\"ekanos feedback \\\\\"<what happened>\\\\\"\" files one.']\n : [],\n }),\n );\n}\n\nfunction statusLabel(report: FeedbackOwnEntry): string {\n if (report.fix?.kind === 'cli') {\n return `fixed in @ekanos/cli ${report.fix.version}`;\n }\n if (report.fix?.kind === 'host') return 'fixed on the host';\n return report.status.replace('_', ' ');\n}\n\nfunction feedbackKind(\n value: string | undefined,\n lastError: boolean,\n): FeedbackKind {\n if (value === undefined) return lastError ? 'bug' : 'other';\n const kind = FEEDBACK_KINDS.find((entry) => entry === value.trim());\n if (kind) return kind;\n throw usageError(\n `\"${value}\" is not a kind of feedback.`,\n `Pass --kind ${FEEDBACK_KINDS.join('|')}.`,\n );\n}\n\n/**\n * The message from stdin, when something is piped in. A terminal, or a\n * stdin that is neither a pipe nor a file (an agent's empty one), is never\n * waited on.\n */\nasync function readPipedMessage(args: FeedbackArgs): Promise<string> {\n if (args.readStdin) {\n return args.stdinIsTTY ? '' : (await args.readStdin()).trim();\n }\n if (args.stdinIsTTY ?? process.stdin.isTTY) return '';\n try {\n const stat = fs.fstatSync(0);\n if (!stat.isFIFO() && !stat.isFile()) return '';\n // Read a byte past the cap, so an over-long message is cut, not refused.\n return fs\n .readFileSync(0, 'utf8')\n .slice(0, FEEDBACK_MESSAGE_MAX_LENGTH * 4)\n .trim();\n } catch {\n return '';\n }\n}\n\n/**\n * `sources feedback [status|enable|disable]` — whether this Source takes\n * reports from `ekanos feedback`. On unless its Source admin turns it off;\n * every change is recorded in the Admin Audit log.\n */\nexport async function runSourceFeedback(\n ctx: CliContext,\n args: {\n host?: string;\n source?: string;\n dir: string;\n env: Record<string, string | undefined>;\n },\n rest: readonly string[],\n): Promise<ExitCode> {\n const [verb = 'status', ...extra] = rest;\n const usage =\n 'Run \"ekanos sources feedback [status|enable|disable] [--source <slug>]\".';\n if (extra.length > 0) {\n throw usageError(`Unexpected argument \"${extra[0]}\".`, usage);\n }\n if (verb !== 'status' && verb !== 'enable' && verb !== 'disable') {\n throw usageError(`Unknown sources feedback subcommand \"${verb}\".`, usage);\n }\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(env, requireSession(env), {\n source: args.source,\n dir: args.dir,\n });\n const client = new FeedbackClient(env, resolved.session);\n const setting = await client.call((token) =>\n sourceFeedbackSetting(\n env.host,\n token,\n resolved.source,\n verb === 'status' ? undefined : verb === 'enable',\n ),\n );\n\n const state = setting.enabled ? 'on' : 'off';\n return ctx.succeed(\n { host: env.host, ...setting },\n ctx.ui.result({\n title:\n verb === 'status'\n ? `Feedback from the CLI is ${state} for ${setting.source.slug}`\n : setting.changed\n ? `Turned feedback from the CLI ${state} for ${setting.source.slug}`\n : `Feedback from the CLI was already ${state} for ${setting.source.slug}`,\n tone: setting.enabled ? 'ok' : 'warn',\n rows: [['Source', setting.source.name ?? setting.source.slug]],\n notes: [\n setting.enabled\n ? '\"ekanos feedback\" sends a report to Vastly when someone, or their agent, runs it; nothing is sent on its own.'\n : '\"ekanos feedback\" is refused for this Source, and no fix updates are shown.',\n ...(verb === 'status'\n ? [\n `Its Source admin changes it: \"ekanos sources feedback ${setting.enabled ? 'disable' : 'enable'}\".`,\n ]\n : []),\n ],\n }),\n );\n}\n\nclass FeedbackClient {\n constructor(\n private readonly env: AuthEnvironment,\n private session: StoredSession,\n ) {}\n\n async call<T>(\n send: (accessToken: string) => Promise<FeedbackApiResult<T>>,\n ): Promise<T> {\n let result = await send(this.session.accessToken);\n if (result.status === 'unauthorized') {\n this.session = await refreshStoredSession(this.env, this.session);\n result = await send(this.session.accessToken);\n }\n if (result.status === 'ok') return result.data;\n throw authRequiredError(\n `The session for ${this.env.host} could not authorize the feedback call.`,\n loginHint(this.env),\n );\n }\n}\n"]}
|
package/dist/commands/publish.js
CHANGED
|
@@ -337,7 +337,7 @@ export async function prepareIntegrationSubmission(ctx, args) {
|
|
|
337
337
|
host: env.host,
|
|
338
338
|
session,
|
|
339
339
|
});
|
|
340
|
-
announceUpdate(ctx, notice);
|
|
340
|
+
announceUpdate(ctx, notice, { env: args.env });
|
|
341
341
|
// The host would reject a build from a CLI it has declared unsupported
|
|
342
342
|
// anyway (see the wire contract in `toolchain-api.ts`) — refuse here with a
|
|
343
343
|
// hint naming the fix, rather than let the submission round-trip fail with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,QAAQ,EACR,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAmB,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAsB,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,GACd,MAAM,gBAAg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AAC,CAAC,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,iBAAiB,CACrB,kBAAkB,YAAY,KAC5B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,EACF,uEAAuE;YACrE,sBAAsB,CACzB,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GACX,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAC3C,CAAC,CAAE,MAAgC,CAAC,OAAO;QAC3C,CAAC,CAAC,SAAS,CAAC;IAEhB,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACjE,MAAM,eAAe,CACnB,6BACE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,SACjD,kCAAkC,EAClC,oBAAoB,YAAY,oCAAoC;YAClE,+BAA+B,CAClC,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { Finding } from '@ekanos/integration-schema';\nimport { findRepoRoot } from '@ekanos/integration-schema/repo';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { StoredSession } from '../auth/credential-store';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport type { CliContext } from '../context';\nimport {\n CliError,\n forbiddenError,\n gateFailedError,\n preconditionError,\n usageError,\n validationError,\n} from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { readProjectKind } from '../experience/project';\nimport { runExperiencePublish } from '../experience/publish';\nimport { renderFindings } from '../findings-renderer';\nimport { type SlugLookup, lookupSlug } from '../names-api';\nimport { packProject } from '../pack';\nimport { type LoadedProject, loadProject, serializeProject } from '../project';\nimport {\n MAX_MANIFEST_BYTES,\n globalNameUnapprovedError,\n stillUnauthorized,\n submitArchive,\n} from '../publish-api';\nimport { runRepoPublish } from '../repo/publish';\nimport { assertSchemaNotSkewed } from '../schema-skew';\nimport { fetchSeatsWithOneRefresh } from '../seats';\nimport { type SourceSeat, stillUnauthorizedSourceSeats } from '../sources-api';\nimport { shortHost } from '../ui';\nimport { announceUpdate, checkForUpdate } from '../update-notice';\nimport { collectAllFindings } from '../validate-findings';\nimport {\n DEFAULT_WAIT_MINUTES,\n failWatchTimeout,\n waitForGate,\n watchOutcomeData,\n} from './status';\n\n/**\n * Checks that are WARN in plain `ekanos validate` but must refuse a\n * `publish` outright: a project that will fail the gate is not allowed to\n * upload and find that out from the gate instead of from itself.\n * `project.host-compiler-rules` (see `project-checks.ts`) is WARN-severity\n * everywhere else on purpose — it reads a partner's local tsconfig, not the\n * gate's own verdict, so it must not block plain validate on a false\n * positive — but at the publish gate, \"this WILL fail the gate\" is exactly\n * the thing a submission preflight exists to refuse. A list, not a second\n * check, so the underlying rule and its message/hint stay defined in exactly\n * one place.\n */\nconst PUBLISH_ERROR_ESCALATIONS: readonly string[] = [\n 'project.host-compiler-rules',\n];\n\n/**\n * Escalate the checks in `PUBLISH_ERROR_ESCALATIONS` from `warn` to `error`\n * for THIS publish run only — `validate`'s own output (and the underlying\n * finding objects elsewhere) is never touched.\n */\nexport function escalateForPublish(findings: Finding[]): Finding[] {\n return findings.map((finding) =>\n finding.severity === 'warn' &&\n PUBLISH_ERROR_ESCALATIONS.includes(finding.check)\n ? { ...finding, severity: 'error' }\n : finding,\n );\n}\n\nexport interface PublishArgs {\n host?: string;\n /** Ekanos source slug. Falls back to ekanos.json's \"source\" field. */\n source?: string;\n /** Project directory (contains ekanos.json). Defaults to cwd. */\n dir: string;\n /**\n * Skips the interactive confirm when the source resolved IMPLICITLY (from\n * ekanos.json) and the caller holds more than one developer seat. Has no\n * effect when `--source` was passed this invocation (explicit is already\n * consent) or when the caller holds exactly one seat (nothing to\n * disambiguate).\n */\n yes: boolean;\n env: Record<string, string | undefined>;\n /**\n * Whether stdin is a real interactive terminal — the SECOND condition (with\n * human/non-JSON mode) required before publish will ever prompt. Defaults\n * to `process.stdin.isTTY === true`. Injectable so tests can exercise the\n * confirm branch without a real TTY.\n */\n stdinIsTTY?: boolean;\n /**\n * Injectable y/N prompt, for tests. Defaults to a real readline prompt over\n * stdin/stderr. Never invoked unless BOTH human mode and a real stdin TTY\n * are in play — see `canPrompt` in `verifyPublishTarget`.\n */\n confirm?: (question: string) => Promise<boolean>;\n /** Experiences only: build and pack, publish nothing. In a repo: every package. */\n dryRun?: boolean;\n /** Repo only: the packages to publish, by name. */\n packages?: readonly string[];\n /** Repo only: publish every package. */\n all?: boolean;\n /** Integration only: after submitting, wait for the gate verdict. */\n wait?: boolean;\n /** `--wait`: minutes to wait for the verdict (default 30). */\n timeoutMinutes?: number;\n /** Injectable for tests: the wait between polls. */\n sleep?: (ms: number) => Promise<void>;\n}\n\n/** Where the resolved source slug came from — governs the confirmation rules below. */\nexport interface SourceResolution {\n source: string;\n /** True iff `--source` was passed THIS invocation. */\n explicit: boolean;\n}\n\n/**\n * `publish` — pack the project and submit it to an Ekanos deployment.\n *\n * The submission gate is the SAME findings pass `validate` runs (one\n * implementation, `validate-findings.ts`): any error-severity finding refuses\n * the publish with GATE_FAILED (exit 10) and the findings in `data`, so an\n * agent can branch on the code and fix-then-retry without re-running validate.\n *\n * Authorization is server-side — the dev seat on the target source — and the\n * stored session is refreshed once on a 401, mirroring `whoami`. On the first\n * successful publish the chosen source slug is persisted into `ekanos.json`\n * so later publishes need no `--source`.\n */\nexport async function runPublish(\n ctx: CliContext,\n args: PublishArgs,\n): Promise<ExitCode> {\n // Inside a repo, `publish` plans the packages: a same-repo integration is\n // ordered first rather than refused as an override.\n const repoRoot = findRepoRoot(path.resolve(args.dir));\n if (repoRoot) {\n return runRepoPublish(ctx, {\n repoRoot,\n cwd: path.resolve(args.dir),\n names: args.packages ?? [],\n all: args.all === true,\n publish: args,\n });\n }\n if ((args.packages?.length ?? 0) > 0 || args.all) {\n throw usageError(\n 'Package names and --all are for a repo.',\n 'Run this from a repo (see \"ekanos init --kind repo\"), or drop the names to publish this project.',\n );\n }\n\n // An experience is published (dry-run only, for now) by its own pipeline,\n // before any login: overrides and the gate refuse it first.\n if (readProjectKind(path.resolve(args.dir)) === 'experience') {\n return runExperiencePublish(ctx, {\n dir: args.dir,\n dryRun: args.dryRun === true,\n env: args.env,\n host: args.host,\n source: args.source,\n yes: args.yes,\n stdinIsTTY: args.stdinIsTTY,\n confirm: args.confirm,\n });\n }\n\n if (args.dryRun) return runIntegrationDryRun(ctx, args);\n\n const prepared = await prepareIntegrationSubmission(ctx, args);\n const { loaded, version, slug } = prepared;\n\n const gate = await refuseOnFindings(ctx, loaded, slug, version);\n if (gate.exitCode !== null) return gate.exitCode;\n\n const submitted = await submitPrepared(ctx, args, prepared);\n\n if (!args.wait) return ctx.succeed(submitted.data, submitted.human);\n\n const submittedSource = (submitted.data.source as { slug: string }).slug;\n const waited = await waitForGate(ctx, prepared.env, {\n slug,\n source: submittedSource,\n version,\n timeoutMinutes: args.timeoutMinutes ?? DEFAULT_WAIT_MINUTES,\n sleep:\n args.sleep ??\n ((ms) =>\n new Promise((resolve) => {\n setTimeout(resolve, ms);\n })),\n });\n if (waited.timedOut) return failWatchTimeout(ctx, slug, version, waited);\n\n const gateData = watchOutcomeData(slug, waited.version);\n if (waited.version.state === 'rejected') {\n return ctx.fail(\n gateFailedError(\n `${slug}@${version} was submitted but rejected by the gate ` +\n `(${gateData.errorCount ?? 0} error${gateData.errorCount === 1 ? '' : 's'}).`,\n 'Resolve the error-severity findings in data.gate.findings, bump the ' +\n 'version (a submitted version cannot be changed), and re-run \"ekanos publish\".',\n ),\n { ...submitted.data, gate: gateData },\n );\n }\n\n return ctx.succeed(\n { ...submitted.data, state: waited.version.state, gate: gateData },\n `${submitted.human}\\n${ctx.ui.ok(`${ctx.ui.glyphs.ok} gate verdict: ${waited.version.state}`)}`,\n );\n}\n\n/**\n * The local gate every publish shares: the full findings pass, refusing with\n * GATE_FAILED when any finding is an error. Returns the exit code when it\n * refused, `null` when the project may go on.\n */\nasync function refuseOnFindings(\n ctx: CliContext,\n loaded: LoadedProject,\n slug: string,\n version: string,\n): Promise<{ exitCode: ExitCode | null; packWarnings: Finding[] }> {\n ctx.log(`Validating ${slug} before publishing…`);\n\n const findings = escalateForPublish(await collectAllFindings(loaded));\n const errorCount = findings.filter((f) => f.severity === 'error').length;\n\n if (errorCount > 0) {\n // Same rule as `validate`: render the shared findings block to stderr\n // BEFORE the envelope settles, human mode only. JSON mode carries the\n // identical findings in `data.findings` and must stay byte-identical.\n // Closing order is findings block -> short summary (via `ctx.fail`'s\n // `findingsSummary` option) -> next action.\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.err(\n `${ctx.ui.glyphs.err} Refusing to publish: ${errorCount} finding` +\n `${errorCount === 1 ? '' : 's'}.`,\n ),\n );\n renderFindings(ctx, findings, { cwd: loaded.projectDir });\n }\n\n const exitCode = ctx.fail(\n gateFailedError(\n `Refusing to publish: ${errorCount} validation finding` +\n `${errorCount === 1 ? '' : 's'}.`,\n 'Resolve the error-severity findings in data.findings (they are ' +\n 'exactly what \"ekanos validate\" reports), then re-run ' +\n '\"ekanos publish\".',\n ),\n { slug, version, findings },\n !ctx.jsonMode\n ? { findingsSummary: { command: 'ekanos publish', errorCount } }\n : undefined,\n );\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.nextAction(\n 'ekanos validate',\n 'fix the error-severity findings above, then re-run \"ekanos publish\"',\n ),\n );\n }\n\n return { exitCode, packWarnings: [] };\n }\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.ok(\n `${ctx.ui.glyphs.ok} validated ${slug} — no error-severity findings.`,\n ),\n );\n }\n\n // What is about to be packed is the one thing a version cannot take back.\n const packWarnings = findings.filter((f) => f.check.startsWith('pack.'));\n if (packWarnings.length > 0 && !ctx.jsonMode) {\n renderFindings(ctx, packWarnings, { cwd: loaded.projectDir });\n }\n\n return { exitCode: null, packWarnings };\n}\n\n/**\n * `publish --dry-run` for one integration: the same findings gate and the same\n * pack a real publish runs, with nothing sent. It needs no login and no\n * source, so it is what a CI job or a first look runs before the real one.\n */\nasync function runIntegrationDryRun(\n ctx: CliContext,\n args: PublishArgs,\n): Promise<ExitCode> {\n const loaded = loadProject(args.dir);\n const skew = assertSchemaNotSkewed(ctx, loaded.projectDir);\n const version = readProjectVersion(loaded.projectDir);\n const slug = loaded.primary.slug;\n\n const gate = await refuseOnFindings(ctx, loaded, slug, version);\n if (gate.exitCode !== null) return gate.exitCode;\n\n ctx.log(`Packing ${slug}@${version}…`);\n const packed = packProject(loaded.projectDir);\n buildManifest(loaded, packed.files);\n\n return ctx.succeed(\n {\n dryRun: true,\n slug,\n version,\n files: packed.files,\n archiveBytes: packed.archive.length,\n warnings: gate.packWarnings,\n ...(skew.status === 'project-older'\n ? {\n schemaSkew: {\n status: skew.status,\n cliSchemaVersion: skew.cliSchemaVersion,\n projectSchemaVersion: skew.projectSchemaVersion,\n },\n }\n : {}),\n },\n ctx.ui.result({\n title: 'Dry run: nothing submitted',\n rows: [\n ['Integration', `${slug}@${version}`],\n ['Files', String(packed.files.length)],\n ['Archive', `${packed.archive.length} bytes`],\n ],\n notes: [\n 'A submitted version is immutable: a mistake means a version bump. Run \"ekanos publish\" to submit.',\n ],\n }),\n );\n}\n\nexport interface SubmittedIntegration {\n data: Record<string, unknown>;\n human: string;\n}\n\n/**\n * Confirm the target, pack and submit one gated integration. The caller has\n * already passed the gate; this is the only part of `publish` that talks to\n * the host.\n */\nexport async function submitPrepared(\n ctx: CliContext,\n args: PublishArgs,\n prepared: PreparedSubmission,\n): Promise<SubmittedIntegration> {\n const { loaded, skew, notice, env, version, slug, resolution } = prepared;\n\n // The 100%-certainty mechanism: confirm the resolved source is one the\n // caller actually holds a seat on — and, when it was resolved IMPLICITLY\n // from ekanos.json with more than one seat in play, that a human (or an\n // explicit --yes) actually intends this target — BEFORE anything is packed\n // or sent over the wire.\n const verified = await verifyPublishTarget(ctx, env, resolution.session, {\n source: resolution.source,\n explicit: resolution.explicit,\n slug,\n version,\n yes: args.yes,\n stdinIsTTY: args.stdinIsTTY ?? process.stdin.isTTY === true,\n confirm: args.confirm ?? promptYesNo,\n });\n\n const source = verified.sourceSeat.slug;\n const availability = loaded.project.availability?.mode;\n\n // Say the full name the host will use, and refuse an unapproved global\n // name, before anything is packed.\n const lookup = await preflightName(\n ctx,\n env,\n verified.session,\n source,\n slug,\n availability,\n );\n\n ctx.log(`Packing ${slug}@${version}…`);\n\n const packed = packProject(loaded.projectDir);\n const manifest = buildManifest(loaded, packed.files);\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.ok(\n `${ctx.ui.glyphs.ok} packed ${slug}@${version} (${packed.files.length} files).`,\n ),\n );\n }\n\n ctx.log(`Submitting to ${env.host} (source \"${source}\")…`);\n\n const receipt = await submitWithOneRefresh(env, verified.session, {\n source,\n slug,\n version,\n manifest,\n archive: packed.archive,\n ...(availability ? { availability } : {}),\n });\n\n const displayName =\n receipt.displayName ?? lookup?.displayName ?? receipt.slug;\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.ok(\n `${ctx.ui.glyphs.ok} submitted ${displayName}@${receipt.version} ` +\n `(state \"${receipt.state}\").`,\n ),\n );\n }\n\n const persisted = persistProjectFields(loaded, source, env.host);\n\n const persistedNote = [\n ...(persisted.source ? [`\"source\": \"${source}\"`] : []),\n ...(persisted.host ? [`\"host\": \"${env.host}\"`] : []),\n ];\n\n return {\n data: {\n host: env.host,\n source: {\n id: verified.sourceSeat.id,\n slug: verified.sourceSeat.slug,\n name: verified.sourceSeat.name,\n },\n slug: receipt.slug,\n namespace: receipt.namespace ?? lookup?.namespace ?? null,\n displayName,\n version: receipt.version,\n submissionId: receipt.submissionId,\n state: receipt.state,\n archiveSha256: receipt.archiveSha256,\n files: packed.files,\n sourcePersisted: persisted.source,\n hostPersisted: persisted.host,\n hostOverride: persisted.hostOverride,\n ...(skew.status === 'project-older'\n ? {\n schemaSkew: {\n status: skew.status,\n cliSchemaVersion: skew.cliSchemaVersion,\n projectSchemaVersion: skew.projectSchemaVersion,\n },\n }\n : {}),\n ...(notice ? { toolchain: notice } : {}),\n },\n human: ctx.ui.result({\n title: 'Submitted',\n rows: [\n ['Integration', `${displayName}@${receipt.version}`],\n ['State', receipt.state],\n ['Source', source],\n ['Host', shortHost(env.host)],\n ...(persistedNote.length > 0\n ? [\n [\n 'Saved',\n `${persistedNote.join(' and ')} to ekanos.json`,\n ] as const,\n ]\n : []),\n ],\n notes: persisted.hostOverride\n ? [\n `This publish went to ${env.host}, but ekanos.json keeps \"host\": ` +\n `\"${persisted.hostOverride}\" — a one-off override never replaces ` +\n 'the saved host; edit ekanos.json to change it.',\n ]\n : [],\n }),\n };\n}\n\n/**\n * Ask the host what it will call this slug for the Source, before packing.\n * An unapproved global name stops the publish here. Any other answer - an\n * older host without the route, a server error, a shape this CLI does not\n * read - is not a reason to stop: the submission itself is authoritative, and\n * the bare slug stands in for the name.\n */\nasync function preflightName(\n ctx: CliContext,\n env: AuthEnvironment,\n session: StoredSession,\n source: string,\n slug: string,\n availability: 'global' | 'restricted' | undefined,\n): Promise<SlugLookup | null> {\n let lookup: SlugLookup | null = null;\n\n try {\n let result = await lookupSlug(\n env.host,\n session.accessToken,\n source,\n slug,\n availability,\n );\n if (result.status === 'unauthorized') {\n const refreshed = await refreshStoredSession(env, session);\n result = await lookupSlug(\n env.host,\n refreshed.accessToken,\n source,\n slug,\n availability,\n );\n }\n if (result.status === 'ok') lookup = result.lookup;\n } catch (error) {\n if (!(error instanceof CliError)) throw error;\n ctx.log(\n `Could not pre-check the name of ${slug} (${error.message}); continuing.`,\n );\n }\n\n if (lookup?.status === 'global_unapproved') {\n throw globalNameUnapprovedError(slug);\n }\n\n if (lookup?.displayName && !ctx.jsonMode) {\n ctx.log(`Publishing as ${lookup.displayName}.`);\n }\n\n return lookup;\n}\n\nexport interface PreparedSubmission {\n env: AuthEnvironment;\n session: StoredSession;\n loaded: LoadedProject;\n skew: ReturnType<typeof assertSchemaNotSkewed>;\n notice: Awaited<ReturnType<typeof checkForUpdate>>;\n resolution: SourceResolution & { session: StoredSession };\n version: string;\n slug: string;\n}\n\n/**\n * Everything `publish` does before it gates a project: sign-in, load, schema\n * skew, toolchain check, source resolution. Shared by the single-project verb\n * and the repo verb (which gates every package before submitting any).\n */\nexport async function prepareIntegrationSubmission(\n ctx: CliContext,\n args: PublishArgs,\n): Promise<PreparedSubmission> {\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const session = requireSession(env);\n\n const loaded = loadProject(args.dir);\n\n // Fail fast, before anything else: a project whose schema is newer than\n // this CLI bundles cannot be trusted to validate correctly, so publishing\n // it — the one verb whose findings gate is meant to be authoritative —\n // must refuse before packing or submitting anything. See `schema-skew.ts`.\n const skew = assertSchemaNotSkewed(ctx, loaded.projectDir);\n\n const notice = await checkForUpdate({\n env: args.env,\n host: env.host,\n session,\n });\n announceUpdate(ctx, notice);\n\n // The host would reject a build from a CLI it has declared unsupported\n // anyway (see the wire contract in `toolchain-api.ts`) — refuse here with a\n // hint naming the fix, rather than let the submission round-trip fail with\n // whatever generic error the host happens to answer with.\n if (notice?.status === 'unsupported') {\n throw preconditionError(\n `@ekanos/cli ${notice.current.cli} is below ${env.host}'s minimum ` +\n `supported version (needs at least ${notice.target.cli}).`,\n 'Run \"ekanos upgrade\" before publishing — the host will refuse this ' +\n 'submission from an unsupported CLI regardless.',\n );\n }\n\n const resolution = await resolveSourceSlug(env, session, args.source, loaded);\n const version = readProjectVersion(loaded.projectDir);\n const slug = loaded.primary.slug;\n\n return { env, session, loaded, skew, notice, resolution, version, slug };\n}\n\n/**\n * The publish-target verification gate.\n *\n * FORBIDDEN (exit 5) whenever the resolved source is not among the caller's\n * seats — regardless of whether it came from `--source` or ekanos.json.\n * Beyond that, the confirmation rules branch on how the source was resolved:\n *\n * - `--source` THIS invocation: explicit is consent. Proceed.\n * - ekanos.json, exactly one seat held (which must be the match, or the\n * FORBIDDEN check above would have already fired): proceed, but say so —\n * there is nothing to disambiguate, but the target should never be silent.\n * - ekanos.json, multiple seats held: the ambiguous case this mechanism\n * exists for. Only when BOTH human (non-JSON) mode AND stdin is a real\n * TTY does it print the target and require an explicit y/N confirm\n * (`--yes` skips it) — see `canPrompt` below for why stdin matters, not\n * just stdout. Every other combination (JSON mode, or human mode with a\n * closed/non-interactive stdin) NEVER prompts — it proceeds only with\n * `--yes`, otherwise VALIDATION (exit 3) with the seat list, naming\n * `--source`, `--yes` and `ekanos use`.\n */\nexport async function verifyPublishTarget(\n ctx: CliContext,\n env: AuthEnvironment,\n session: StoredSession,\n args: SourceResolution & {\n slug: string;\n version: string;\n yes: boolean;\n /** Real interactivity signal for stdin — see `canPrompt` below. */\n stdinIsTTY: boolean;\n confirm: (question: string) => Promise<boolean>;\n },\n): Promise<{ sourceSeat: SourceSeat; session: StoredSession }> {\n const result = await fetchSeatsWithOneRefresh(env, session);\n\n if (result.status === 'unauthorized') {\n stillUnauthorizedSourceSeats(env);\n }\n\n const seat = result.sources.find((s) => s.slug === args.source);\n\n if (!seat) {\n throw forbiddenError(\n `This account does not hold a seat on source \"${args.source}\" on ${env.host}.`,\n seatsHint(result.sources, env.host),\n );\n }\n\n if (args.explicit) {\n return { sourceSeat: seat, session: result.session };\n }\n\n if (result.sources.length === 1) {\n ctx.log(\n `Publishing to ${seat.name ?? seat.slug} (${seat.slug}) — your only ` +\n `developer seat.`,\n );\n return { sourceSeat: seat, session: result.session };\n }\n\n // Implicit source, multiple seats: the ambiguous case.\n //\n // `ctx.jsonMode` alone is NOT enough to decide whether an interactive\n // confirm is safe: `--no-json` forces human mode even when stdout is\n // piped, and neither `--no-json` nor a bare human run says anything about\n // stdin. Prompting `readline`'s `.question()` against a closed/non-TTY\n // stdin (a cron job, a wrapper script piping stdout but not attached to a\n // terminal) never resolves — the process hangs instead of exiting with a\n // clean code. So an actual prompt requires BOTH: human mode AND a real\n // stdin TTY. Anything else — JSON mode, or human mode with non-interactive\n // stdin — falls through to the same non-prompting `--yes`-or-refuse rule.\n const canPrompt = !ctx.jsonMode && args.stdinIsTTY;\n\n if (canPrompt) {\n ctx.log(\n `Publishing ${args.slug}@${args.version} to SOURCE ${seat.name ?? seat.slug} ` +\n `(${seat.slug}) on ${env.host}`,\n );\n\n if (!args.yes) {\n const confirmed = await args.confirm('Proceed? [y/N]');\n\n if (!confirmed) {\n throw validationError(\n `Publish to \"${seat.slug}\" was not confirmed.`,\n multiSeatHint(result.sources),\n );\n }\n }\n\n return { sourceSeat: seat, session: result.session };\n }\n\n if (args.yes) {\n return { sourceSeat: seat, session: result.session };\n }\n\n throw validationError(\n `Ambiguous publish target: this account holds ${result.sources.length} ` +\n `developer seats and the source was resolved from ekanos.json, not ` +\n `an explicit flag.`,\n multiSeatHint(result.sources),\n );\n}\n\nfunction seatsHint(sources: SourceSeat[], host: string): string {\n if (sources.length === 0) {\n return (\n `You hold no seats on any source on ${host}. Ask Ekanos ` +\n `to grant your account the developer seat on the intended source.`\n );\n }\n\n return (\n `You hold a seat on: ${describeSeats(sources)}. Pass \"--source <slug>\" ` +\n `naming one of these, or run \"ekanos use <slug>\" to set the project's ` +\n `default.`\n );\n}\n\nfunction multiSeatHint(sources: SourceSeat[]): string {\n return (\n `You hold seats on: ${describeSeats(sources)}. Pass \"--source <slug>\" ` +\n `to name the target explicitly, add \"--yes\" to confirm the target ` +\n `already in ekanos.json non-interactively, or run \"ekanos use <slug>\" ` +\n `to change the project's default.`\n );\n}\n\nfunction describeSeats(sources: SourceSeat[]): string {\n return sources.map((s) => `${s.slug} (${s.roles.join(', ')})`).join(', ');\n}\n\n/**\n * The real, non-test y/N prompt. Reads a line from stdin and writes the\n * question to stderr, so it never touches stdout — the one stream the JSON\n * envelope invariant depends on. Only reachable when `verifyPublishTarget`'s\n * `canPrompt` is true — human mode AND a real stdin TTY — so this never\n * blocks on a closed or non-interactive stdin.\n */\n/**\n * Exported so `upgrade` can reuse the exact same y/N prompt rather than\n * writing a second one — see `canPrompt` above for the stdin-TTY gating this\n * is only ever invoked behind.\n */\nexport async function promptYesNo(question: string): Promise<boolean> {\n const readline = await import('node:readline/promises');\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stderr,\n });\n\n try {\n const answer = await rl.question(`${question} `);\n return /^y(es)?$/i.test(answer.trim());\n } finally {\n rl.close();\n }\n}\n\nexport async function submitWithOneRefresh(\n env: ReturnType<typeof resolveAuthEnvironment>,\n session: StoredSession,\n payload: Parameters<typeof submitArchive>[2],\n) {\n const first = await submitArchive(env.host, session.accessToken, payload);\n\n if (first.status === 'ok') return first.receipt;\n\n // The access token no longer authenticates — an ordinary event, not an\n // error. One refresh, one retry; a second 401 is authoritative.\n const refreshed = await refreshStoredSession(env, session);\n const second = await submitArchive(env.host, refreshed.accessToken, payload);\n\n if (second.status === 'ok') return second.receipt;\n\n return stillUnauthorized(env);\n}\n\n/**\n * Resolve the source slug (flag → ekanos.json) and whether it was given\n * EXPLICITLY this invocation — the fact `verifyPublishTarget` uses to decide\n * whether a confirmation is even in play. `flag !== undefined` (rather than\n * \"non-empty after trim\") is deliberate: an explicit `--source` that is\n * effectively empty is still a caller who typed the flag, not one who\n * fell through to ekanos.json.\n */\nexport async function resolveSourceSlug(\n env: AuthEnvironment,\n session: StoredSession,\n flag: string | undefined,\n /** Anything that carries the project's saved `source`: an integration project or an experience's ekanos.json. */\n loaded: { project: { source?: string } },\n): Promise<SourceResolution & { session: StoredSession }> {\n const explicit = flag !== undefined;\n const raw = flag ?? loaded.project.source;\n\n if (!raw || raw.trim().length === 0) {\n return noSourceError(env, session);\n }\n\n return { source: raw.trim(), explicit, session };\n}\n\n/**\n * The no-source validation error, enriched with the caller's seat list when\n * it can be fetched — best-effort, since a session is guaranteed to exist\n * here (publish already called `requireSession`) but the fetch itself can\n * still fail (network, MFA, a down deployment). A failure to enrich must\n * never mask or replace the primary \"no source given\" error.\n */\nasync function noSourceError(\n env: AuthEnvironment,\n session: StoredSession,\n): Promise<never> {\n let seatsNote = '';\n\n try {\n const result = await fetchSeatsWithOneRefresh(env, session);\n\n if (result.status === 'ok') {\n seatsNote =\n result.sources.length > 0\n ? ` You hold a seat on: ${describeSeats(result.sources)}.`\n : ' You hold no seats on any source on this host yet.';\n }\n } catch {\n // Best-effort — the primary error below stands on its own.\n }\n\n throw validationError(\n 'No Ekanos source given for the submission.',\n 'Pass \"--source <slug>\" (your operator names the source), or set ' +\n '\"source\": \"<slug>\" in ekanos.json. A successful publish saves it ' +\n `there for you.${seatsNote}`,\n );\n}\n\n/**\n * Persist the chosen source AND host into ekanos.json after a SUCCESSFUL\n * publish, so the next publish — and every other host-taking verb — needs no\n * flag. Returns what was written. A write failure is reported but never fails\n * the command — the submission already landed.\n *\n * `publish` is the only verb that writes ekanos.json: it is the one verb that\n * proves the (host, source) pair actually works, and it always runs inside a\n * project. `login` deliberately never writes — it is routinely run outside\n * one, and the credential store's sole-host fallback covers it.\n *\n * `host` persists on FIRST WRITE ONLY. It decides where every future verb\n * sends the bearer token and the source archive, so a one-off `--host`\n * override (a staging test, say) must not silently become the project's\n * sticky default; when the override differs from the stored host, the stored\n * value is kept and the difference is called out in the result instead.\n * Changing it is an explicit edit of ekanos.json. `source` keeps the simpler\n * always-update semantics — it is scoped BY the host, and updating it is the\n * documented way to repoint a project.\n */\nexport function persistProjectFields(\n loaded: LoadedProject,\n source: string,\n host: string,\n): { source: boolean; host: boolean; hostOverride: string | null } {\n const wants = {\n source: loaded.project.source !== source,\n host: loaded.project.host === undefined,\n };\n\n const hostOverride =\n loaded.project.host !== undefined && loaded.project.host !== host\n ? loaded.project.host\n : null;\n\n if (!wants.source && !wants.host) {\n return { source: false, host: false, hostOverride };\n }\n\n try {\n fs.writeFileSync(\n loaded.configPath,\n serializeProject({\n ...loaded.project,\n source,\n host: wants.host ? host : loaded.project.host,\n }),\n );\n\n return { ...wants, hostOverride };\n } catch {\n // Diagnostics-only: the publish succeeded; a read-only ekanos.json just\n // means the next publish needs the flags again.\n return { source: false, host: false, hostOverride };\n }\n}\n\n/**\n * How many packed paths the manifest embeds before switching to a truncated\n * list plus a `filesTruncated` total. The manifest is metadata — the archive\n * itself is the payload — and the server caps it at MAX_MANIFEST_BYTES, so a\n * many-small-files project must not be able to blow the cap with its file\n * list alone.\n */\nconst MANIFEST_FILE_LIST_CAP = 200;\n\n/**\n * The submission manifest: the parsed ekanos.json, the integration entries,\n * and (a bounded prefix of) the packed file list. Refuses to build one over\n * the server's byte cap — a clear VALIDATION error here beats the server's\n * generic 400 after a 4 MiB upload.\n */\nexport function buildManifest(loaded: LoadedProject, files: string[]): string {\n const manifest = JSON.stringify({\n project: loaded.project,\n integrations: loaded.integrations.map((i) => ({\n slug: i.slug,\n entry: i.entry,\n })),\n files: files.slice(0, MANIFEST_FILE_LIST_CAP),\n ...(files.length > MANIFEST_FILE_LIST_CAP\n ? { filesTruncated: files.length }\n : {}),\n });\n\n const bytes = Buffer.byteLength(manifest, 'utf8');\n\n if (bytes > MAX_MANIFEST_BYTES) {\n throw validationError(\n `The submission manifest is ${bytes} bytes, over the ` +\n `${MAX_MANIFEST_BYTES}-byte server cap.`,\n 'The manifest embeds your ekanos.json — trim oversized fields there ' +\n '(sourceGlobs is the usual culprit), then re-run \"ekanos publish\".',\n );\n }\n\n return manifest;\n}\n\nconst SEMVER_PATTERN =\n /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/;\n\n/**\n * The submitted version is the project's own `package.json#version` — one\n * source of truth, the same field npm would publish.\n */\nexport function readProjectVersion(projectDir: string): string {\n const manifestPath = path.join(projectDir, 'package.json');\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));\n } catch (error) {\n throw preconditionError(\n `Could not read ${manifestPath}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n `Ensure the project has a valid package.json — its \"version\" field is ` +\n `what gets submitted.`,\n );\n }\n\n const version =\n typeof parsed === 'object' && parsed !== null\n ? (parsed as { version?: unknown }).version\n : undefined;\n\n if (typeof version !== 'string' || !SEMVER_PATTERN.test(version)) {\n throw validationError(\n `package.json \"version\" is ${\n typeof version === 'string' ? `\"${version}\"` : 'missing'\n }, which is not a semver version.`,\n `Set \"version\" in ${manifestPath} to a semver string like \"0.1.0\", ` +\n `then re-run \"ekanos publish\".`,\n );\n }\n\n return version;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/commands/publish.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,QAAQ,EACR,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAmB,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAsB,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAA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C,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,iBAAiB,CACrB,kBAAkB,YAAY,KAC5B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,EACF,uEAAuE;YACrE,sBAAsB,CACzB,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GACX,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAC3C,CAAC,CAAE,MAAgC,CAAC,OAAO;QAC3C,CAAC,CAAC,SAAS,CAAC;IAEhB,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACjE,MAAM,eAAe,CACnB,6BACE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,SACjD,kCAAkC,EAClC,oBAAoB,YAAY,oCAAoC;YAClE,+BAA+B,CAClC,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type { Finding } from '@ekanos/integration-schema';\nimport { findRepoRoot } from '@ekanos/integration-schema/repo';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { StoredSession } from '../auth/credential-store';\nimport {\n type AuthEnvironment,\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport type { CliContext } from '../context';\nimport {\n CliError,\n forbiddenError,\n gateFailedError,\n preconditionError,\n usageError,\n validationError,\n} from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { readProjectKind } from '../experience/project';\nimport { runExperiencePublish } from '../experience/publish';\nimport { renderFindings } from '../findings-renderer';\nimport { type SlugLookup, lookupSlug } from '../names-api';\nimport { packProject } from '../pack';\nimport { type LoadedProject, loadProject, serializeProject } from '../project';\nimport {\n MAX_MANIFEST_BYTES,\n globalNameUnapprovedError,\n stillUnauthorized,\n submitArchive,\n} from '../publish-api';\nimport { runRepoPublish } from '../repo/publish';\nimport { assertSchemaNotSkewed } from '../schema-skew';\nimport { fetchSeatsWithOneRefresh } from '../seats';\nimport { type SourceSeat, stillUnauthorizedSourceSeats } from '../sources-api';\nimport { shortHost } from '../ui';\nimport { announceUpdate, checkForUpdate } from '../update-notice';\nimport { collectAllFindings } from '../validate-findings';\nimport {\n DEFAULT_WAIT_MINUTES,\n failWatchTimeout,\n waitForGate,\n watchOutcomeData,\n} from './status';\n\n/**\n * Checks that are WARN in plain `ekanos validate` but must refuse a\n * `publish` outright: a project that will fail the gate is not allowed to\n * upload and find that out from the gate instead of from itself.\n * `project.host-compiler-rules` (see `project-checks.ts`) is WARN-severity\n * everywhere else on purpose — it reads a partner's local tsconfig, not the\n * gate's own verdict, so it must not block plain validate on a false\n * positive — but at the publish gate, \"this WILL fail the gate\" is exactly\n * the thing a submission preflight exists to refuse. A list, not a second\n * check, so the underlying rule and its message/hint stay defined in exactly\n * one place.\n */\nconst PUBLISH_ERROR_ESCALATIONS: readonly string[] = [\n 'project.host-compiler-rules',\n];\n\n/**\n * Escalate the checks in `PUBLISH_ERROR_ESCALATIONS` from `warn` to `error`\n * for THIS publish run only — `validate`'s own output (and the underlying\n * finding objects elsewhere) is never touched.\n */\nexport function escalateForPublish(findings: Finding[]): Finding[] {\n return findings.map((finding) =>\n finding.severity === 'warn' &&\n PUBLISH_ERROR_ESCALATIONS.includes(finding.check)\n ? { ...finding, severity: 'error' }\n : finding,\n );\n}\n\nexport interface PublishArgs {\n host?: string;\n /** Ekanos source slug. Falls back to ekanos.json's \"source\" field. */\n source?: string;\n /** Project directory (contains ekanos.json). Defaults to cwd. */\n dir: string;\n /**\n * Skips the interactive confirm when the source resolved IMPLICITLY (from\n * ekanos.json) and the caller holds more than one developer seat. Has no\n * effect when `--source` was passed this invocation (explicit is already\n * consent) or when the caller holds exactly one seat (nothing to\n * disambiguate).\n */\n yes: boolean;\n env: Record<string, string | undefined>;\n /**\n * Whether stdin is a real interactive terminal — the SECOND condition (with\n * human/non-JSON mode) required before publish will ever prompt. Defaults\n * to `process.stdin.isTTY === true`. Injectable so tests can exercise the\n * confirm branch without a real TTY.\n */\n stdinIsTTY?: boolean;\n /**\n * Injectable y/N prompt, for tests. Defaults to a real readline prompt over\n * stdin/stderr. Never invoked unless BOTH human mode and a real stdin TTY\n * are in play — see `canPrompt` in `verifyPublishTarget`.\n */\n confirm?: (question: string) => Promise<boolean>;\n /** Experiences only: build and pack, publish nothing. In a repo: every package. */\n dryRun?: boolean;\n /** Repo only: the packages to publish, by name. */\n packages?: readonly string[];\n /** Repo only: publish every package. */\n all?: boolean;\n /** Integration only: after submitting, wait for the gate verdict. */\n wait?: boolean;\n /** `--wait`: minutes to wait for the verdict (default 30). */\n timeoutMinutes?: number;\n /** Injectable for tests: the wait between polls. */\n sleep?: (ms: number) => Promise<void>;\n}\n\n/** Where the resolved source slug came from — governs the confirmation rules below. */\nexport interface SourceResolution {\n source: string;\n /** True iff `--source` was passed THIS invocation. */\n explicit: boolean;\n}\n\n/**\n * `publish` — pack the project and submit it to an Ekanos deployment.\n *\n * The submission gate is the SAME findings pass `validate` runs (one\n * implementation, `validate-findings.ts`): any error-severity finding refuses\n * the publish with GATE_FAILED (exit 10) and the findings in `data`, so an\n * agent can branch on the code and fix-then-retry without re-running validate.\n *\n * Authorization is server-side — the dev seat on the target source — and the\n * stored session is refreshed once on a 401, mirroring `whoami`. On the first\n * successful publish the chosen source slug is persisted into `ekanos.json`\n * so later publishes need no `--source`.\n */\nexport async function runPublish(\n ctx: CliContext,\n args: PublishArgs,\n): Promise<ExitCode> {\n // Inside a repo, `publish` plans the packages: a same-repo integration is\n // ordered first rather than refused as an override.\n const repoRoot = findRepoRoot(path.resolve(args.dir));\n if (repoRoot) {\n return runRepoPublish(ctx, {\n repoRoot,\n cwd: path.resolve(args.dir),\n names: args.packages ?? [],\n all: args.all === true,\n publish: args,\n });\n }\n if ((args.packages?.length ?? 0) > 0 || args.all) {\n throw usageError(\n 'Package names and --all are for a repo.',\n 'Run this from a repo (see \"ekanos init --kind repo\"), or drop the names to publish this project.',\n );\n }\n\n // An experience is published (dry-run only, for now) by its own pipeline,\n // before any login: overrides and the gate refuse it first.\n if (readProjectKind(path.resolve(args.dir)) === 'experience') {\n return runExperiencePublish(ctx, {\n dir: args.dir,\n dryRun: args.dryRun === true,\n env: args.env,\n host: args.host,\n source: args.source,\n yes: args.yes,\n stdinIsTTY: args.stdinIsTTY,\n confirm: args.confirm,\n });\n }\n\n if (args.dryRun) return runIntegrationDryRun(ctx, args);\n\n const prepared = await prepareIntegrationSubmission(ctx, args);\n const { loaded, version, slug } = prepared;\n\n const gate = await refuseOnFindings(ctx, loaded, slug, version);\n if (gate.exitCode !== null) return gate.exitCode;\n\n const submitted = await submitPrepared(ctx, args, prepared);\n\n if (!args.wait) return ctx.succeed(submitted.data, submitted.human);\n\n const submittedSource = (submitted.data.source as { slug: string }).slug;\n const waited = await waitForGate(ctx, prepared.env, {\n slug,\n source: submittedSource,\n version,\n timeoutMinutes: args.timeoutMinutes ?? DEFAULT_WAIT_MINUTES,\n sleep:\n args.sleep ??\n ((ms) =>\n new Promise((resolve) => {\n setTimeout(resolve, ms);\n })),\n });\n if (waited.timedOut) return failWatchTimeout(ctx, slug, version, waited);\n\n const gateData = watchOutcomeData(slug, waited.version);\n if (waited.version.state === 'rejected') {\n return ctx.fail(\n gateFailedError(\n `${slug}@${version} was submitted but rejected by the gate ` +\n `(${gateData.errorCount ?? 0} error${gateData.errorCount === 1 ? '' : 's'}).`,\n 'Resolve the error-severity findings in data.gate.findings, bump the ' +\n 'version (a submitted version cannot be changed), and re-run \"ekanos publish\".',\n ),\n { ...submitted.data, gate: gateData },\n );\n }\n\n return ctx.succeed(\n { ...submitted.data, state: waited.version.state, gate: gateData },\n `${submitted.human}\\n${ctx.ui.ok(`${ctx.ui.glyphs.ok} gate verdict: ${waited.version.state}`)}`,\n );\n}\n\n/**\n * The local gate every publish shares: the full findings pass, refusing with\n * GATE_FAILED when any finding is an error. Returns the exit code when it\n * refused, `null` when the project may go on.\n */\nasync function refuseOnFindings(\n ctx: CliContext,\n loaded: LoadedProject,\n slug: string,\n version: string,\n): Promise<{ exitCode: ExitCode | null; packWarnings: Finding[] }> {\n ctx.log(`Validating ${slug} before publishing…`);\n\n const findings = escalateForPublish(await collectAllFindings(loaded));\n const errorCount = findings.filter((f) => f.severity === 'error').length;\n\n if (errorCount > 0) {\n // Same rule as `validate`: render the shared findings block to stderr\n // BEFORE the envelope settles, human mode only. JSON mode carries the\n // identical findings in `data.findings` and must stay byte-identical.\n // Closing order is findings block -> short summary (via `ctx.fail`'s\n // `findingsSummary` option) -> next action.\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.err(\n `${ctx.ui.glyphs.err} Refusing to publish: ${errorCount} finding` +\n `${errorCount === 1 ? '' : 's'}.`,\n ),\n );\n renderFindings(ctx, findings, { cwd: loaded.projectDir });\n }\n\n const exitCode = ctx.fail(\n gateFailedError(\n `Refusing to publish: ${errorCount} validation finding` +\n `${errorCount === 1 ? '' : 's'}.`,\n 'Resolve the error-severity findings in data.findings (they are ' +\n 'exactly what \"ekanos validate\" reports), then re-run ' +\n '\"ekanos publish\".',\n ),\n { slug, version, findings },\n !ctx.jsonMode\n ? { findingsSummary: { command: 'ekanos publish', errorCount } }\n : undefined,\n );\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.nextAction(\n 'ekanos validate',\n 'fix the error-severity findings above, then re-run \"ekanos publish\"',\n ),\n );\n }\n\n return { exitCode, packWarnings: [] };\n }\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.ok(\n `${ctx.ui.glyphs.ok} validated ${slug} — no error-severity findings.`,\n ),\n );\n }\n\n // What is about to be packed is the one thing a version cannot take back.\n const packWarnings = findings.filter((f) => f.check.startsWith('pack.'));\n if (packWarnings.length > 0 && !ctx.jsonMode) {\n renderFindings(ctx, packWarnings, { cwd: loaded.projectDir });\n }\n\n return { exitCode: null, packWarnings };\n}\n\n/**\n * `publish --dry-run` for one integration: the same findings gate and the same\n * pack a real publish runs, with nothing sent. It needs no login and no\n * source, so it is what a CI job or a first look runs before the real one.\n */\nasync function runIntegrationDryRun(\n ctx: CliContext,\n args: PublishArgs,\n): Promise<ExitCode> {\n const loaded = loadProject(args.dir);\n const skew = assertSchemaNotSkewed(ctx, loaded.projectDir);\n const version = readProjectVersion(loaded.projectDir);\n const slug = loaded.primary.slug;\n\n const gate = await refuseOnFindings(ctx, loaded, slug, version);\n if (gate.exitCode !== null) return gate.exitCode;\n\n ctx.log(`Packing ${slug}@${version}…`);\n const packed = packProject(loaded.projectDir);\n buildManifest(loaded, packed.files);\n\n return ctx.succeed(\n {\n dryRun: true,\n slug,\n version,\n files: packed.files,\n archiveBytes: packed.archive.length,\n warnings: gate.packWarnings,\n ...(skew.status === 'project-older'\n ? {\n schemaSkew: {\n status: skew.status,\n cliSchemaVersion: skew.cliSchemaVersion,\n projectSchemaVersion: skew.projectSchemaVersion,\n },\n }\n : {}),\n },\n ctx.ui.result({\n title: 'Dry run: nothing submitted',\n rows: [\n ['Integration', `${slug}@${version}`],\n ['Files', String(packed.files.length)],\n ['Archive', `${packed.archive.length} bytes`],\n ],\n notes: [\n 'A submitted version is immutable: a mistake means a version bump. Run \"ekanos publish\" to submit.',\n ],\n }),\n );\n}\n\nexport interface SubmittedIntegration {\n data: Record<string, unknown>;\n human: string;\n}\n\n/**\n * Confirm the target, pack and submit one gated integration. The caller has\n * already passed the gate; this is the only part of `publish` that talks to\n * the host.\n */\nexport async function submitPrepared(\n ctx: CliContext,\n args: PublishArgs,\n prepared: PreparedSubmission,\n): Promise<SubmittedIntegration> {\n const { loaded, skew, notice, env, version, slug, resolution } = prepared;\n\n // The 100%-certainty mechanism: confirm the resolved source is one the\n // caller actually holds a seat on — and, when it was resolved IMPLICITLY\n // from ekanos.json with more than one seat in play, that a human (or an\n // explicit --yes) actually intends this target — BEFORE anything is packed\n // or sent over the wire.\n const verified = await verifyPublishTarget(ctx, env, resolution.session, {\n source: resolution.source,\n explicit: resolution.explicit,\n slug,\n version,\n yes: args.yes,\n stdinIsTTY: args.stdinIsTTY ?? process.stdin.isTTY === true,\n confirm: args.confirm ?? promptYesNo,\n });\n\n const source = verified.sourceSeat.slug;\n const availability = loaded.project.availability?.mode;\n\n // Say the full name the host will use, and refuse an unapproved global\n // name, before anything is packed.\n const lookup = await preflightName(\n ctx,\n env,\n verified.session,\n source,\n slug,\n availability,\n );\n\n ctx.log(`Packing ${slug}@${version}…`);\n\n const packed = packProject(loaded.projectDir);\n const manifest = buildManifest(loaded, packed.files);\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.ok(\n `${ctx.ui.glyphs.ok} packed ${slug}@${version} (${packed.files.length} files).`,\n ),\n );\n }\n\n ctx.log(`Submitting to ${env.host} (source \"${source}\")…`);\n\n const receipt = await submitWithOneRefresh(env, verified.session, {\n source,\n slug,\n version,\n manifest,\n archive: packed.archive,\n ...(availability ? { availability } : {}),\n });\n\n const displayName =\n receipt.displayName ?? lookup?.displayName ?? receipt.slug;\n\n if (!ctx.jsonMode) {\n ctx.log(\n ctx.ui.ok(\n `${ctx.ui.glyphs.ok} submitted ${displayName}@${receipt.version} ` +\n `(state \"${receipt.state}\").`,\n ),\n );\n }\n\n const persisted = persistProjectFields(loaded, source, env.host);\n\n const persistedNote = [\n ...(persisted.source ? [`\"source\": \"${source}\"`] : []),\n ...(persisted.host ? [`\"host\": \"${env.host}\"`] : []),\n ];\n\n return {\n data: {\n host: env.host,\n source: {\n id: verified.sourceSeat.id,\n slug: verified.sourceSeat.slug,\n name: verified.sourceSeat.name,\n },\n slug: receipt.slug,\n namespace: receipt.namespace ?? lookup?.namespace ?? null,\n displayName,\n version: receipt.version,\n submissionId: receipt.submissionId,\n state: receipt.state,\n archiveSha256: receipt.archiveSha256,\n files: packed.files,\n sourcePersisted: persisted.source,\n hostPersisted: persisted.host,\n hostOverride: persisted.hostOverride,\n ...(skew.status === 'project-older'\n ? {\n schemaSkew: {\n status: skew.status,\n cliSchemaVersion: skew.cliSchemaVersion,\n projectSchemaVersion: skew.projectSchemaVersion,\n },\n }\n : {}),\n ...(notice ? { toolchain: notice } : {}),\n },\n human: ctx.ui.result({\n title: 'Submitted',\n rows: [\n ['Integration', `${displayName}@${receipt.version}`],\n ['State', receipt.state],\n ['Source', source],\n ['Host', shortHost(env.host)],\n ...(persistedNote.length > 0\n ? [\n [\n 'Saved',\n `${persistedNote.join(' and ')} to ekanos.json`,\n ] as const,\n ]\n : []),\n ],\n notes: persisted.hostOverride\n ? [\n `This publish went to ${env.host}, but ekanos.json keeps \"host\": ` +\n `\"${persisted.hostOverride}\" — a one-off override never replaces ` +\n 'the saved host; edit ekanos.json to change it.',\n ]\n : [],\n }),\n };\n}\n\n/**\n * Ask the host what it will call this slug for the Source, before packing.\n * An unapproved global name stops the publish here. Any other answer - an\n * older host without the route, a server error, a shape this CLI does not\n * read - is not a reason to stop: the submission itself is authoritative, and\n * the bare slug stands in for the name.\n */\nasync function preflightName(\n ctx: CliContext,\n env: AuthEnvironment,\n session: StoredSession,\n source: string,\n slug: string,\n availability: 'global' | 'restricted' | undefined,\n): Promise<SlugLookup | null> {\n let lookup: SlugLookup | null = null;\n\n try {\n let result = await lookupSlug(\n env.host,\n session.accessToken,\n source,\n slug,\n availability,\n );\n if (result.status === 'unauthorized') {\n const refreshed = await refreshStoredSession(env, session);\n result = await lookupSlug(\n env.host,\n refreshed.accessToken,\n source,\n slug,\n availability,\n );\n }\n if (result.status === 'ok') lookup = result.lookup;\n } catch (error) {\n if (!(error instanceof CliError)) throw error;\n ctx.log(\n `Could not pre-check the name of ${slug} (${error.message}); continuing.`,\n );\n }\n\n if (lookup?.status === 'global_unapproved') {\n throw globalNameUnapprovedError(slug);\n }\n\n if (lookup?.displayName && !ctx.jsonMode) {\n ctx.log(`Publishing as ${lookup.displayName}.`);\n }\n\n return lookup;\n}\n\nexport interface PreparedSubmission {\n env: AuthEnvironment;\n session: StoredSession;\n loaded: LoadedProject;\n skew: ReturnType<typeof assertSchemaNotSkewed>;\n notice: Awaited<ReturnType<typeof checkForUpdate>>;\n resolution: SourceResolution & { session: StoredSession };\n version: string;\n slug: string;\n}\n\n/**\n * Everything `publish` does before it gates a project: sign-in, load, schema\n * skew, toolchain check, source resolution. Shared by the single-project verb\n * and the repo verb (which gates every package before submitting any).\n */\nexport async function prepareIntegrationSubmission(\n ctx: CliContext,\n args: PublishArgs,\n): Promise<PreparedSubmission> {\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const session = requireSession(env);\n\n const loaded = loadProject(args.dir);\n\n // Fail fast, before anything else: a project whose schema is newer than\n // this CLI bundles cannot be trusted to validate correctly, so publishing\n // it — the one verb whose findings gate is meant to be authoritative —\n // must refuse before packing or submitting anything. See `schema-skew.ts`.\n const skew = assertSchemaNotSkewed(ctx, loaded.projectDir);\n\n const notice = await checkForUpdate({\n env: args.env,\n host: env.host,\n session,\n });\n announceUpdate(ctx, notice, { env: args.env });\n\n // The host would reject a build from a CLI it has declared unsupported\n // anyway (see the wire contract in `toolchain-api.ts`) — refuse here with a\n // hint naming the fix, rather than let the submission round-trip fail with\n // whatever generic error the host happens to answer with.\n if (notice?.status === 'unsupported') {\n throw preconditionError(\n `@ekanos/cli ${notice.current.cli} is below ${env.host}'s minimum ` +\n `supported version (needs at least ${notice.target.cli}).`,\n 'Run \"ekanos upgrade\" before publishing — the host will refuse this ' +\n 'submission from an unsupported CLI regardless.',\n );\n }\n\n const resolution = await resolveSourceSlug(env, session, args.source, loaded);\n const version = readProjectVersion(loaded.projectDir);\n const slug = loaded.primary.slug;\n\n return { env, session, loaded, skew, notice, resolution, version, slug };\n}\n\n/**\n * The publish-target verification gate.\n *\n * FORBIDDEN (exit 5) whenever the resolved source is not among the caller's\n * seats — regardless of whether it came from `--source` or ekanos.json.\n * Beyond that, the confirmation rules branch on how the source was resolved:\n *\n * - `--source` THIS invocation: explicit is consent. Proceed.\n * - ekanos.json, exactly one seat held (which must be the match, or the\n * FORBIDDEN check above would have already fired): proceed, but say so —\n * there is nothing to disambiguate, but the target should never be silent.\n * - ekanos.json, multiple seats held: the ambiguous case this mechanism\n * exists for. Only when BOTH human (non-JSON) mode AND stdin is a real\n * TTY does it print the target and require an explicit y/N confirm\n * (`--yes` skips it) — see `canPrompt` below for why stdin matters, not\n * just stdout. Every other combination (JSON mode, or human mode with a\n * closed/non-interactive stdin) NEVER prompts — it proceeds only with\n * `--yes`, otherwise VALIDATION (exit 3) with the seat list, naming\n * `--source`, `--yes` and `ekanos use`.\n */\nexport async function verifyPublishTarget(\n ctx: CliContext,\n env: AuthEnvironment,\n session: StoredSession,\n args: SourceResolution & {\n slug: string;\n version: string;\n yes: boolean;\n /** Real interactivity signal for stdin — see `canPrompt` below. */\n stdinIsTTY: boolean;\n confirm: (question: string) => Promise<boolean>;\n },\n): Promise<{ sourceSeat: SourceSeat; session: StoredSession }> {\n const result = await fetchSeatsWithOneRefresh(env, session);\n\n if (result.status === 'unauthorized') {\n stillUnauthorizedSourceSeats(env);\n }\n\n const seat = result.sources.find((s) => s.slug === args.source);\n\n if (!seat) {\n throw forbiddenError(\n `This account does not hold a seat on source \"${args.source}\" on ${env.host}.`,\n seatsHint(result.sources, env.host),\n );\n }\n\n if (args.explicit) {\n return { sourceSeat: seat, session: result.session };\n }\n\n if (result.sources.length === 1) {\n ctx.log(\n `Publishing to ${seat.name ?? seat.slug} (${seat.slug}) — your only ` +\n `developer seat.`,\n );\n return { sourceSeat: seat, session: result.session };\n }\n\n // Implicit source, multiple seats: the ambiguous case.\n //\n // `ctx.jsonMode` alone is NOT enough to decide whether an interactive\n // confirm is safe: `--no-json` forces human mode even when stdout is\n // piped, and neither `--no-json` nor a bare human run says anything about\n // stdin. Prompting `readline`'s `.question()` against a closed/non-TTY\n // stdin (a cron job, a wrapper script piping stdout but not attached to a\n // terminal) never resolves — the process hangs instead of exiting with a\n // clean code. So an actual prompt requires BOTH: human mode AND a real\n // stdin TTY. Anything else — JSON mode, or human mode with non-interactive\n // stdin — falls through to the same non-prompting `--yes`-or-refuse rule.\n const canPrompt = !ctx.jsonMode && args.stdinIsTTY;\n\n if (canPrompt) {\n ctx.log(\n `Publishing ${args.slug}@${args.version} to SOURCE ${seat.name ?? seat.slug} ` +\n `(${seat.slug}) on ${env.host}`,\n );\n\n if (!args.yes) {\n const confirmed = await args.confirm('Proceed? [y/N]');\n\n if (!confirmed) {\n throw validationError(\n `Publish to \"${seat.slug}\" was not confirmed.`,\n multiSeatHint(result.sources),\n );\n }\n }\n\n return { sourceSeat: seat, session: result.session };\n }\n\n if (args.yes) {\n return { sourceSeat: seat, session: result.session };\n }\n\n throw validationError(\n `Ambiguous publish target: this account holds ${result.sources.length} ` +\n `developer seats and the source was resolved from ekanos.json, not ` +\n `an explicit flag.`,\n multiSeatHint(result.sources),\n );\n}\n\nfunction seatsHint(sources: SourceSeat[], host: string): string {\n if (sources.length === 0) {\n return (\n `You hold no seats on any source on ${host}. Ask Ekanos ` +\n `to grant your account the developer seat on the intended source.`\n );\n }\n\n return (\n `You hold a seat on: ${describeSeats(sources)}. Pass \"--source <slug>\" ` +\n `naming one of these, or run \"ekanos use <slug>\" to set the project's ` +\n `default.`\n );\n}\n\nfunction multiSeatHint(sources: SourceSeat[]): string {\n return (\n `You hold seats on: ${describeSeats(sources)}. Pass \"--source <slug>\" ` +\n `to name the target explicitly, add \"--yes\" to confirm the target ` +\n `already in ekanos.json non-interactively, or run \"ekanos use <slug>\" ` +\n `to change the project's default.`\n );\n}\n\nfunction describeSeats(sources: SourceSeat[]): string {\n return sources.map((s) => `${s.slug} (${s.roles.join(', ')})`).join(', ');\n}\n\n/**\n * The real, non-test y/N prompt. Reads a line from stdin and writes the\n * question to stderr, so it never touches stdout — the one stream the JSON\n * envelope invariant depends on. Only reachable when `verifyPublishTarget`'s\n * `canPrompt` is true — human mode AND a real stdin TTY — so this never\n * blocks on a closed or non-interactive stdin.\n */\n/**\n * Exported so `upgrade` can reuse the exact same y/N prompt rather than\n * writing a second one — see `canPrompt` above for the stdin-TTY gating this\n * is only ever invoked behind.\n */\nexport async function promptYesNo(question: string): Promise<boolean> {\n const readline = await import('node:readline/promises');\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stderr,\n });\n\n try {\n const answer = await rl.question(`${question} `);\n return /^y(es)?$/i.test(answer.trim());\n } finally {\n rl.close();\n }\n}\n\nexport async function submitWithOneRefresh(\n env: ReturnType<typeof resolveAuthEnvironment>,\n session: StoredSession,\n payload: Parameters<typeof submitArchive>[2],\n) {\n const first = await submitArchive(env.host, session.accessToken, payload);\n\n if (first.status === 'ok') return first.receipt;\n\n // The access token no longer authenticates — an ordinary event, not an\n // error. One refresh, one retry; a second 401 is authoritative.\n const refreshed = await refreshStoredSession(env, session);\n const second = await submitArchive(env.host, refreshed.accessToken, payload);\n\n if (second.status === 'ok') return second.receipt;\n\n return stillUnauthorized(env);\n}\n\n/**\n * Resolve the source slug (flag → ekanos.json) and whether it was given\n * EXPLICITLY this invocation — the fact `verifyPublishTarget` uses to decide\n * whether a confirmation is even in play. `flag !== undefined` (rather than\n * \"non-empty after trim\") is deliberate: an explicit `--source` that is\n * effectively empty is still a caller who typed the flag, not one who\n * fell through to ekanos.json.\n */\nexport async function resolveSourceSlug(\n env: AuthEnvironment,\n session: StoredSession,\n flag: string | undefined,\n /** Anything that carries the project's saved `source`: an integration project or an experience's ekanos.json. */\n loaded: { project: { source?: string } },\n): Promise<SourceResolution & { session: StoredSession }> {\n const explicit = flag !== undefined;\n const raw = flag ?? loaded.project.source;\n\n if (!raw || raw.trim().length === 0) {\n return noSourceError(env, session);\n }\n\n return { source: raw.trim(), explicit, session };\n}\n\n/**\n * The no-source validation error, enriched with the caller's seat list when\n * it can be fetched — best-effort, since a session is guaranteed to exist\n * here (publish already called `requireSession`) but the fetch itself can\n * still fail (network, MFA, a down deployment). A failure to enrich must\n * never mask or replace the primary \"no source given\" error.\n */\nasync function noSourceError(\n env: AuthEnvironment,\n session: StoredSession,\n): Promise<never> {\n let seatsNote = '';\n\n try {\n const result = await fetchSeatsWithOneRefresh(env, session);\n\n if (result.status === 'ok') {\n seatsNote =\n result.sources.length > 0\n ? ` You hold a seat on: ${describeSeats(result.sources)}.`\n : ' You hold no seats on any source on this host yet.';\n }\n } catch {\n // Best-effort — the primary error below stands on its own.\n }\n\n throw validationError(\n 'No Ekanos source given for the submission.',\n 'Pass \"--source <slug>\" (your operator names the source), or set ' +\n '\"source\": \"<slug>\" in ekanos.json. A successful publish saves it ' +\n `there for you.${seatsNote}`,\n );\n}\n\n/**\n * Persist the chosen source AND host into ekanos.json after a SUCCESSFUL\n * publish, so the next publish — and every other host-taking verb — needs no\n * flag. Returns what was written. A write failure is reported but never fails\n * the command — the submission already landed.\n *\n * `publish` is the only verb that writes ekanos.json: it is the one verb that\n * proves the (host, source) pair actually works, and it always runs inside a\n * project. `login` deliberately never writes — it is routinely run outside\n * one, and the credential store's sole-host fallback covers it.\n *\n * `host` persists on FIRST WRITE ONLY. It decides where every future verb\n * sends the bearer token and the source archive, so a one-off `--host`\n * override (a staging test, say) must not silently become the project's\n * sticky default; when the override differs from the stored host, the stored\n * value is kept and the difference is called out in the result instead.\n * Changing it is an explicit edit of ekanos.json. `source` keeps the simpler\n * always-update semantics — it is scoped BY the host, and updating it is the\n * documented way to repoint a project.\n */\nexport function persistProjectFields(\n loaded: LoadedProject,\n source: string,\n host: string,\n): { source: boolean; host: boolean; hostOverride: string | null } {\n const wants = {\n source: loaded.project.source !== source,\n host: loaded.project.host === undefined,\n };\n\n const hostOverride =\n loaded.project.host !== undefined && loaded.project.host !== host\n ? loaded.project.host\n : null;\n\n if (!wants.source && !wants.host) {\n return { source: false, host: false, hostOverride };\n }\n\n try {\n fs.writeFileSync(\n loaded.configPath,\n serializeProject({\n ...loaded.project,\n source,\n host: wants.host ? host : loaded.project.host,\n }),\n );\n\n return { ...wants, hostOverride };\n } catch {\n // Diagnostics-only: the publish succeeded; a read-only ekanos.json just\n // means the next publish needs the flags again.\n return { source: false, host: false, hostOverride };\n }\n}\n\n/**\n * How many packed paths the manifest embeds before switching to a truncated\n * list plus a `filesTruncated` total. The manifest is metadata — the archive\n * itself is the payload — and the server caps it at MAX_MANIFEST_BYTES, so a\n * many-small-files project must not be able to blow the cap with its file\n * list alone.\n */\nconst MANIFEST_FILE_LIST_CAP = 200;\n\n/**\n * The submission manifest: the parsed ekanos.json, the integration entries,\n * and (a bounded prefix of) the packed file list. Refuses to build one over\n * the server's byte cap — a clear VALIDATION error here beats the server's\n * generic 400 after a 4 MiB upload.\n */\nexport function buildManifest(loaded: LoadedProject, files: string[]): string {\n const manifest = JSON.stringify({\n project: loaded.project,\n integrations: loaded.integrations.map((i) => ({\n slug: i.slug,\n entry: i.entry,\n })),\n files: files.slice(0, MANIFEST_FILE_LIST_CAP),\n ...(files.length > MANIFEST_FILE_LIST_CAP\n ? { filesTruncated: files.length }\n : {}),\n });\n\n const bytes = Buffer.byteLength(manifest, 'utf8');\n\n if (bytes > MAX_MANIFEST_BYTES) {\n throw validationError(\n `The submission manifest is ${bytes} bytes, over the ` +\n `${MAX_MANIFEST_BYTES}-byte server cap.`,\n 'The manifest embeds your ekanos.json — trim oversized fields there ' +\n '(sourceGlobs is the usual culprit), then re-run \"ekanos publish\".',\n );\n }\n\n return manifest;\n}\n\nconst SEMVER_PATTERN =\n /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/;\n\n/**\n * The submitted version is the project's own `package.json#version` — one\n * source of truth, the same field npm would publish.\n */\nexport function readProjectVersion(projectDir: string): string {\n const manifestPath = path.join(projectDir, 'package.json');\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));\n } catch (error) {\n throw preconditionError(\n `Could not read ${manifestPath}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n `Ensure the project has a valid package.json — its \"version\" field is ` +\n `what gets submitted.`,\n );\n }\n\n const version =\n typeof parsed === 'object' && parsed !== null\n ? (parsed as { version?: unknown }).version\n : undefined;\n\n if (typeof version !== 'string' || !SEMVER_PATTERN.test(version)) {\n throw validationError(\n `package.json \"version\" is ${\n typeof version === 'string' ? `\"${version}\"` : 'missing'\n }, which is not a semver version.`,\n `Set \"version\" in ${manifestPath} to a semver string like \"0.1.0\", ` +\n `then re-run \"ekanos publish\".`,\n );\n }\n\n return version;\n}\n"]}
|
package/dist/commands/sources.js
CHANGED
|
@@ -12,6 +12,7 @@ import { resolveSourceTarget } from '../source-target.js';
|
|
|
12
12
|
import { stillUnauthorizedSourceSeats } from '../sources-api.js';
|
|
13
13
|
import { listProductScopes, setScopeProduct } from '../teams-api.js';
|
|
14
14
|
import { pluralize, shortHost } from '../ui.js';
|
|
15
|
+
import { runSourceFeedback } from './feedback.js';
|
|
15
16
|
import { scopeDeprecationNotice } from './scope-notice.js';
|
|
16
17
|
import { runSourcePeople, runSourceRoles } from './sources-roles.js';
|
|
17
18
|
/**
|
|
@@ -32,8 +33,10 @@ export async function runSources(ctx, args) {
|
|
|
32
33
|
return runSourceRoles(ctx, args, rest);
|
|
33
34
|
if (subcommand === 'people')
|
|
34
35
|
return runSourcePeople(ctx, args, rest);
|
|
36
|
+
if (subcommand === 'feedback')
|
|
37
|
+
return runSourceFeedback(ctx, args, rest);
|
|
35
38
|
if (subcommand !== 'products') {
|
|
36
|
-
throw usageError(`Unknown sources subcommand "${subcommand}".`, 'Run "ekanos sources" to list your sources, "ekanos sources products [enable|disable <product>]", "ekanos sources scopes [add|remove <scope> <product>]", "ekanos sources roles [list|create|update|delete <role>]" or "ekanos sources
|
|
39
|
+
throw usageError(`Unknown sources subcommand "${subcommand}".`, 'Run "ekanos sources" to list your sources, "ekanos sources products [enable|disable <product>]", "ekanos sources scopes [add|remove <scope> <product>]", "ekanos sources roles [list|create|update|delete <role>]", "ekanos sources people" or "ekanos sources feedback [status|enable|disable]".');
|
|
37
40
|
}
|
|
38
41
|
return runProducts(ctx, args, rest);
|
|
39
42
|
}
|