@lark-project/cli
Version:
飞书项目插件开发工具
45 lines (44 loc) • 1.87 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatWhoami = void 0;
/** Render a unix-seconds timestamp as local YYYY-MM-DD. */
function formatDate(ts) {
const d = new Date(ts * 1000);
const pad = (n) => String(n).padStart(2, '0');
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
}
/**
* Render the self-describing `lpm whoami` report. The text itself tells the AI
* what to do (suggest + confirm), so skills don't need to restate the rule.
* Input is a WhoamiSelection, which carries only origins + timestamps — never
* a token — so this output cannot leak credentials.
*/
function formatWhoami(sel) {
const { domains, suggested } = sel;
if (domains.length === 0) {
return '未登录。请先执行 lpm login --site-domain <url>。';
}
if (domains.length === 1) {
return [
`已登录站点:${domains[0].domain} ← 建议用于 lpm create`,
'→ 与用户确认此站点后再创建。',
].join('\n');
}
const lines = [];
if (suggested) {
lines.push('已登录站点(最近使用优先):');
domains.forEach((e, i) => {
const when = e.lastUsedAt !== undefined ? ` (上次使用 ${formatDate(e.lastUsedAt)})` : '';
const mark = e.domain === suggested ? ' ← 建议' : '';
lines.push(` ${i + 1}. ${e.domain}${when}${mark}`);
});
lines.push('→ 向用户建议标记 ← 的站点,确认后用于 lpm create;用户也可改选其它。');
}
else {
lines.push('已登录站点:');
domains.forEach(e => lines.push(` - ${e.domain}`));
lines.push('→ 无法判定最近使用站点,请让用户选择其一。');
}
return lines.join('\n');
}
exports.formatWhoami = formatWhoami;