@ekanos/cli 0.5.1 → 0.6.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 +1 -1
- package/dist/commands/agents-init.d.ts +33 -0
- package/dist/commands/agents-init.js +113 -0
- package/dist/commands/agents-init.js.map +1 -0
- package/dist/commands/agents.d.ts +3 -1
- package/dist/commands/agents.js +14 -5
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/catalog.js +3 -2
- package/dist/commands/catalog.js.map +1 -1
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +2 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/agents-claude.md.tmpl +14 -0
- package/templates/claude-skill.md.tmpl +4 -8
- package/templates/package.json.tmpl +1 -1
- package/templates/skills/build-agent/SKILL.md +110 -0
- package/templates/skills/build-agent/references/agent-json.md +85 -0
- package/templates/skills/build-agent/references/rollout.md +53 -0
- package/templates/skills/build-agent/references/triggers.md +47 -0
- package/templates/skills/ekanos-platform/SKILL.md +98 -0
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ npx @ekanos/cli dev
|
|
|
28
28
|
| `status` | The read verb: login state for the resolved host, this project's `ekanos.json`, and its submissions on the host (`GET /api/partner/submissions`). Never fails just because you are logged out — it reports `authenticated: false` instead. |
|
|
29
29
|
| `sources` | List every Ekanos source you hold a developer or source-admin seat on (`GET /api/partner/sources`), with a marker on this project's current publish target. |
|
|
30
30
|
| `catalog` | `ekanos catalog [<product-slug>]` — what a source can already use (`GET /api/partner/catalog`): every product enabled, switched off or available to enable, with its tools, agent triggers and generated setup steps. Check it before building something the source may already have. |
|
|
31
|
-
| `agents` | `ekanos agents list | show | pull | apply | publish | rollback` — the source's agents, held by Ekanos (`/api/partner/agents`). `apply` stores a new version as a draft, `publish` makes a version the one every team runs, `rollback` publishes an earlier one. Either seat applies; only the source admin publishes.
|
|
31
|
+
| `agents` | `ekanos agents init | list | show | pull | apply | publish | rollback` — the source's agents, held by Ekanos (`/api/partner/agents`). `init` sets up a folder for designing agents with Claude (the `build-agent` and `ekanos-platform` skills, the docs MCP server, a CLAUDE.md) without scaffolding an integration. `apply` stores a new version as a draft, `publish` makes a version the one every team runs, `rollback` publishes an earlier one. Either seat applies; only the source admin publishes.
|
|
32
32
|
| `use` | `ekanos use <source-slug>` — set this project's publish target to a source you hold a seat on. Refuses (`forbidden`, with your actual seats in the hint) for a slug you don't hold a seat on, so a typo can't silently repoint a project. |
|
|
33
33
|
| `publish` | Validate, pack and submit the integration to an Ekanos host — refusing (`forbidden`) a target you hold no seat on, and confirming an ambiguous multi-seat target before submitting. See [Publish target verification](#publish-target-verification). |
|
|
34
34
|
| `upgrade` | Move this toolchain to a coherent target version, with verify-and-rollback. `--check` reports current vs. target and changes nothing; a bare `upgrade` installs, verifies (`validate` + the test script), and rolls back automatically on any failure. See [Keeping the toolchain current](#keeping-the-toolchain-current). |
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CliContext } from '../context.js';
|
|
2
|
+
import type { ExitCode } from '../exit-codes.js';
|
|
3
|
+
import type { Ui } from '../ui.js';
|
|
4
|
+
/** The skills a folder that only manages agents needs — not the integration-authoring ones. */
|
|
5
|
+
export declare const AGENT_SKILLS: readonly ['ekanos-platform', 'build-agent'];
|
|
6
|
+
export declare const DOCS_MCP_SERVER_NAME = "ekanos-sdk-docs";
|
|
7
|
+
export declare const DOCS_MCP_SERVER: {
|
|
8
|
+
readonly type: 'http';
|
|
9
|
+
readonly url: 'https://sdk.ekanos.dev/mcp';
|
|
10
|
+
};
|
|
11
|
+
export interface AgentsInitArgs {
|
|
12
|
+
dir: string;
|
|
13
|
+
force: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* `ekanos agents init` — make a folder ready for Claude to design agents: the
|
|
17
|
+
* `ekanos-platform` and `build-agent` skills, the docs MCP server in
|
|
18
|
+
* `.mcp.json`, and a short CLAUDE.md. Unlike `ekanos init` it scaffolds no
|
|
19
|
+
* integration: an agent is data in Ekanos, not code in this folder. Local,
|
|
20
|
+
* no session needed, and idempotent: existing files are kept (merged, for
|
|
21
|
+
* `.mcp.json`) unless `--force`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function runAgentsInit(ctx: CliContext, args: AgentsInitArgs): ExitCode;
|
|
24
|
+
type DocsServerOutcome = 'created' | 'merged' | 'present' | 'unreadable';
|
|
25
|
+
/** Create `.mcp.json` with the docs server, or add it to one that lacks it. */
|
|
26
|
+
export declare function ensureDocsServer(targetDir: string): {
|
|
27
|
+
outcome: DocsServerOutcome;
|
|
28
|
+
};
|
|
29
|
+
/** Whether this folder already has the docs server — `agents`/`catalog` suggest `agents init` when not. */
|
|
30
|
+
export declare function hasDocsServer(targetDir: string): boolean;
|
|
31
|
+
/** Suggest `ekanos agents init` (skills + the docs MCP server) where this folder lacks it. */
|
|
32
|
+
export declare function withDocsHint(ui: Ui, dir: string, summary: string): string;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { readFileNoFollow, writeFileNoFollow } from '../safe-fs.js';
|
|
4
|
+
import { templatesDir } from '../templates.js';
|
|
5
|
+
import { copyBundledSkillTrees } from './init.js';
|
|
6
|
+
/** The skills a folder that only manages agents needs — not the integration-authoring ones. */
|
|
7
|
+
export const AGENT_SKILLS = ['ekanos-platform', 'build-agent'];
|
|
8
|
+
export const DOCS_MCP_SERVER_NAME = 'ekanos-sdk-docs';
|
|
9
|
+
export const DOCS_MCP_SERVER = {
|
|
10
|
+
type: 'http',
|
|
11
|
+
url: 'https://sdk.ekanos.dev/mcp',
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* `ekanos agents init` — make a folder ready for Claude to design agents: the
|
|
15
|
+
* `ekanos-platform` and `build-agent` skills, the docs MCP server in
|
|
16
|
+
* `.mcp.json`, and a short CLAUDE.md. Unlike `ekanos init` it scaffolds no
|
|
17
|
+
* integration: an agent is data in Ekanos, not code in this folder. Local,
|
|
18
|
+
* no session needed, and idempotent: existing files are kept (merged, for
|
|
19
|
+
* `.mcp.json`) unless `--force`.
|
|
20
|
+
*/
|
|
21
|
+
export function runAgentsInit(ctx, args) {
|
|
22
|
+
const targetDir = path.resolve(args.dir);
|
|
23
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
24
|
+
const skills = copyBundledSkillTrees(targetDir, args.force, undefined, 'throw', AGENT_SKILLS);
|
|
25
|
+
const created = [...skills.created];
|
|
26
|
+
const skipped = [...skills.skipped];
|
|
27
|
+
const mcp = ensureDocsServer(targetDir);
|
|
28
|
+
if (mcp.outcome === 'created' || mcp.outcome === 'merged') {
|
|
29
|
+
created.push('.mcp.json');
|
|
30
|
+
}
|
|
31
|
+
else if (mcp.outcome === 'unreadable') {
|
|
32
|
+
skipped.push({
|
|
33
|
+
file: '.mcp.json',
|
|
34
|
+
reason: 'it is not valid JSON',
|
|
35
|
+
hint: `Add "${DOCS_MCP_SERVER_NAME}": ${JSON.stringify(DOCS_MCP_SERVER)} under "mcpServers" yourself.`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const claudeFile = path.join(targetDir, 'CLAUDE.md');
|
|
39
|
+
if (args.force || readFileNoFollow(targetDir, claudeFile) === null) {
|
|
40
|
+
writeFileNoFollow(targetDir, claudeFile, fs.readFileSync(path.join(templatesDir(), 'agents-claude.md.tmpl'), 'utf8'));
|
|
41
|
+
created.push('CLAUDE.md');
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
skipped.push({
|
|
45
|
+
file: 'CLAUDE.md',
|
|
46
|
+
reason: 'it already exists',
|
|
47
|
+
hint: 'Point it at the build-agent and ekanos-platform skills, or re-run with --force to replace it.',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const rows = [
|
|
51
|
+
['Created', created.length > 0 ? created : ['nothing new']],
|
|
52
|
+
...(skipped.length > 0
|
|
53
|
+
? [
|
|
54
|
+
['Kept', skipped.map((entry) => `${entry.file} (${entry.reason})`)],
|
|
55
|
+
]
|
|
56
|
+
: []),
|
|
57
|
+
];
|
|
58
|
+
return ctx.succeed({ dir: targetDir, created, skipped, mcpServer: mcp.outcome }, [
|
|
59
|
+
ctx.ui.result({ title: 'Ready to build agents', rows }),
|
|
60
|
+
ctx.ui.hint('Run "claude" here and describe the agent you want — e.g. "a support agent that triages new tickets".'),
|
|
61
|
+
].join('\n'));
|
|
62
|
+
}
|
|
63
|
+
/** Create `.mcp.json` with the docs server, or add it to one that lacks it. */
|
|
64
|
+
export function ensureDocsServer(targetDir) {
|
|
65
|
+
var _a;
|
|
66
|
+
const file = path.join(targetDir, '.mcp.json');
|
|
67
|
+
const existing = readFileNoFollow(targetDir, file);
|
|
68
|
+
if (existing === null) {
|
|
69
|
+
writeJson(targetDir, file, {
|
|
70
|
+
mcpServers: { [DOCS_MCP_SERVER_NAME]: DOCS_MCP_SERVER },
|
|
71
|
+
});
|
|
72
|
+
return { outcome: 'created' };
|
|
73
|
+
}
|
|
74
|
+
let parsed;
|
|
75
|
+
try {
|
|
76
|
+
parsed = JSON.parse(existing);
|
|
77
|
+
}
|
|
78
|
+
catch (_b) {
|
|
79
|
+
return { outcome: 'unreadable' };
|
|
80
|
+
}
|
|
81
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
82
|
+
return { outcome: 'unreadable' };
|
|
83
|
+
}
|
|
84
|
+
const config = parsed;
|
|
85
|
+
if ((_a = config.mcpServers) === null || _a === void 0 ? void 0 : _a[DOCS_MCP_SERVER_NAME])
|
|
86
|
+
return { outcome: 'present' };
|
|
87
|
+
writeJson(targetDir, file, Object.assign(Object.assign({}, config), { mcpServers: Object.assign(Object.assign({}, config.mcpServers), { [DOCS_MCP_SERVER_NAME]: DOCS_MCP_SERVER }) }));
|
|
88
|
+
return { outcome: 'merged' };
|
|
89
|
+
}
|
|
90
|
+
/** Whether this folder already has the docs server — `agents`/`catalog` suggest `agents init` when not. */
|
|
91
|
+
export function hasDocsServer(targetDir) {
|
|
92
|
+
var _a;
|
|
93
|
+
try {
|
|
94
|
+
const parsed = JSON.parse(fs.readFileSync(path.join(targetDir, '.mcp.json'), 'utf8'));
|
|
95
|
+
return Boolean((_a = parsed.mcpServers) === null || _a === void 0 ? void 0 : _a[DOCS_MCP_SERVER_NAME]);
|
|
96
|
+
}
|
|
97
|
+
catch (_b) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function writeJson(root, file, value) {
|
|
102
|
+
writeFileNoFollow(root, file, `${JSON.stringify(value, null, 2)}\n`);
|
|
103
|
+
}
|
|
104
|
+
/** Suggest `ekanos agents init` (skills + the docs MCP server) where this folder lacks it. */
|
|
105
|
+
export function withDocsHint(ui, dir, summary) {
|
|
106
|
+
if (hasDocsServer(dir))
|
|
107
|
+
return summary;
|
|
108
|
+
return [
|
|
109
|
+
summary,
|
|
110
|
+
ui.hint('Designing agents with Claude? "ekanos agents init" adds the build-agent skill and the Ekanos docs MCP server to this folder.'),
|
|
111
|
+
].join('\n');
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=agents-init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-init.js","sourceRoot":"","sources":["../../src/commands/agents-init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAoB,MAAM,QAAQ,CAAC;AAEjE,+FAA+F;AAC/F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,iBAAiB,EAAE,aAAa,CAAU,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,CAAC,CACf,CAAC;QAC9C,OAAO,OAAO,CAAC,MAAA,MAAM,CAAC,UAAU,0CAAG,oBAAoB,CAAC,CAAC,CAAC;IAC5D,CAAC;eAAO,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,IAAY,EAAE,IAAY,EAAE,KAAc;IAC3D,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACvE,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,YAAY,CAAC,EAAM,EAAE,GAAW,EAAE,OAAe;IAC/D,IAAI,aAAa,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC;IACvC,OAAO;QACL,OAAO;QACP,EAAE,CAAC,IAAI,CACL,8HAA8H,CAC/H;KACF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport type { CliContext } from '../context';\nimport type { ExitCode } from '../exit-codes';\nimport { readFileNoFollow, writeFileNoFollow } from '../safe-fs';\nimport { templatesDir } from '../templates';\nimport type { ResultRow, Ui } from '../ui';\nimport { copyBundledSkillTrees, type SkippedFile } from './init';\n\n/** The skills a folder that only manages agents needs — not the integration-authoring ones. */\nexport const AGENT_SKILLS = ['ekanos-platform', 'build-agent'] as const;\n\nexport const DOCS_MCP_SERVER_NAME = 'ekanos-sdk-docs';\nexport const DOCS_MCP_SERVER = {\n type: 'http',\n url: 'https://sdk.ekanos.dev/mcp',\n} as const;\n\nexport interface AgentsInitArgs {\n dir: string;\n force: boolean;\n}\n\n/**\n * `ekanos agents init` — make a folder ready for Claude to design agents: the\n * `ekanos-platform` and `build-agent` skills, the docs MCP server in\n * `.mcp.json`, and a short CLAUDE.md. Unlike `ekanos init` it scaffolds no\n * integration: an agent is data in Ekanos, not code in this folder. Local,\n * no session needed, and idempotent: existing files are kept (merged, for\n * `.mcp.json`) unless `--force`.\n */\nexport function runAgentsInit(ctx: CliContext, args: AgentsInitArgs): ExitCode {\n const targetDir = path.resolve(args.dir);\n fs.mkdirSync(targetDir, { recursive: true });\n\n const skills = copyBundledSkillTrees(\n targetDir,\n args.force,\n undefined,\n 'throw',\n AGENT_SKILLS,\n );\n const created = [...skills.created];\n const skipped: SkippedFile[] = [...skills.skipped];\n\n const mcp = ensureDocsServer(targetDir);\n if (mcp.outcome === 'created' || mcp.outcome === 'merged') {\n created.push('.mcp.json');\n } else if (mcp.outcome === 'unreadable') {\n skipped.push({\n file: '.mcp.json',\n reason: 'it is not valid JSON',\n hint: `Add \"${DOCS_MCP_SERVER_NAME}\": ${JSON.stringify(DOCS_MCP_SERVER)} under \"mcpServers\" yourself.`,\n });\n }\n\n const claudeFile = path.join(targetDir, 'CLAUDE.md');\n if (args.force || readFileNoFollow(targetDir, claudeFile) === null) {\n writeFileNoFollow(\n targetDir,\n claudeFile,\n fs.readFileSync(\n path.join(templatesDir(), 'agents-claude.md.tmpl'),\n 'utf8',\n ),\n );\n created.push('CLAUDE.md');\n } else {\n skipped.push({\n file: 'CLAUDE.md',\n reason: 'it already exists',\n hint: 'Point it at the build-agent and ekanos-platform skills, or re-run with --force to replace it.',\n });\n }\n\n const rows: ResultRow[] = [\n ['Created', created.length > 0 ? created : ['nothing new']],\n ...(skipped.length > 0\n ? ([\n ['Kept', skipped.map((entry) => `${entry.file} (${entry.reason})`)],\n ] as const)\n : []),\n ];\n return ctx.succeed(\n { dir: targetDir, created, skipped, mcpServer: mcp.outcome },\n [\n ctx.ui.result({ title: 'Ready to build agents', rows }),\n ctx.ui.hint(\n 'Run \"claude\" here and describe the agent you want — e.g. \"a support agent that triages new tickets\".',\n ),\n ].join('\\n'),\n );\n}\n\ntype DocsServerOutcome = 'created' | 'merged' | 'present' | 'unreadable';\n\n/** Create `.mcp.json` with the docs server, or add it to one that lacks it. */\nexport function ensureDocsServer(targetDir: string): {\n outcome: DocsServerOutcome;\n} {\n const file = path.join(targetDir, '.mcp.json');\n const existing = readFileNoFollow(targetDir, file);\n if (existing === null) {\n writeJson(targetDir, file, {\n mcpServers: { [DOCS_MCP_SERVER_NAME]: DOCS_MCP_SERVER },\n });\n return { outcome: 'created' };\n }\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(existing);\n } catch {\n return { outcome: 'unreadable' };\n }\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n return { outcome: 'unreadable' };\n }\n\n const config = parsed as { mcpServers?: Record<string, unknown> };\n if (config.mcpServers?.[DOCS_MCP_SERVER_NAME]) return { outcome: 'present' };\n writeJson(targetDir, file, {\n ...config,\n mcpServers: {\n ...config.mcpServers,\n [DOCS_MCP_SERVER_NAME]: DOCS_MCP_SERVER,\n },\n });\n return { outcome: 'merged' };\n}\n\n/** Whether this folder already has the docs server — `agents`/`catalog` suggest `agents init` when not. */\nexport function hasDocsServer(targetDir: string): boolean {\n try {\n const parsed = JSON.parse(\n fs.readFileSync(path.join(targetDir, '.mcp.json'), 'utf8'),\n ) as { mcpServers?: Record<string, unknown> };\n return Boolean(parsed.mcpServers?.[DOCS_MCP_SERVER_NAME]);\n } catch {\n return false;\n }\n}\n\nfunction writeJson(root: string, file: string, value: unknown): void {\n writeFileNoFollow(root, file, `${JSON.stringify(value, null, 2)}\\n`);\n}\n\n/** Suggest `ekanos agents init` (skills + the docs MCP server) where this folder lacks it. */\nexport function withDocsHint(ui: Ui, dir: string, summary: string): string {\n if (hasDocsServer(dir)) return summary;\n return [\n summary,\n ui.hint(\n 'Designing agents with Claude? \"ekanos agents init\" adds the build-agent skill and the Ekanos docs MCP server to this folder.',\n ),\n ].join('\\n');\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AgentTemplateBody } from '@ekanos/integration-schema';
|
|
2
2
|
import type { CliContext } from '../context.js';
|
|
3
3
|
import type { ExitCode } from '../exit-codes.js';
|
|
4
|
-
export declare const AGENTS_SUBCOMMANDS: readonly ['list', 'show', 'pull', 'apply', 'publish', 'rollback'];
|
|
4
|
+
export declare const AGENTS_SUBCOMMANDS: readonly ['init', 'list', 'show', 'pull', 'apply', 'publish', 'rollback'];
|
|
5
5
|
/** The file `pull` writes and `apply` reads, inside an agent's directory. */
|
|
6
6
|
export declare const AGENT_FILE = "agent.json";
|
|
7
7
|
/** Instructions as Markdown, beside it. Used when `agent.json` has none. */
|
|
@@ -18,6 +18,8 @@ export interface AgentsArgs {
|
|
|
18
18
|
overwrite: boolean;
|
|
19
19
|
out?: string;
|
|
20
20
|
yes: boolean;
|
|
21
|
+
/** `init`: replace the skills and CLAUDE.md even when they exist. */
|
|
22
|
+
force?: boolean;
|
|
21
23
|
dir: string;
|
|
22
24
|
env: Record<string, string | undefined>;
|
|
23
25
|
stdinIsTTY?: boolean;
|
package/dist/commands/agents.js
CHANGED
|
@@ -18,8 +18,10 @@ import { authRequiredError, notFoundError, usageError, validationError, } from '
|
|
|
18
18
|
import { classifyPath } from '../safe-fs.js';
|
|
19
19
|
import { resolveSourceTarget } from '../source-target.js';
|
|
20
20
|
import { pluralize } from '../ui.js';
|
|
21
|
+
import { runAgentsInit, withDocsHint } from './agents-init.js';
|
|
21
22
|
import { promptYesNo } from './publish.js';
|
|
22
23
|
export const AGENTS_SUBCOMMANDS = [
|
|
24
|
+
'init',
|
|
23
25
|
'list',
|
|
24
26
|
'show',
|
|
25
27
|
'pull',
|
|
@@ -40,8 +42,15 @@ export const AGENT_INSTRUCTIONS_FILE = 'AGENT.md';
|
|
|
40
42
|
* layout back.
|
|
41
43
|
*/
|
|
42
44
|
export async function runAgents(ctx, args) {
|
|
43
|
-
var _a, _b, _c;
|
|
45
|
+
var _a, _b, _c, _d;
|
|
44
46
|
const subcommand = parseSubcommand(args.subcommand);
|
|
47
|
+
// Local only: no host, no session.
|
|
48
|
+
if (subcommand === 'init') {
|
|
49
|
+
return runAgentsInit(ctx, {
|
|
50
|
+
dir: path.resolve(args.dir, (_a = args.target) !== null && _a !== void 0 ? _a : '.'),
|
|
51
|
+
force: args.force === true,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
45
54
|
// Read the local input before any network call, so a bad file fails fast.
|
|
46
55
|
const local = subcommand === 'apply' ? readAgentInput(args.target, args.dir) : null;
|
|
47
56
|
const env = resolveAuthEnvironment(ctx, args.host, args.env, {
|
|
@@ -53,7 +62,7 @@ export async function runAgents(ctx, args) {
|
|
|
53
62
|
switch (subcommand) {
|
|
54
63
|
case 'list': {
|
|
55
64
|
const list = await client.call((token) => listAgentTemplates(env.host, token, source));
|
|
56
|
-
return ctx.succeed(Object.assign({ host: env.host }, list), listSummary(ctx.ui, list));
|
|
65
|
+
return ctx.succeed(Object.assign({ host: env.host }, list), withDocsHint(ctx.ui, args.dir, listSummary(ctx.ui, list)));
|
|
57
66
|
}
|
|
58
67
|
case 'show': {
|
|
59
68
|
const key = requireKey(args.target, 'show');
|
|
@@ -63,7 +72,7 @@ export async function runAgents(ctx, args) {
|
|
|
63
72
|
case 'pull': {
|
|
64
73
|
const key = requireKey(args.target, 'pull');
|
|
65
74
|
const shown = await client.call((token) => showAgentTemplate(env.host, token, source, key));
|
|
66
|
-
const outDir = path.resolve(args.dir, (
|
|
75
|
+
const outDir = path.resolve(args.dir, (_b = args.out) !== null && _b !== void 0 ? _b : path.join('agents', key));
|
|
67
76
|
const written = writeAgentFiles(outDir, shown.template);
|
|
68
77
|
return ctx.succeed({
|
|
69
78
|
host: env.host,
|
|
@@ -80,7 +89,7 @@ export async function runAgents(ctx, args) {
|
|
|
80
89
|
}
|
|
81
90
|
case 'apply': {
|
|
82
91
|
const input = local;
|
|
83
|
-
const baseVersion = (
|
|
92
|
+
const baseVersion = (_c = parseVersionFlag(args.baseVersion, '--base-version')) !== null && _c !== void 0 ? _c : input.baseVersion;
|
|
84
93
|
const result = await client.call((token) => applyAgentTemplate(env.host, token, {
|
|
85
94
|
source,
|
|
86
95
|
key: input.key,
|
|
@@ -96,7 +105,7 @@ export async function runAgents(ctx, args) {
|
|
|
96
105
|
case 'publish':
|
|
97
106
|
case 'rollback': {
|
|
98
107
|
const key = requireKey(args.target, subcommand);
|
|
99
|
-
let version = (
|
|
108
|
+
let version = (_d = parseVersionFlag(args.to, '--to')) !== null && _d !== void 0 ? _d : undefined;
|
|
100
109
|
if (subcommand === 'rollback' && version === undefined) {
|
|
101
110
|
throw usageError('rollback needs the version to go back to.', `Pass "--to <n>". "ekanos agents show ${key}" lists them.`);
|
|
102
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAEL,uBAAuB,EAEvB,sBAAsB,GAGvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAEL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAA2B,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,SAAS;IACT,UAAU;CACF,CAAC;AAIX,6EAA6E;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CA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M,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,GAAG,EAAE;QAC1D,IAAI,EAAE,MAAM,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;QACpD,IAAI;QACJ,KAAK;KACN,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type AgentTemplateBody,\n AgentTemplateBodySchema,\n type AgentTemplateDetail,\n AgentTemplateKeySchema,\n type AgentTemplateList,\n type AgentTemplateResult,\n} from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport {\n type AgentsApiResult,\n applyAgentTemplate,\n listAgentTemplates,\n publishAgentTemplate,\n showAgentTemplate,\n} from '../agents-api';\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 authRequiredError,\n notFoundError,\n usageError,\n validationError,\n} from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { classifyPath } from '../safe-fs';\nimport { resolveSourceTarget } from '../source-target';\nimport { type ResultRow, type Ui, pluralize } from '../ui';\nimport { promptYesNo } from './publish';\n\nexport const AGENTS_SUBCOMMANDS = [\n 'list',\n 'show',\n 'pull',\n 'apply',\n 'publish',\n 'rollback',\n] as const;\n\ntype AgentsSubcommand = (typeof AGENTS_SUBCOMMANDS)[number];\n\n/** The file `pull` writes and `apply` reads, inside an agent's directory. */\nexport const AGENT_FILE = 'agent.json';\n/** Instructions as Markdown, beside it. Used when `agent.json` has none. */\nexport const AGENT_INSTRUCTIONS_FILE = 'AGENT.md';\n\nexport interface AgentsArgs {\n host?: string;\n source?: string;\n subcommand?: string;\n /** A template key, or for `apply` a file or directory. */\n target?: string;\n /** `publish` / `rollback`: the version to make the one teams run. */\n to?: string;\n baseVersion?: string;\n overwrite: boolean;\n out?: string;\n yes: boolean;\n dir: string;\n env: Record<string, string | undefined>;\n stdinIsTTY?: boolean;\n confirm?: (question: string) => Promise<boolean>;\n}\n\n/**\n * `agents` — the Source's agent templates (plan 239.0 / 239.2). Ekanos holds\n * them; nothing here is deployed. `apply` stores a new version (a draft\n * until published), `publish` makes a version the one every team runs,\n * `rollback` publishes an older one. `pull` writes a template out as\n * `agent.json` + `AGENT.md` for review or Git, and `apply` reads the same\n * layout back.\n */\nexport async function runAgents(\n ctx: CliContext,\n args: AgentsArgs,\n): Promise<ExitCode> {\n const subcommand = parseSubcommand(args.subcommand);\n\n // Read the local input before any network call, so a bad file fails fast.\n const local =\n subcommand === 'apply' ? readAgentInput(args.target, args.dir) : null;\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(\n env,\n requireSession(env.store, env.host),\n args,\n );\n const client = new AgentsClient(env, resolved.session);\n const source = resolved.source;\n\n switch (subcommand) {\n case 'list': {\n const list = await client.call((token) =>\n listAgentTemplates(env.host, token, source),\n );\n return ctx.succeed(\n { host: env.host, ...list },\n listSummary(ctx.ui, list),\n );\n }\n case 'show': {\n const key = requireKey(args.target, 'show');\n const shown = await client.call((token) =>\n showAgentTemplate(env.host, token, source, key),\n );\n return ctx.succeed(\n { host: env.host, ...shown },\n templateDetail(ctx.ui, shown.template),\n );\n }\n case 'pull': {\n const key = requireKey(args.target, 'pull');\n const shown = await client.call((token) =>\n showAgentTemplate(env.host, token, source, key),\n );\n const outDir = path.resolve(\n args.dir,\n args.out ?? path.join('agents', key),\n );\n const written = writeAgentFiles(outDir, shown.template);\n return ctx.succeed(\n {\n host: env.host,\n key,\n version: shown.template.latestVersion,\n files: written,\n },\n ctx.ui.result({\n title: `Pulled ${key} v${shown.template.latestVersion}`,\n rows: written.map((file): ResultRow => ['Wrote', file]),\n notes: [\n `Edit, then \"ekanos agents apply ${path.relative(args.dir, outDir) || '.'}\".`,\n ],\n }),\n );\n }\n case 'apply': {\n const input = local!;\n const baseVersion =\n parseVersionFlag(args.baseVersion, '--base-version') ??\n input.baseVersion;\n const result = await client.call((token) =>\n applyAgentTemplate(env.host, token, {\n source,\n key: input.key,\n body: input.body,\n baseVersion,\n overwrite: args.overwrite,\n }),\n );\n if (input.file && result.outcome !== 'unchanged') {\n recordBaseVersion(input.file, result.version);\n }\n return ctx.succeed(\n { host: env.host, ...result },\n resultSummary(ctx.ui, result),\n );\n }\n case 'publish':\n case 'rollback': {\n const key = requireKey(args.target, subcommand);\n let version = parseVersionFlag(args.to, '--to') ?? undefined;\n if (subcommand === 'rollback' && version === undefined) {\n throw usageError(\n 'rollback needs the version to go back to.',\n `Pass \"--to <n>\". \"ekanos agents show ${key}\" lists them.`,\n );\n }\n // Refuse a script with no --yes before reading anything.\n if (!args.yes && !canPrompt(ctx, args)) {\n throw validationError(\n `${subcommand === 'rollback' ? 'Rolling back' : 'Publishing'} ${key} on ${source} needs confirmation.`,\n 'It reaches every team running this agent at once. Pass --yes to confirm.',\n );\n }\n // Publish names the version it confirmed, never \"whatever is latest\n // when the request lands\" — a draft applied in between is not shipped\n // unseen to every team.\n if (version === undefined) {\n const shown = await client.call((token) =>\n showAgentTemplate(env.host, token, source, key),\n );\n version = shown.template.latestVersion;\n }\n await confirmPublish(ctx, args, {\n key,\n source,\n what:\n subcommand === 'rollback'\n ? `Roll ${key} back to version ${version}`\n : `Publish ${key} version ${version}`,\n });\n const result = await client.call((token) =>\n publishAgentTemplate(env.host, token, subcommand, {\n source,\n key,\n version,\n }),\n );\n return ctx.succeed(\n { host: env.host, ...result },\n resultSummary(ctx.ui, result),\n );\n }\n }\n}\n\n/** Every call refreshes the session once on a 401, then gives up. */\nclass AgentsClient {\n constructor(\n private readonly env: AuthEnvironment,\n private session: StoredSession,\n ) {}\n\n async call<T>(\n send: (accessToken: string) => Promise<AgentsApiResult<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 agents call.`,\n `Run \"ekanos login --host ${this.env.host}\" and retry.`,\n );\n }\n}\n\nfunction parseSubcommand(value: string | undefined): AgentsSubcommand {\n const match = AGENTS_SUBCOMMANDS.find((name) => name === value);\n if (match) return match;\n throw usageError(\n value\n ? `Unknown agents subcommand \"${value}\".`\n : 'agents needs a subcommand.',\n `Run one of: ${AGENTS_SUBCOMMANDS.map((name) => `ekanos agents ${name}`).join(', ')}.`,\n );\n}\n\nfunction requireKey(value: string | undefined, verb: string): string {\n const parsed = AgentTemplateKeySchema.safeParse(value ?? '');\n if (parsed.success) return parsed.data;\n throw usageError(\n value\n ? `\"${value}\" is not an agent key.`\n : `agents ${verb} needs an agent key.`,\n `Pass the key, e.g. \"ekanos agents ${verb} support-triage\". ` +\n `\"ekanos agents list\" shows them.`,\n );\n}\n\nfunction parseVersionFlag(\n value: string | undefined,\n flag: string,\n): number | null {\n if (value === undefined) return null;\n const version = Number(value);\n if (Number.isInteger(version) && version >= 1) return version;\n throw usageError(\n `${flag} must be a version number (got \"${value}\").`,\n `\"ekanos agents show <key>\" lists the versions.`,\n );\n}\n\ninterface AgentInput {\n key: string;\n body: AgentTemplateBody;\n baseVersion: number | null;\n /** The agent.json read, when there was one, so the new version is recorded in it. */\n file: string | null;\n}\n\n/**\n * Read `apply`'s input: a directory holding `agent.json` (and optionally\n * `AGENT.md`), or a `.json` file. The key is the file's `key`, else the\n * directory's name. `baseVersion` in the file is the version it was pulled\n * or last applied at — what the host checks for a concurrent change.\n */\nexport function readAgentInput(\n target: string | undefined,\n cwd: string,\n): AgentInput {\n if (!target) {\n throw usageError(\n 'agents apply needs a file or directory.',\n `Pass an agent directory (\"ekanos agents apply agents/support\") or a ` +\n `JSON file. \"ekanos agents pull <key>\" writes the layout.`,\n );\n }\n const resolved = path.resolve(cwd, target);\n const kind = classifyPath(resolved);\n const dir = kind === 'directory' ? resolved : path.dirname(resolved);\n const file =\n kind === 'directory' ? path.join(resolved, AGENT_FILE) : resolved;\n\n if (classifyPath(file) !== 'file') {\n throw notFoundError(\n `No ${kind === 'directory' ? AGENT_FILE : 'file'} at ${file}.`,\n `\"ekanos agents pull <key>\" writes ${AGENT_FILE} and ${AGENT_INSTRUCTIONS_FILE}.`,\n );\n }\n\n let raw: unknown;\n try {\n raw = JSON.parse(fs.readFileSync(file, 'utf8'));\n } catch (error) {\n throw validationError(\n `${file} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,\n 'Fix the JSON and apply again.',\n );\n }\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {\n throw validationError(\n `${file} must hold a JSON object.`,\n 'See \"ekanos agents --help\".',\n );\n }\n\n const {\n key: rawKey,\n baseVersion: rawBase,\n $schema: _schema,\n ...rest\n } = raw as Record<string, unknown>;\n const fields: Record<string, unknown> = { ...rest };\n\n const instructionsFile = path.join(dir, AGENT_INSTRUCTIONS_FILE);\n if (\n fields.instructions === undefined &&\n classifyPath(instructionsFile) === 'file'\n ) {\n fields.instructions = fs.readFileSync(instructionsFile, 'utf8');\n }\n\n const key = AgentTemplateKeySchema.safeParse(\n typeof rawKey === 'string' ? rawKey : path.basename(dir),\n );\n if (!key.success) {\n throw validationError(\n `No usable agent key: set \"key\" in ${file}, or name the directory after it.`,\n key.error.issues[0]?.message ??\n 'Use lowercase letters, digits and hyphens.',\n );\n }\n\n const body = AgentTemplateBodySchema.safeParse(fields);\n if (!body.success) {\n throw validationError(\n [\n `${file} is not a valid agent:`,\n ...body.error.issues.map(\n (issue) => ` ${issue.path.join('.') || '(root)'}: ${issue.message}`,\n ),\n ].join('\\n'),\n `Fields: name, description, instructions (or ${AGENT_INSTRUCTIONS_FILE}), ` +\n `model, maxTurns, tools, policy, skills.`,\n );\n }\n\n const baseVersion =\n typeof rawBase === 'number' && Number.isInteger(rawBase) && rawBase >= 1\n ? rawBase\n : null;\n\n return { key: key.data, body: body.data, baseVersion, file };\n}\n\n/**\n * Write `agent.json` + `AGENT.md`. The instructions live in the Markdown so\n * they read and diff as prose; the JSON holds everything else plus the\n * version they came from.\n */\nfunction writeAgentFiles(\n outDir: string,\n template: AgentTemplateDetail,\n): string[] {\n fs.mkdirSync(outDir, { recursive: true });\n const { instructions, ...rest } = template.body;\n const json = {\n key: template.key,\n baseVersion: template.latestVersion,\n ...rest,\n };\n const jsonPath = path.join(outDir, AGENT_FILE);\n const mdPath = path.join(outDir, AGENT_INSTRUCTIONS_FILE);\n for (const target of [jsonPath, mdPath]) {\n const kind = classifyPath(target);\n if (kind !== 'missing' && kind !== 'file') {\n throw validationError(\n `Refusing to write through ${target} (${kind}).`,\n 'Remove it, or pass --out <dir>.',\n );\n }\n }\n fs.writeFileSync(jsonPath, `${JSON.stringify(json, null, 2)}\\n`);\n fs.writeFileSync(\n mdPath,\n instructions.endsWith('\\n') ? instructions : `${instructions}\\n`,\n );\n return [jsonPath, mdPath];\n}\n\n/** After a stored version, point the file at it, so the next apply is based on it. */\nfunction recordBaseVersion(file: string, version: number) {\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Record<\n string,\n unknown\n >;\n if (raw.baseVersion === version) return;\n const { key, baseVersion: _old, ...rest } = raw;\n const next =\n key === undefined\n ? { baseVersion: version, ...rest }\n : { key, baseVersion: version, ...rest };\n fs.writeFileSync(file, `${JSON.stringify(next, null, 2)}\\n`);\n}\n\nfunction canPrompt(ctx: CliContext, args: AgentsArgs): boolean {\n return !ctx.jsonMode && (args.stdinIsTTY ?? process.stdin.isTTY === true);\n}\n\n/**\n * Publishing changes what every team running the agent does, at once. A\n * human run asks first; a scripted or JSON run needs `--yes`.\n */\nasync function confirmPublish(\n ctx: CliContext,\n args: AgentsArgs,\n target: { key: string; source: string; what: string },\n) {\n if (args.yes) return;\n if (!canPrompt(ctx, args)) {\n throw validationError(\n `${target.what} on ${target.source} needs confirmation.`,\n 'It reaches every team running this agent at once. Pass --yes to confirm.',\n );\n }\n ctx.log(\n `${target.what} on ${target.source}. Every team running it follows at once.`,\n );\n const confirmed = await (args.confirm ?? promptYesNo)('Proceed? [y/N]');\n if (!confirmed) {\n throw validationError(\n `${target.what} was not confirmed.`,\n 'Nothing was changed.',\n );\n }\n}\n\nfunction versionLabel(template: {\n latestVersion: number;\n publishedVersion: number | null;\n}): string {\n if (template.publishedVersion === null)\n return `v${template.latestVersion} draft, never published`;\n if (template.publishedVersion === template.latestVersion)\n return `v${template.latestVersion} published`;\n return `v${template.publishedVersion} published, v${template.latestVersion} latest`;\n}\n\nfunction listSummary(ui: Ui, list: AgentTemplateList): string {\n if (list.templates.length === 0) {\n return ui.result({\n title: `No agents on ${list.source.slug} yet`,\n tone: 'warn',\n notes: ['\"ekanos agents apply <dir>\" stores the first one.'],\n });\n }\n return [\n ui.result({\n title: `${pluralize(list.templates.length, 'agent')} on ${list.source.slug}`,\n rows: list.templates.map((template): ResultRow => [\n template.key,\n [\n template.name,\n versionLabel(template),\n template.status === 'archived' ? 'archived' : null,\n template.teams\n ? `${pluralize(template.teams.enabled, 'team')}`\n : null,\n ]\n .filter(Boolean)\n .join(' · '),\n ]),\n }),\n ui.hint('\"ekanos agents show <key>\" shows one, with its versions.'),\n ].join('\\n\\n');\n}\n\nfunction templateDetail(ui: Ui, template: AgentTemplateDetail): string {\n const { body } = template;\n const rows: ResultRow[] = [\n ['Versions', versionLabel(template)],\n ['Model', body.model ?? 'house default'],\n ['Tools', describeTools(body)],\n [\n 'Approval',\n `reads ${body.policy.reads}, writes ${body.policy.writes}` +\n (Object.keys(body.policy.overrides).length > 0\n ? `, ${pluralize(Object.keys(body.policy.overrides).length, 'override')}`\n : ''),\n ],\n ['Skills', body.skills.length > 0 ? body.skills.join(', ') : 'none'],\n ['Connections', describeConnections(body)],\n ['Teams may add', describeCustomization(body)],\n ];\n if (template.teams) {\n rows.push([\n 'Teams',\n `${template.teams.enabled} running` +\n (template.teams.pinned > 0\n ? `, ${template.teams.pinned} pinned to an older version`\n : ''),\n ]);\n }\n rows.push([\n 'History',\n template.versions.map(\n (version) =>\n `v${version.version} ${version.createdAt.slice(0, 10)}` +\n (version.createdBy ? ` by ${version.createdBy}` : '') +\n (version.publishedAt\n ? ` · published ${version.publishedAt.slice(0, 10)}`\n : ''),\n ),\n ]);\n return ui.result({ title: `${body.name} (${template.key})`, rows });\n}\n\nfunction describeConnections(body: AgentTemplateBody): string[] {\n const owner = (connection: AgentTemplateBody['connections'][string]) =>\n connection.owner === 'source'\n ? 'one connection for the source'\n : `each team's own (${connection.team})`;\n const lines = [\n ...Object.entries(body.connections).map(\n ([slug, connection]) => `${slug}: ${owner(connection)}`,\n ),\n ...body.mcpServers.map(\n (server) => `${server.key} (MCP, ${server.url}): ${owner(server)}`,\n ),\n ];\n return lines.length > 0 ? lines : [\"each team's own (optional)\"];\n}\n\nfunction describeCustomization(body: AgentTemplateBody): string {\n const allowed = Object.entries(body.teamCustomization)\n .filter(([, on]) => on)\n .map(([knob]) => CUSTOMIZATION_LABEL[knob] ?? knob);\n return allowed.length > 0 ? allowed.join(', ') : 'nothing (template only)';\n}\n\nconst CUSTOMIZATION_LABEL: Record<string, string> = {\n mcpServers: 'own MCP servers',\n skills: 'own skills',\n integrations: 'more integrations',\n narrow: 'narrower tools',\n};\n\nfunction describeTools(body: AgentTemplateBody): string {\n if (body.tools.mode === 'read_only')\n return 'every read the team has connected';\n if (body.tools.mode === 'all') return 'every tool the team has connected';\n return (\n [...(body.tools.products ?? []), ...(body.tools.tools ?? [])].join(', ') ||\n 'none'\n );\n}\n\nconst OUTCOME_TITLE = {\n created: 'Created',\n updated: 'Stored a new version',\n unchanged: 'Unchanged',\n published: 'Published',\n 'rolled-back': 'Rolled back',\n} as const;\n\nfunction resultSummary(ui: Ui, result: AgentTemplateResult): string {\n const { template } = result;\n const rows: ResultRow[] = [['Versions', versionLabel(template)]];\n if (result.outcome === 'published' || result.outcome === 'rolled-back') {\n rows.push(['Teams updated', String(result.teamsUpdated)]);\n }\n const notes =\n (result.outcome === 'created' || result.outcome === 'updated') &&\n template.publishedVersion !== template.latestVersion\n ? [\n `Teams still run the published version. \"ekanos agents publish ${template.key}\" moves them.`,\n ]\n : [];\n return ui.result({\n title: `${OUTCOME_TITLE[result.outcome]}: ${template.key}`,\n tone: result.outcome === 'unchanged' ? 'warn' : 'ok',\n rows,\n notes,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAEL,uBAAuB,EAEvB,sBAAsB,GAGvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAEL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAEL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAA2B,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,SAAS;IACT,UAAU;CACF,CAAC;AAIX,6EAA6E;AAC7E,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AACvC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAAC;AAsBlD;;;;;;;GAO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M,CAAC,OAAO,KAAK,SAAS,CAAC;QAC9D,QAAQ,CAAC,gBAAgB,KAAK,QAAQ,CAAC,aAAa;QAClD,CAAC,CAAC;YACE,iEAAiE,QAAQ,CAAC,GAAG,eAAe;SAC7F;QACH,CAAC,CAAC,EAAE,CAAC;IACT,OAAO,EAAE,CAAC,MAAM,CAAC;QACf,KAAK,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,GAAG,EAAE;QAC1D,IAAI,EAAE,MAAM,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI;QACpD,IAAI;QACJ,KAAK;KACN,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n type AgentTemplateBody,\n AgentTemplateBodySchema,\n type AgentTemplateDetail,\n AgentTemplateKeySchema,\n type AgentTemplateList,\n type AgentTemplateResult,\n} from '@ekanos/integration-schema';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nimport {\n type AgentsApiResult,\n applyAgentTemplate,\n listAgentTemplates,\n publishAgentTemplate,\n showAgentTemplate,\n} from '../agents-api';\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 authRequiredError,\n notFoundError,\n usageError,\n validationError,\n} from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { classifyPath } from '../safe-fs';\nimport { resolveSourceTarget } from '../source-target';\nimport { type ResultRow, type Ui, pluralize } from '../ui';\nimport { runAgentsInit, withDocsHint } from './agents-init';\nimport { promptYesNo } from './publish';\n\nexport const AGENTS_SUBCOMMANDS = [\n 'init',\n 'list',\n 'show',\n 'pull',\n 'apply',\n 'publish',\n 'rollback',\n] as const;\n\ntype AgentsSubcommand = (typeof AGENTS_SUBCOMMANDS)[number];\n\n/** The file `pull` writes and `apply` reads, inside an agent's directory. */\nexport const AGENT_FILE = 'agent.json';\n/** Instructions as Markdown, beside it. Used when `agent.json` has none. */\nexport const AGENT_INSTRUCTIONS_FILE = 'AGENT.md';\n\nexport interface AgentsArgs {\n host?: string;\n source?: string;\n subcommand?: string;\n /** A template key, or for `apply` a file or directory. */\n target?: string;\n /** `publish` / `rollback`: the version to make the one teams run. */\n to?: string;\n baseVersion?: string;\n overwrite: boolean;\n out?: string;\n yes: boolean;\n /** `init`: replace the skills and CLAUDE.md even when they exist. */\n force?: boolean;\n dir: string;\n env: Record<string, string | undefined>;\n stdinIsTTY?: boolean;\n confirm?: (question: string) => Promise<boolean>;\n}\n\n/**\n * `agents` — the Source's agent templates (plan 239.0 / 239.2). Ekanos holds\n * them; nothing here is deployed. `apply` stores a new version (a draft\n * until published), `publish` makes a version the one every team runs,\n * `rollback` publishes an older one. `pull` writes a template out as\n * `agent.json` + `AGENT.md` for review or Git, and `apply` reads the same\n * layout back.\n */\nexport async function runAgents(\n ctx: CliContext,\n args: AgentsArgs,\n): Promise<ExitCode> {\n const subcommand = parseSubcommand(args.subcommand);\n\n // Local only: no host, no session.\n if (subcommand === 'init') {\n return runAgentsInit(ctx, {\n dir: path.resolve(args.dir, args.target ?? '.'),\n force: args.force === true,\n });\n }\n\n // Read the local input before any network call, so a bad file fails fast.\n const local =\n subcommand === 'apply' ? readAgentInput(args.target, args.dir) : null;\n\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n const resolved = await resolveSourceTarget(\n env,\n requireSession(env.store, env.host),\n args,\n );\n const client = new AgentsClient(env, resolved.session);\n const source = resolved.source;\n\n switch (subcommand) {\n case 'list': {\n const list = await client.call((token) =>\n listAgentTemplates(env.host, token, source),\n );\n return ctx.succeed(\n { host: env.host, ...list },\n withDocsHint(ctx.ui, args.dir, listSummary(ctx.ui, list)),\n );\n }\n case 'show': {\n const key = requireKey(args.target, 'show');\n const shown = await client.call((token) =>\n showAgentTemplate(env.host, token, source, key),\n );\n return ctx.succeed(\n { host: env.host, ...shown },\n templateDetail(ctx.ui, shown.template),\n );\n }\n case 'pull': {\n const key = requireKey(args.target, 'pull');\n const shown = await client.call((token) =>\n showAgentTemplate(env.host, token, source, key),\n );\n const outDir = path.resolve(\n args.dir,\n args.out ?? path.join('agents', key),\n );\n const written = writeAgentFiles(outDir, shown.template);\n return ctx.succeed(\n {\n host: env.host,\n key,\n version: shown.template.latestVersion,\n files: written,\n },\n ctx.ui.result({\n title: `Pulled ${key} v${shown.template.latestVersion}`,\n rows: written.map((file): ResultRow => ['Wrote', file]),\n notes: [\n `Edit, then \"ekanos agents apply ${path.relative(args.dir, outDir) || '.'}\".`,\n ],\n }),\n );\n }\n case 'apply': {\n const input = local!;\n const baseVersion =\n parseVersionFlag(args.baseVersion, '--base-version') ??\n input.baseVersion;\n const result = await client.call((token) =>\n applyAgentTemplate(env.host, token, {\n source,\n key: input.key,\n body: input.body,\n baseVersion,\n overwrite: args.overwrite,\n }),\n );\n if (input.file && result.outcome !== 'unchanged') {\n recordBaseVersion(input.file, result.version);\n }\n return ctx.succeed(\n { host: env.host, ...result },\n resultSummary(ctx.ui, result),\n );\n }\n case 'publish':\n case 'rollback': {\n const key = requireKey(args.target, subcommand);\n let version = parseVersionFlag(args.to, '--to') ?? undefined;\n if (subcommand === 'rollback' && version === undefined) {\n throw usageError(\n 'rollback needs the version to go back to.',\n `Pass \"--to <n>\". \"ekanos agents show ${key}\" lists them.`,\n );\n }\n // Refuse a script with no --yes before reading anything.\n if (!args.yes && !canPrompt(ctx, args)) {\n throw validationError(\n `${subcommand === 'rollback' ? 'Rolling back' : 'Publishing'} ${key} on ${source} needs confirmation.`,\n 'It reaches every team running this agent at once. Pass --yes to confirm.',\n );\n }\n // Publish names the version it confirmed, never \"whatever is latest\n // when the request lands\" — a draft applied in between is not shipped\n // unseen to every team.\n if (version === undefined) {\n const shown = await client.call((token) =>\n showAgentTemplate(env.host, token, source, key),\n );\n version = shown.template.latestVersion;\n }\n await confirmPublish(ctx, args, {\n key,\n source,\n what:\n subcommand === 'rollback'\n ? `Roll ${key} back to version ${version}`\n : `Publish ${key} version ${version}`,\n });\n const result = await client.call((token) =>\n publishAgentTemplate(env.host, token, subcommand, {\n source,\n key,\n version,\n }),\n );\n return ctx.succeed(\n { host: env.host, ...result },\n resultSummary(ctx.ui, result),\n );\n }\n }\n}\n\n/** Every call refreshes the session once on a 401, then gives up. */\nclass AgentsClient {\n constructor(\n private readonly env: AuthEnvironment,\n private session: StoredSession,\n ) {}\n\n async call<T>(\n send: (accessToken: string) => Promise<AgentsApiResult<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 agents call.`,\n `Run \"ekanos login --host ${this.env.host}\" and retry.`,\n );\n }\n}\n\nfunction parseSubcommand(value: string | undefined): AgentsSubcommand {\n const match = AGENTS_SUBCOMMANDS.find((name) => name === value);\n if (match) return match;\n throw usageError(\n value\n ? `Unknown agents subcommand \"${value}\".`\n : 'agents needs a subcommand.',\n `Run one of: ${AGENTS_SUBCOMMANDS.map((name) => `ekanos agents ${name}`).join(', ')}.`,\n );\n}\n\nfunction requireKey(value: string | undefined, verb: string): string {\n const parsed = AgentTemplateKeySchema.safeParse(value ?? '');\n if (parsed.success) return parsed.data;\n throw usageError(\n value\n ? `\"${value}\" is not an agent key.`\n : `agents ${verb} needs an agent key.`,\n `Pass the key, e.g. \"ekanos agents ${verb} support-triage\". ` +\n `\"ekanos agents list\" shows them.`,\n );\n}\n\nfunction parseVersionFlag(\n value: string | undefined,\n flag: string,\n): number | null {\n if (value === undefined) return null;\n const version = Number(value);\n if (Number.isInteger(version) && version >= 1) return version;\n throw usageError(\n `${flag} must be a version number (got \"${value}\").`,\n `\"ekanos agents show <key>\" lists the versions.`,\n );\n}\n\ninterface AgentInput {\n key: string;\n body: AgentTemplateBody;\n baseVersion: number | null;\n /** The agent.json read, when there was one, so the new version is recorded in it. */\n file: string | null;\n}\n\n/**\n * Read `apply`'s input: a directory holding `agent.json` (and optionally\n * `AGENT.md`), or a `.json` file. The key is the file's `key`, else the\n * directory's name. `baseVersion` in the file is the version it was pulled\n * or last applied at — what the host checks for a concurrent change.\n */\nexport function readAgentInput(\n target: string | undefined,\n cwd: string,\n): AgentInput {\n if (!target) {\n throw usageError(\n 'agents apply needs a file or directory.',\n `Pass an agent directory (\"ekanos agents apply agents/support\") or a ` +\n `JSON file. \"ekanos agents pull <key>\" writes the layout.`,\n );\n }\n const resolved = path.resolve(cwd, target);\n const kind = classifyPath(resolved);\n const dir = kind === 'directory' ? resolved : path.dirname(resolved);\n const file =\n kind === 'directory' ? path.join(resolved, AGENT_FILE) : resolved;\n\n if (classifyPath(file) !== 'file') {\n throw notFoundError(\n `No ${kind === 'directory' ? AGENT_FILE : 'file'} at ${file}.`,\n `\"ekanos agents pull <key>\" writes ${AGENT_FILE} and ${AGENT_INSTRUCTIONS_FILE}.`,\n );\n }\n\n let raw: unknown;\n try {\n raw = JSON.parse(fs.readFileSync(file, 'utf8'));\n } catch (error) {\n throw validationError(\n `${file} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,\n 'Fix the JSON and apply again.',\n );\n }\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {\n throw validationError(\n `${file} must hold a JSON object.`,\n 'See \"ekanos agents --help\".',\n );\n }\n\n const {\n key: rawKey,\n baseVersion: rawBase,\n $schema: _schema,\n ...rest\n } = raw as Record<string, unknown>;\n const fields: Record<string, unknown> = { ...rest };\n\n const instructionsFile = path.join(dir, AGENT_INSTRUCTIONS_FILE);\n if (\n fields.instructions === undefined &&\n classifyPath(instructionsFile) === 'file'\n ) {\n fields.instructions = fs.readFileSync(instructionsFile, 'utf8');\n }\n\n const key = AgentTemplateKeySchema.safeParse(\n typeof rawKey === 'string' ? rawKey : path.basename(dir),\n );\n if (!key.success) {\n throw validationError(\n `No usable agent key: set \"key\" in ${file}, or name the directory after it.`,\n key.error.issues[0]?.message ??\n 'Use lowercase letters, digits and hyphens.',\n );\n }\n\n const body = AgentTemplateBodySchema.safeParse(fields);\n if (!body.success) {\n throw validationError(\n [\n `${file} is not a valid agent:`,\n ...body.error.issues.map(\n (issue) => ` ${issue.path.join('.') || '(root)'}: ${issue.message}`,\n ),\n ].join('\\n'),\n `Fields: name, description, instructions (or ${AGENT_INSTRUCTIONS_FILE}), ` +\n `model, maxTurns, tools, policy, skills.`,\n );\n }\n\n const baseVersion =\n typeof rawBase === 'number' && Number.isInteger(rawBase) && rawBase >= 1\n ? rawBase\n : null;\n\n return { key: key.data, body: body.data, baseVersion, file };\n}\n\n/**\n * Write `agent.json` + `AGENT.md`. The instructions live in the Markdown so\n * they read and diff as prose; the JSON holds everything else plus the\n * version they came from.\n */\nfunction writeAgentFiles(\n outDir: string,\n template: AgentTemplateDetail,\n): string[] {\n fs.mkdirSync(outDir, { recursive: true });\n const { instructions, ...rest } = template.body;\n const json = {\n key: template.key,\n baseVersion: template.latestVersion,\n ...rest,\n };\n const jsonPath = path.join(outDir, AGENT_FILE);\n const mdPath = path.join(outDir, AGENT_INSTRUCTIONS_FILE);\n for (const target of [jsonPath, mdPath]) {\n const kind = classifyPath(target);\n if (kind !== 'missing' && kind !== 'file') {\n throw validationError(\n `Refusing to write through ${target} (${kind}).`,\n 'Remove it, or pass --out <dir>.',\n );\n }\n }\n fs.writeFileSync(jsonPath, `${JSON.stringify(json, null, 2)}\\n`);\n fs.writeFileSync(\n mdPath,\n instructions.endsWith('\\n') ? instructions : `${instructions}\\n`,\n );\n return [jsonPath, mdPath];\n}\n\n/** After a stored version, point the file at it, so the next apply is based on it. */\nfunction recordBaseVersion(file: string, version: number) {\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Record<\n string,\n unknown\n >;\n if (raw.baseVersion === version) return;\n const { key, baseVersion: _old, ...rest } = raw;\n const next =\n key === undefined\n ? { baseVersion: version, ...rest }\n : { key, baseVersion: version, ...rest };\n fs.writeFileSync(file, `${JSON.stringify(next, null, 2)}\\n`);\n}\n\nfunction canPrompt(ctx: CliContext, args: AgentsArgs): boolean {\n return !ctx.jsonMode && (args.stdinIsTTY ?? process.stdin.isTTY === true);\n}\n\n/**\n * Publishing changes what every team running the agent does, at once. A\n * human run asks first; a scripted or JSON run needs `--yes`.\n */\nasync function confirmPublish(\n ctx: CliContext,\n args: AgentsArgs,\n target: { key: string; source: string; what: string },\n) {\n if (args.yes) return;\n if (!canPrompt(ctx, args)) {\n throw validationError(\n `${target.what} on ${target.source} needs confirmation.`,\n 'It reaches every team running this agent at once. Pass --yes to confirm.',\n );\n }\n ctx.log(\n `${target.what} on ${target.source}. Every team running it follows at once.`,\n );\n const confirmed = await (args.confirm ?? promptYesNo)('Proceed? [y/N]');\n if (!confirmed) {\n throw validationError(\n `${target.what} was not confirmed.`,\n 'Nothing was changed.',\n );\n }\n}\n\nfunction versionLabel(template: {\n latestVersion: number;\n publishedVersion: number | null;\n}): string {\n if (template.publishedVersion === null)\n return `v${template.latestVersion} draft, never published`;\n if (template.publishedVersion === template.latestVersion)\n return `v${template.latestVersion} published`;\n return `v${template.publishedVersion} published, v${template.latestVersion} latest`;\n}\n\nfunction listSummary(ui: Ui, list: AgentTemplateList): string {\n if (list.templates.length === 0) {\n return ui.result({\n title: `No agents on ${list.source.slug} yet`,\n tone: 'warn',\n notes: ['\"ekanos agents apply <dir>\" stores the first one.'],\n });\n }\n return [\n ui.result({\n title: `${pluralize(list.templates.length, 'agent')} on ${list.source.slug}`,\n rows: list.templates.map((template): ResultRow => [\n template.key,\n [\n template.name,\n versionLabel(template),\n template.status === 'archived' ? 'archived' : null,\n template.teams\n ? `${pluralize(template.teams.enabled, 'team')}`\n : null,\n ]\n .filter(Boolean)\n .join(' · '),\n ]),\n }),\n ui.hint('\"ekanos agents show <key>\" shows one, with its versions.'),\n ].join('\\n\\n');\n}\n\nfunction templateDetail(ui: Ui, template: AgentTemplateDetail): string {\n const { body } = template;\n const rows: ResultRow[] = [\n ['Versions', versionLabel(template)],\n ['Model', body.model ?? 'house default'],\n ['Tools', describeTools(body)],\n [\n 'Approval',\n `reads ${body.policy.reads}, writes ${body.policy.writes}` +\n (Object.keys(body.policy.overrides).length > 0\n ? `, ${pluralize(Object.keys(body.policy.overrides).length, 'override')}`\n : ''),\n ],\n ['Skills', body.skills.length > 0 ? body.skills.join(', ') : 'none'],\n ['Connections', describeConnections(body)],\n ['Teams may add', describeCustomization(body)],\n ];\n if (template.teams) {\n rows.push([\n 'Teams',\n `${template.teams.enabled} running` +\n (template.teams.pinned > 0\n ? `, ${template.teams.pinned} pinned to an older version`\n : ''),\n ]);\n }\n rows.push([\n 'History',\n template.versions.map(\n (version) =>\n `v${version.version} ${version.createdAt.slice(0, 10)}` +\n (version.createdBy ? ` by ${version.createdBy}` : '') +\n (version.publishedAt\n ? ` · published ${version.publishedAt.slice(0, 10)}`\n : ''),\n ),\n ]);\n return ui.result({ title: `${body.name} (${template.key})`, rows });\n}\n\nfunction describeConnections(body: AgentTemplateBody): string[] {\n const owner = (connection: AgentTemplateBody['connections'][string]) =>\n connection.owner === 'source'\n ? 'one connection for the source'\n : `each team's own (${connection.team})`;\n const lines = [\n ...Object.entries(body.connections).map(\n ([slug, connection]) => `${slug}: ${owner(connection)}`,\n ),\n ...body.mcpServers.map(\n (server) => `${server.key} (MCP, ${server.url}): ${owner(server)}`,\n ),\n ];\n return lines.length > 0 ? lines : [\"each team's own (optional)\"];\n}\n\nfunction describeCustomization(body: AgentTemplateBody): string {\n const allowed = Object.entries(body.teamCustomization)\n .filter(([, on]) => on)\n .map(([knob]) => CUSTOMIZATION_LABEL[knob] ?? knob);\n return allowed.length > 0 ? allowed.join(', ') : 'nothing (template only)';\n}\n\nconst CUSTOMIZATION_LABEL: Record<string, string> = {\n mcpServers: 'own MCP servers',\n skills: 'own skills',\n integrations: 'more integrations',\n narrow: 'narrower tools',\n};\n\nfunction describeTools(body: AgentTemplateBody): string {\n if (body.tools.mode === 'read_only')\n return 'every read the team has connected';\n if (body.tools.mode === 'all') return 'every tool the team has connected';\n return (\n [...(body.tools.products ?? []), ...(body.tools.tools ?? [])].join(', ') ||\n 'none'\n );\n}\n\nconst OUTCOME_TITLE = {\n created: 'Created',\n updated: 'Stored a new version',\n unchanged: 'Unchanged',\n published: 'Published',\n 'rolled-back': 'Rolled back',\n} as const;\n\nfunction resultSummary(ui: Ui, result: AgentTemplateResult): string {\n const { template } = result;\n const rows: ResultRow[] = [['Versions', versionLabel(template)]];\n if (result.outcome === 'published' || result.outcome === 'rolled-back') {\n rows.push(['Teams updated', String(result.teamsUpdated)]);\n }\n const notes =\n (result.outcome === 'created' || result.outcome === 'updated') &&\n template.publishedVersion !== template.latestVersion\n ? [\n `Teams still run the published version. \"ekanos agents publish ${template.key}\" moves them.`,\n ]\n : [];\n return ui.result({\n title: `${OUTCOME_TITLE[result.outcome]}: ${template.key}`,\n tone: result.outcome === 'unchanged' ? 'warn' : 'ok',\n rows,\n notes,\n });\n}\n"]}
|
package/dist/commands/catalog.js
CHANGED
|
@@ -3,6 +3,7 @@ import { fetchSourceCatalog, } from '../catalog-api.js';
|
|
|
3
3
|
import { authRequiredError } from '../errors.js';
|
|
4
4
|
import { resolveSourceTarget } from '../source-target.js';
|
|
5
5
|
import { pluralize } from '../ui.js';
|
|
6
|
+
import { withDocsHint } from './agents-init.js';
|
|
6
7
|
/**
|
|
7
8
|
* `catalog` — what the Source can already do (plan 239.0). Lists every
|
|
8
9
|
* product the Source can use, with its tools, agent events and the steps
|
|
@@ -27,9 +28,9 @@ export async function runCatalog(ctx, args) {
|
|
|
27
28
|
result = await fetchSourceCatalog(env.host, session.accessToken, query);
|
|
28
29
|
}
|
|
29
30
|
const catalog = requireCatalog(result, env.host);
|
|
30
|
-
return ctx.succeed(Object.assign({ host: env.host }, catalog), args.product
|
|
31
|
+
return ctx.succeed(Object.assign({ host: env.host }, catalog), withDocsHint(ctx.ui, args.dir, args.product
|
|
31
32
|
? productDetail(ctx.ui, catalog.products[0])
|
|
32
|
-
: catalogSummary(ctx.ui, catalog));
|
|
33
|
+
: catalogSummary(ctx.ui, catalog)));
|
|
33
34
|
}
|
|
34
35
|
function requireCatalog(result, host) {
|
|
35
36
|
if (result.status === 'ok')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/commands/catalog.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAW,SAAS,EAAE,MAAM,OAAO,CAAC;AAW3C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAe,EACf,IAAiB;IAEjB,MAAM,GAAG,GAAG,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;QAC3D,UAAU,EAAE,IAAI,CAAC,GAAG;KACrB,CAAC,CAAC;IACH,IAAI,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAElD,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC/D,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IAE3B,MAAM,KAAK,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACjE,IAAI,MAAM,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAA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AQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC7C;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,aAAa,CAAC,OAAuB;IAC5C,MAAM,KAAK,GAAG;QACZ,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;QACzE,OAAO,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YAC5B,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC;YACxD,CAAC,CAAC,IAAI;KACT,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,SAAS,CAAC,OAAuB;IACxC,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;IACxE,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC;AAC3E,CAAC","sourcesContent":["import type { CatalogProduct, SourceCatalog } from '@ekanos/integration-schema';\n\nimport {\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport {\n type FetchSourceCatalogResult,\n fetchSourceCatalog,\n} from '../catalog-api';\nimport type { CliContext } from '../context';\nimport { authRequiredError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { resolveSourceTarget } from '../source-target';\nimport { type Ui, pluralize } from '../ui';\n\nexport interface CatalogArgs {\n host?: string;\n source?: string;\n /** One product's detail, when given. */\n product?: string;\n dir: string;\n env: Record<string, string | undefined>;\n}\n\n/**\n * `catalog` — what the Source can already do (plan 239.0). Lists every\n * product the Source can use, with its tools, agent events and the steps\n * left to set it up; `ekanos catalog <product>` shows one in full.\n *\n * Read before building: an agent migration asks it first, so a capability\n * the Source already has is set up rather than rebuilt. Works outside a\n * project — the Source comes from `--source`, else `ekanos.json`, else the\n * caller's only seat.\n */\nexport async function runCatalog(\n ctx: CliContext,\n args: CatalogArgs,\n): Promise<ExitCode> {\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n let session = requireSession(env.store, env.host);\n\n const resolved = await resolveSourceTarget(env, session, args);\n session = resolved.session;\n\n const query = { source: resolved.source, product: args.product };\n let result = await fetchSourceCatalog(env.host, session.accessToken, query);\n if (result.status === 'unauthorized') {\n session = await refreshStoredSession(env, session);\n result = await fetchSourceCatalog(env.host, session.accessToken, query);\n }\n const catalog = requireCatalog(result, env.host);\n\n return ctx.succeed(\n { host: env.host, ...catalog },\n args.product\n ? productDetail(ctx.ui, catalog.products[0]!)\n : catalogSummary(ctx.ui, catalog),\n );\n}\n\nfunction requireCatalog(\n result: FetchSourceCatalogResult,\n host: string,\n): SourceCatalog {\n if (result.status === 'ok') return result.catalog;\n throw authRequiredError(\n `The session for ${host} could not authorize the catalog read.`,\n `Run \"ekanos login --host ${host}\" and retry.`,\n );\n}\n\nconst AVAILABILITY_LABEL = {\n enabled: 'Enabled on this Source',\n 'turned-off': 'Granted but switched off',\n available: 'Available — ask Ekanos to enable',\n} as const;\n\nfunction catalogSummary(ui: Ui, catalog: SourceCatalog): string {\n const blocks = (['enabled', 'turned-off', 'available'] as const)\n .map((availability) => {\n const products = catalog.products.filter(\n (product) => product.availability === availability,\n );\n if (products.length === 0) return null;\n return ui.result({\n title: `${AVAILABILITY_LABEL[availability]} (${products.length})`,\n tone: availability === 'enabled' ? 'ok' : 'warn',\n rows: products.map((product): [string, string] => [\n product.slug,\n [product.name, describeShape(product), openSteps(product)]\n .filter(Boolean)\n .join(' · '),\n ]),\n });\n })\n .filter((block): block is string => block !== null);\n\n return [\n ...blocks,\n ui.hint(\n `${pluralize(catalog.products.length, 'product')} on ${catalog.source.slug}. ` +\n `\"ekanos catalog <product>\" shows tools, agent events and setup steps.`,\n ),\n ].join('\\n\\n');\n}\n\nfunction productDetail(ui: Ui, product: CatalogProduct): string {\n const rows: [string, string | string[]][] = [\n ['What', product.summary ?? '—'],\n [\n 'Kind',\n product.kind === 'experience' ? 'Ekanos Experience' : 'Integration',\n ],\n ['Status', AVAILABILITY_LABEL[product.availability]],\n ];\n if (product.connectedTeams !== null) {\n rows.push(['Teams connected', String(product.connectedTeams)]);\n }\n if (product.tools.length > 0) {\n rows.push([\n 'Tools',\n product.tools.map(\n (tool) =>\n `${tool.name} (${tool.effect}${tool.sensitivity === 'undeclared' ? '' : `, ${tool.sensitivity}`})`,\n ),\n ]);\n }\n if (product.agentEvents.length > 0) {\n rows.push([\n 'Agent triggers',\n product.agentEvents.map((event) => `${event.id} — ${event.label}`),\n ]);\n }\n if (product.agentReplyTool) {\n rows.push(['Replies with', product.agentReplyTool]);\n }\n rows.push([\n 'Setup',\n product.setupSteps.map(\n (step, index) =>\n `${index + 1}. [${step.state}] ${step.title} (${step.actor}) — ${step.detail}` +\n (step.guideUrl ? ` ${step.guideUrl}` : ''),\n ),\n ]);\n\n return ui.result({ title: `${product.name} (${product.slug})`, rows });\n}\n\nfunction describeShape(product: CatalogProduct): string {\n const parts = [\n product.tools.length > 0 ? pluralize(product.tools.length, 'tool') : null,\n product.agentEvents.length > 0\n ? pluralize(product.agentEvents.length, 'agent trigger')\n : null,\n ].filter(Boolean);\n return parts.join(', ');\n}\n\nfunction openSteps(product: CatalogProduct): string {\n const open = product.setupSteps.filter((step) => step.state === 'todo');\n return open.length === 0 ? '' : `${pluralize(open.length, 'step')} left`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/commands/catalog.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAW,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAW7C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAe,EACf,IAAiB;IAEjB,MAAM,GAAG,GAAG,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;QAC3D,UAAU,EAAE,IAAI,CAAC,GAAG;KACrB,CAAC,CAAC;IACH,IAAI,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAElD,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAC/D,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;IAE3B,MAAM,KAAK,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACjE,IAAI,MAAM,GAAG,MAAM,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC5E,IAAI,MAAM,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC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AC,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC7C;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,aAAa,CAAC,OAAuB;IAC5C,MAAM,KAAK,GAAG;QACZ,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;QACzE,OAAO,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;YAC5B,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC;YACxD,CAAC,CAAC,IAAI;KACT,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,SAAS,CAAC,OAAuB;IACxC,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;IACxE,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC;AAC3E,CAAC","sourcesContent":["import type { CatalogProduct, SourceCatalog } from '@ekanos/integration-schema';\n\nimport {\n refreshStoredSession,\n requireSession,\n resolveAuthEnvironment,\n} from '../auth/session';\nimport {\n type FetchSourceCatalogResult,\n fetchSourceCatalog,\n} from '../catalog-api';\nimport type { CliContext } from '../context';\nimport { authRequiredError } from '../errors';\nimport type { ExitCode } from '../exit-codes';\nimport { resolveSourceTarget } from '../source-target';\nimport { type Ui, pluralize } from '../ui';\nimport { withDocsHint } from './agents-init';\n\nexport interface CatalogArgs {\n host?: string;\n source?: string;\n /** One product's detail, when given. */\n product?: string;\n dir: string;\n env: Record<string, string | undefined>;\n}\n\n/**\n * `catalog` — what the Source can already do (plan 239.0). Lists every\n * product the Source can use, with its tools, agent events and the steps\n * left to set it up; `ekanos catalog <product>` shows one in full.\n *\n * Read before building: an agent migration asks it first, so a capability\n * the Source already has is set up rather than rebuilt. Works outside a\n * project — the Source comes from `--source`, else `ekanos.json`, else the\n * caller's only seat.\n */\nexport async function runCatalog(\n ctx: CliContext,\n args: CatalogArgs,\n): Promise<ExitCode> {\n const env = resolveAuthEnvironment(ctx, args.host, args.env, {\n projectDir: args.dir,\n });\n let session = requireSession(env.store, env.host);\n\n const resolved = await resolveSourceTarget(env, session, args);\n session = resolved.session;\n\n const query = { source: resolved.source, product: args.product };\n let result = await fetchSourceCatalog(env.host, session.accessToken, query);\n if (result.status === 'unauthorized') {\n session = await refreshStoredSession(env, session);\n result = await fetchSourceCatalog(env.host, session.accessToken, query);\n }\n const catalog = requireCatalog(result, env.host);\n\n return ctx.succeed(\n { host: env.host, ...catalog },\n withDocsHint(\n ctx.ui,\n args.dir,\n args.product\n ? productDetail(ctx.ui, catalog.products[0]!)\n : catalogSummary(ctx.ui, catalog),\n ),\n );\n}\n\nfunction requireCatalog(\n result: FetchSourceCatalogResult,\n host: string,\n): SourceCatalog {\n if (result.status === 'ok') return result.catalog;\n throw authRequiredError(\n `The session for ${host} could not authorize the catalog read.`,\n `Run \"ekanos login --host ${host}\" and retry.`,\n );\n}\n\nconst AVAILABILITY_LABEL = {\n enabled: 'Enabled on this Source',\n 'turned-off': 'Granted but switched off',\n available: 'Available — ask Ekanos to enable',\n} as const;\n\nfunction catalogSummary(ui: Ui, catalog: SourceCatalog): string {\n const blocks = (['enabled', 'turned-off', 'available'] as const)\n .map((availability) => {\n const products = catalog.products.filter(\n (product) => product.availability === availability,\n );\n if (products.length === 0) return null;\n return ui.result({\n title: `${AVAILABILITY_LABEL[availability]} (${products.length})`,\n tone: availability === 'enabled' ? 'ok' : 'warn',\n rows: products.map((product): [string, string] => [\n product.slug,\n [product.name, describeShape(product), openSteps(product)]\n .filter(Boolean)\n .join(' · '),\n ]),\n });\n })\n .filter((block): block is string => block !== null);\n\n return [\n ...blocks,\n ui.hint(\n `${pluralize(catalog.products.length, 'product')} on ${catalog.source.slug}. ` +\n `\"ekanos catalog <product>\" shows tools, agent events and setup steps.`,\n ),\n ].join('\\n\\n');\n}\n\nfunction productDetail(ui: Ui, product: CatalogProduct): string {\n const rows: [string, string | string[]][] = [\n ['What', product.summary ?? '—'],\n [\n 'Kind',\n product.kind === 'experience' ? 'Ekanos Experience' : 'Integration',\n ],\n ['Status', AVAILABILITY_LABEL[product.availability]],\n ];\n if (product.connectedTeams !== null) {\n rows.push(['Teams connected', String(product.connectedTeams)]);\n }\n if (product.tools.length > 0) {\n rows.push([\n 'Tools',\n product.tools.map(\n (tool) =>\n `${tool.name} (${tool.effect}${tool.sensitivity === 'undeclared' ? '' : `, ${tool.sensitivity}`})`,\n ),\n ]);\n }\n if (product.agentEvents.length > 0) {\n rows.push([\n 'Agent triggers',\n product.agentEvents.map((event) => `${event.id} — ${event.label}`),\n ]);\n }\n if (product.agentReplyTool) {\n rows.push(['Replies with', product.agentReplyTool]);\n }\n rows.push([\n 'Setup',\n product.setupSteps.map(\n (step, index) =>\n `${index + 1}. [${step.state}] ${step.title} (${step.actor}) — ${step.detail}` +\n (step.guideUrl ? ` ${step.guideUrl}` : ''),\n ),\n ]);\n\n return ui.result({ title: `${product.name} (${product.slug})`, rows });\n}\n\nfunction describeShape(product: CatalogProduct): string {\n const parts = [\n product.tools.length > 0 ? pluralize(product.tools.length, 'tool') : null,\n product.agentEvents.length > 0\n ? pluralize(product.agentEvents.length, 'agent trigger')\n : null,\n ].filter(Boolean);\n return parts.join(', ');\n}\n\nfunction openSteps(product: CatalogProduct): string {\n const open = product.setupSteps.filter((step) => step.state === 'todo');\n return open.length === 0 ? '' : `${pluralize(open.length, 'step')} left`;\n}\n"]}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ export declare function runInit(ctx: CliContext, args: InitArgs): Promise<ExitCo
|
|
|
103
103
|
*
|
|
104
104
|
* `skillsRoot` is injectable for tests; real callers take the default.
|
|
105
105
|
*/
|
|
106
|
-
export declare function copyBundledSkillTrees(targetDir: string, force: boolean, skillsRoot?: string, onRefusal?: 'throw' | 'collect'): {
|
|
106
|
+
export declare function copyBundledSkillTrees(targetDir: string, force: boolean, skillsRoot?: string, onRefusal?: 'throw' | 'collect', only?: readonly string[]): {
|
|
107
107
|
created: string[];
|
|
108
108
|
skipped: SkippedFile[];
|
|
109
109
|
refused: string[];
|
package/dist/commands/init.js
CHANGED
|
@@ -302,7 +302,7 @@ function renderEkanosConfig(vars, docs) {
|
|
|
302
302
|
*
|
|
303
303
|
* `skillsRoot` is injectable for tests; real callers take the default.
|
|
304
304
|
*/
|
|
305
|
-
export function copyBundledSkillTrees(targetDir, force, skillsRoot = path.join(templatesDir(), 'skills'), onRefusal = 'throw') {
|
|
305
|
+
export function copyBundledSkillTrees(targetDir, force, skillsRoot = path.join(templatesDir(), 'skills'), onRefusal = 'throw', only) {
|
|
306
306
|
if (!fs.existsSync(skillsRoot))
|
|
307
307
|
return { created: [], skipped: [], refused: [] };
|
|
308
308
|
const created = [];
|
|
@@ -312,6 +312,7 @@ export function copyBundledSkillTrees(targetDir, force, skillsRoot = path.join(t
|
|
|
312
312
|
.readdirSync(skillsRoot, { withFileTypes: true })
|
|
313
313
|
.filter((entry) => entry.isDirectory())
|
|
314
314
|
.map((entry) => entry.name)
|
|
315
|
+
.filter((name) => !only || only.includes(name))
|
|
315
316
|
.sort();
|
|
316
317
|
for (const name of skillDirs) {
|
|
317
318
|
const destBase = path.join('.claude', 'skills', name);
|