@ekanos/cli 0.34.0 → 0.35.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.
Files changed (36) hide show
  1. package/README.md +2 -1
  2. package/dist/commands/index-experience.js +2 -0
  3. package/dist/commands/index-experience.js.map +1 -1
  4. package/dist/commands/migrate.d.ts +2 -0
  5. package/dist/commands/migrate.js +180 -0
  6. package/dist/commands/migrate.js.map +1 -0
  7. package/dist/commands/status.js +18 -2
  8. package/dist/commands/status.js.map +1 -1
  9. package/dist/commands/team-agents.d.ts +1 -1
  10. package/dist/commands/team-agents.js +6 -0
  11. package/dist/commands/team-agents.js.map +1 -1
  12. package/dist/commands/team-api-keys.d.ts +4 -0
  13. package/dist/commands/team-api-keys.js +277 -0
  14. package/dist/commands/team-api-keys.js.map +1 -0
  15. package/dist/commands/teams.js +1 -1
  16. package/dist/commands/teams.js.map +1 -1
  17. package/dist/host-load.d.ts +8 -0
  18. package/dist/host-load.js +115 -0
  19. package/dist/host-load.js.map +1 -0
  20. package/dist/index.js +16 -3
  21. package/dist/index.js.map +1 -1
  22. package/dist/migrate-connection.d.ts +29 -0
  23. package/dist/migrate-connection.js +569 -0
  24. package/dist/migrate-connection.js.map +1 -0
  25. package/dist/teams-api.js +6 -0
  26. package/dist/teams-api.js.map +1 -1
  27. package/dist/validate-findings.js +5 -1
  28. package/dist/validate-findings.js.map +1 -1
  29. package/loader/declaration-loader.hooks.mjs +187 -0
  30. package/loader/host-load-probe.mjs +20 -0
  31. package/loader/register-declaration-loader.mjs +3 -0
  32. package/package.json +5 -4
  33. package/templates/AGENTS.md.tmpl +17 -3
  34. package/templates/experience/package.json.tmpl +4 -4
  35. package/templates/package.json.tmpl +4 -4
  36. package/templates/skills/build-integration/references/oauth-setup.md +3 -3
@@ -0,0 +1,187 @@
1
+ import { transform as esbuildTransform } from 'esbuild';
2
+ import fs from 'node:fs';
3
+ import { fileURLToPath, pathToFileURL } from 'node:url';
4
+
5
+ const RETRY_EXTENSIONS = ['.ts', '.tsx', '.mts', '/index.ts', '/index.tsx'];
6
+
7
+ const NODE_MODULES_TS_PATTERN = /\.(?:m|c)?ts$/i;
8
+
9
+ const MANIFEST_URL = process.env.EKANOS_PARTNER_MANIFEST_PATH_OVERRIDE
10
+ ? pathToFileURL(process.env.EKANOS_PARTNER_MANIFEST_PATH_OVERRIDE)
11
+ : new URL('../../lib/partner-integrations.manifest.ts', import.meta.url);
12
+
13
+ let admittedPackageNamesPromise;
14
+
15
+ async function getAdmittedPartnerPackageNames() {
16
+ admittedPackageNamesPromise ??= (async () => {
17
+ try {
18
+ const manifestModule =
19
+ /** @type {{ partnerIntegrationsManifest?: unknown }} */ (
20
+ await import(MANIFEST_URL.href)
21
+ );
22
+ const entries = manifestModule.partnerIntegrationsManifest;
23
+ if (!Array.isArray(entries)) {
24
+ return new Set();
25
+ }
26
+ return new Set(
27
+ entries
28
+ .map(
29
+ (entry) =>
30
+ /** @type {{ packageName?: unknown }} */ (entry)?.packageName,
31
+ )
32
+ .filter((name) => typeof name === 'string'),
33
+ );
34
+ } catch (error) {
35
+ console.warn(
36
+ `[declaration-loader] could not read the partner manifest at ${MANIFEST_URL.href}; ` +
37
+ `no partner package will be transformed under node_modules. Cause: ${error}`,
38
+ );
39
+ return new Set();
40
+ }
41
+ })();
42
+ return admittedPackageNamesPromise;
43
+ }
44
+
45
+ function partnerPackageNameFromPath(filePath) {
46
+ const segments = filePath.split(/[\\/]+/);
47
+ const index = segments.lastIndexOf('node_modules');
48
+ if (index === -1 || index + 1 >= segments.length) {
49
+ return null;
50
+ }
51
+
52
+ const first = segments[index + 1];
53
+ if (first.startsWith('@')) {
54
+ return index + 2 < segments.length
55
+ ? `${first}/${segments[index + 2]}`
56
+ : null;
57
+ }
58
+ return first;
59
+ }
60
+
61
+ async function transformAdmittedPartnerModule(filePath) {
62
+ const source = fs.readFileSync(filePath, 'utf8');
63
+ const result = await esbuildTransform(source, {
64
+ loader: 'ts',
65
+ format: 'esm',
66
+ sourcefile: filePath,
67
+ sourcemap: 'inline',
68
+ });
69
+
70
+ return {
71
+ format: 'module',
72
+ shortCircuit: true,
73
+ source: result.code,
74
+ };
75
+ }
76
+
77
+ export async function resolve(specifier, context, nextResolve) {
78
+ if (!specifier.startsWith('.') && !specifier.startsWith('/')) {
79
+ return nextResolve(specifier, context);
80
+ }
81
+
82
+ try {
83
+ return await nextResolve(specifier, context);
84
+ } catch (error) {
85
+ const base = context.parentURL
86
+ ? new URL(specifier, context.parentURL)
87
+ : pathToFileURL(specifier);
88
+
89
+ for (const extension of RETRY_EXTENSIONS) {
90
+ const candidate = `${base.href}${extension}`;
91
+ if (fs.existsSync(fileURLToPath(candidate))) {
92
+ return { url: candidate, shortCircuit: true };
93
+ }
94
+ }
95
+
96
+ throw error;
97
+ }
98
+ }
99
+
100
+ function declaredExportNames(source) {
101
+ const names = new Set();
102
+
103
+ for (const match of source.matchAll(
104
+ /^export\s+(?:async\s+)?(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/gm,
105
+ )) {
106
+ names.add(match[1]);
107
+ }
108
+
109
+ for (const match of source.matchAll(/^export\s*\{([^}]*)\}/gm)) {
110
+ for (const clause of match[1].split(',')) {
111
+ const name = clause
112
+ .trim()
113
+ .split(/\s+as\s+/)
114
+ .pop()
115
+ ?.trim();
116
+ if (name && /^[A-Za-z_$][\w$]*$/.test(name)) {
117
+ names.add(name);
118
+ }
119
+ }
120
+ }
121
+
122
+ return [...names];
123
+ }
124
+
125
+ async function isAdmittedPartnerFile(filePath) {
126
+ const packageName = partnerPackageNameFromPath(filePath);
127
+ if (!packageName) return false;
128
+ const admitted = await getAdmittedPartnerPackageNames();
129
+ return admitted.has(packageName);
130
+ }
131
+
132
+ export async function load(url, context, nextLoad) {
133
+ if (!url.endsWith('.tsx')) {
134
+ if (NODE_MODULES_TS_PATTERN.test(url) && !url.endsWith('.d.ts')) {
135
+ const filePath = fileURLToPath(url);
136
+ if (await isAdmittedPartnerFile(filePath)) {
137
+ return transformAdmittedPartnerModule(filePath);
138
+ }
139
+ }
140
+
141
+ if (
142
+ url.startsWith('file:') &&
143
+ url.endsWith('.json') &&
144
+ context.importAttributes?.type !== 'json'
145
+ ) {
146
+ const filePath = fileURLToPath(url);
147
+ if (await isAdmittedPartnerFile(filePath)) {
148
+ const parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
149
+ return {
150
+ format: 'module',
151
+ shortCircuit: true,
152
+ source: `export default ${JSON.stringify(parsed)};\n`,
153
+ };
154
+ }
155
+ }
156
+
157
+ return nextLoad(url, context);
158
+ }
159
+
160
+ const source = fs.readFileSync(fileURLToPath(url), 'utf8');
161
+
162
+ const prelude = `const __stub = (exportName) => {
163
+ const fail = () => {
164
+ throw new Error(
165
+ 'export "' + exportName + '" of ' + ${JSON.stringify(url)} +
166
+ ' was stubbed by the declaration loader — declaration data must come from .ts modules;' +
167
+ ' a .tsx export may only be held as a component reference, never read as data.',
168
+ );
169
+ };
170
+ return new Proxy(function () {}, {
171
+ get: fail,
172
+ set: fail,
173
+ apply: fail,
174
+ construct: fail,
175
+ });
176
+ };`;
177
+
178
+ const stubs = declaredExportNames(source)
179
+ .map((name) => `export const ${name} = __stub(${JSON.stringify(name)});`)
180
+ .join('\n');
181
+
182
+ return {
183
+ format: 'module',
184
+ shortCircuit: true,
185
+ source: `${prelude}\n${stubs}\nexport default __stub('default');\n`,
186
+ };
187
+ }
@@ -0,0 +1,20 @@
1
+ import { parseIntegrationDefinition } from '@ekanos/integration-schema';
2
+
3
+ const MARKER = '__EKANOS_HOST_LOAD__';
4
+
5
+ try {
6
+ const loaded = await import(process.argv[2]);
7
+
8
+ if (loaded.integration === undefined) {
9
+ throw new Error(
10
+ 'the entry has no `integration` export. A declaration module must `export const integration = defineIntegration({ … })`.',
11
+ );
12
+ }
13
+
14
+ parseIntegrationDefinition(loaded.integration);
15
+ console.log(`${MARKER}${JSON.stringify({ ok: true })}`);
16
+ } catch (error) {
17
+ const message = error instanceof Error ? error.message : String(error);
18
+ const stack = error instanceof Error ? (error.stack ?? message) : message;
19
+ console.log(`${MARKER}${JSON.stringify({ ok: false, message, stack })}`);
20
+ }
@@ -0,0 +1,3 @@
1
+ import module from 'node:module';
2
+
3
+ module.register('./declaration-loader.hooks.mjs', import.meta.url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekanos/cli",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "private": false,
5
5
  "description": "The Ekanos partner toolchain CLI: scaffold, validate, and test an Ekanos integration against the published @ekanos packages. Agent-native — every verb speaks JSON with a stable exit-code taxonomy.",
6
6
  "keywords": [
@@ -19,6 +19,7 @@
19
19
  },
20
20
  "files": [
21
21
  "dist",
22
+ "loader",
22
23
  "templates",
23
24
  "README.md",
24
25
  "LICENSE"
@@ -35,16 +36,16 @@
35
36
  },
36
37
  "dependencies": {
37
38
  "@clack/prompts": "1.9.0",
38
- "@ekanos/integration-schema": "0.37.0",
39
+ "@ekanos/integration-schema": "0.38.0",
39
40
  "esbuild": "0.28.2",
40
41
  "npm": "11.19.1",
41
42
  "picocolors": "1.1.1"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@kit/tsconfig": "0.1.0",
45
- "@types/node": "26.6.6",
46
+ "@types/node": "26.6.11",
46
47
  "typescript": "^7.0.2",
47
- "vitest": "5.1.1",
48
+ "vitest": "5.1.2",
48
49
  "zod": "4.6.7"
49
50
  },
50
51
  "peerDependencies": {
@@ -177,18 +177,32 @@ snapshot (trim the oldest rows until `JSON.stringify` fits, and say so with a
177
177
  ### Secrets and the activation contract
178
178
 
179
179
  There is **no `secrets` block** in the definition. Secrets are *named*, and the
180
- activation form is where most names come from. Declare the form's fields in
181
- `activation.fields` and mark every credential `secret: true`:
180
+ activation form is where most names come from. The whole connection is stated
181
+ in one place, `connection`: declare the form's fields in `connection.fields`,
182
+ mark every credential `secret: true`, and put every secret field in exactly one
183
+ credential in `connection.credentials`. Each credential states its `level`:
184
+ `'team'` (connected once for everyone) or `'user'` (each person connects their
185
+ own). There is no default level.
182
186
 
183
187
  ```ts
184
- activation: {
188
+ connection: {
185
189
  fields: [
186
190
  { name: ACME_API_KEY, label: 'API key', secret: true },
187
191
  { name: ACME_MERCHANT_ID, label: 'Merchant ID', secret: false },
188
192
  ],
193
+ credentials: [
194
+ { kind: 'activation', id: 'api-key', label: 'API key', level: 'team', fields: [ACME_API_KEY] },
195
+ ],
189
196
  },
190
197
  ```
191
198
 
199
+ An OAuth sign-in is a credential too: `{ kind: 'oauth', id: 'default', level,
200
+ provider, client: { idSecretName, secretSecretName }, onTokens }`. The id
201
+ `'default'` is the main sign-in; any other id is a named connection and needs a
202
+ `label` and a `description`. A package written with the older top-level
203
+ `oauth`, `oauthConnections` or `activation` blocks still works, with a warning;
204
+ `ekanos migrate` rewrites it.
205
+
192
206
  **A `secret: true` field is stored in the platform vault, never in the
193
207
  connection record every team member can read, and is readable as
194
208
  `ctx.secrets.get('<that exact field name>')`.** No prefixing, no
@@ -22,16 +22,16 @@
22
22
  "build": "npx ekanos build"
23
23
  },
24
24
  "dependencies": {
25
- "@ekanos/sdk": "^0.37.0",
26
- "@ekanos/ui": "^0.37.0",
25
+ "@ekanos/sdk": "^0.38.0",
26
+ "@ekanos/ui": "^0.38.0",
27
27
  "@tanstack/react-query": "^5.101.4",
28
28
  "react": "^19.2.8",
29
29
  "react-dom": "^19.2.8",
30
30
  "zod": "^4.6.7"
31
31
  },
32
32
  "devDependencies": {
33
- "@ekanos/cli": "^0.34.0",
34
- "@ekanos/harness": "^0.37.0",
33
+ "@ekanos/cli": "^0.35.0",
34
+ "@ekanos/harness": "^0.38.0",
35
35
  "@tailwindcss/postcss": "^4.3.3",
36
36
  "@typescript-eslint/parser": "^8.46.2",
37
37
  "@types/react": "^19.2.0",
@@ -12,12 +12,12 @@
12
12
  "prepare": "node scripts/setup-hooks.mjs"
13
13
  },
14
14
  "dependencies": {
15
- "@ekanos/sdk": "^0.37.0",
16
- "@ekanos/ui": "^0.37.0"
15
+ "@ekanos/sdk": "^0.38.0",
16
+ "@ekanos/ui": "^0.38.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@ekanos/cli": "^0.34.0",
20
- "@ekanos/harness": "^0.37.0",
19
+ "@ekanos/cli": "^0.35.0",
20
+ "@ekanos/harness": "^0.38.0",
21
21
  "@hookform/resolvers": "^5.2.2",
22
22
  "@tailwindcss/postcss": "^4.3.3",
23
23
  "@tanstack/react-query": "^5.101.4",
@@ -39,11 +39,11 @@ the default is HTTP Basic (`'client_secret_basic'`), but a provider that wants
39
39
  `client_id` and `client_secret` in the form body (LinkedIn) needs
40
40
  `provider.tokenAuthMethod: 'client_secret_post'` in the declaration. The
41
41
  harness derives the rest — provider host, redirect URI, scopes, PKCE — from
42
- `defineIntegration({ oauth })`, so do not repeat those in `notes`.
42
+ the OAuth credential in `connection.credentials`, so do not repeat those in `notes`.
43
43
 
44
44
  Also declare the same guidance **on the connection itself** for the hosted
45
- product — `setup` in `defineIntegration({ oauth: { … } })` (and on each
46
- `oauthConnections` entry). That is what a Source admin sees in `ekanos apps`
45
+ product — `setup` on each `{ kind: 'oauth' }` credential in
46
+ `defineIntegration({ connection: { credentials: [ … ] } })`. That is what a Source admin sees in `ekanos apps`
47
47
  and a team sees in its setup panel once the integration is live:
48
48
 
49
49
  ```ts