@elevasis/sdk 1.1.0 → 1.3.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/dist/cli.cjs CHANGED
@@ -6,9 +6,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __esm = (fn, res) => function __init() {
10
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
- };
12
9
  var __commonJS = (cb, mod) => function __require() {
13
10
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
11
  };
@@ -26490,65 +26487,6 @@ var require_zod = __commonJS({
26490
26487
  }
26491
26488
  });
26492
26489
 
26493
- // src/cli/config.ts
26494
- var config_exports = {};
26495
- __export(config_exports, {
26496
- findEnvFile: () => findEnvFile,
26497
- resolveApiKey: () => resolveApiKey,
26498
- resolveApiUrl: () => resolveApiUrl,
26499
- resolveEnvironment: () => resolveEnvironment
26500
- });
26501
- function resolveApiUrl(cliOverride, prod) {
26502
- if (cliOverride) return cliOverride;
26503
- if (prod) return PROD_API_URL;
26504
- if (process.env.ELEVASIS_API_URL) return process.env.ELEVASIS_API_URL;
26505
- if (process.env.NODE_ENV === "development") return DEV_API_URL;
26506
- return PROD_API_URL;
26507
- }
26508
- function resolveEnvironment(prod) {
26509
- if (prod) return "production";
26510
- return process.env.NODE_ENV === "development" ? "development" : "production";
26511
- }
26512
- function resolveApiKey(prod) {
26513
- if (!prod && process.env.NODE_ENV === "development") {
26514
- return process.env.ELEVASIS_PLATFORM_KEY_DEV ?? process.env.ELEVASIS_PLATFORM_KEY ?? "";
26515
- }
26516
- return process.env.ELEVASIS_PLATFORM_KEY ?? "";
26517
- }
26518
- function findEnvFile(startDir) {
26519
- const cwd = (0, import_path.resolve)(startDir ?? process.cwd());
26520
- let dir = cwd;
26521
- while (true) {
26522
- const candidate = (0, import_path.resolve)(dir, ".env");
26523
- if ((0, import_fs.existsSync)(candidate)) return candidate;
26524
- const parent = (0, import_path.dirname)(dir);
26525
- if (parent === dir) break;
26526
- dir = parent;
26527
- }
26528
- dir = cwd;
26529
- while (true) {
26530
- if ((0, import_fs.existsSync)((0, import_path.resolve)(dir, "pnpm-workspace.yaml"))) {
26531
- const candidate = (0, import_path.resolve)(dir, ".env");
26532
- if ((0, import_fs.existsSync)(candidate)) return candidate;
26533
- break;
26534
- }
26535
- const parent = (0, import_path.dirname)(dir);
26536
- if (parent === dir) break;
26537
- dir = parent;
26538
- }
26539
- return void 0;
26540
- }
26541
- var import_fs, import_path, DEV_API_URL, PROD_API_URL;
26542
- var init_config = __esm({
26543
- "src/cli/config.ts"() {
26544
- "use strict";
26545
- import_fs = require("fs");
26546
- import_path = require("path");
26547
- DEV_API_URL = "http://localhost:5170";
26548
- PROD_API_URL = "https://api.elevasis.io";
26549
- }
26550
- });
26551
-
26552
26490
  // src/cli/index.ts
26553
26491
  var import_dotenv = __toESM(require_main(), 1);
26554
26492
 
@@ -43835,11 +43773,53 @@ var ResourceRegistry = class {
43835
43773
  }
43836
43774
  };
43837
43775
 
43838
- // src/cli/commands/deploy.ts
43839
- init_config();
43776
+ // src/cli/config.ts
43777
+ var import_fs = require("fs");
43778
+ var import_path = require("path");
43779
+ var DEV_API_URL = "http://localhost:5170";
43780
+ var PROD_API_URL = "https://api.elevasis.io";
43781
+ function resolveApiUrl(cliOverride, prod) {
43782
+ if (cliOverride) return cliOverride;
43783
+ if (prod) return PROD_API_URL;
43784
+ if (process.env.ELEVASIS_API_URL) return process.env.ELEVASIS_API_URL;
43785
+ if (process.env.NODE_ENV === "development") return DEV_API_URL;
43786
+ return PROD_API_URL;
43787
+ }
43788
+ function resolveEnvironment(prod) {
43789
+ if (prod) return "production";
43790
+ return process.env.NODE_ENV === "development" ? "development" : "production";
43791
+ }
43792
+ function resolveApiKey(prod) {
43793
+ if (!prod && process.env.NODE_ENV === "development") {
43794
+ return process.env.ELEVASIS_PLATFORM_KEY_DEV ?? process.env.ELEVASIS_PLATFORM_KEY ?? "";
43795
+ }
43796
+ return process.env.ELEVASIS_PLATFORM_KEY ?? "";
43797
+ }
43798
+ function findEnvFile(startDir) {
43799
+ const cwd = (0, import_path.resolve)(startDir ?? process.cwd());
43800
+ let dir = cwd;
43801
+ while (true) {
43802
+ const candidate = (0, import_path.resolve)(dir, ".env");
43803
+ if ((0, import_fs.existsSync)(candidate)) return candidate;
43804
+ const parent = (0, import_path.dirname)(dir);
43805
+ if (parent === dir) break;
43806
+ dir = parent;
43807
+ }
43808
+ dir = cwd;
43809
+ while (true) {
43810
+ if ((0, import_fs.existsSync)((0, import_path.resolve)(dir, "pnpm-workspace.yaml"))) {
43811
+ const candidate = (0, import_path.resolve)(dir, ".env");
43812
+ if ((0, import_fs.existsSync)(candidate)) return candidate;
43813
+ break;
43814
+ }
43815
+ const parent = (0, import_path.dirname)(dir);
43816
+ if (parent === dir) break;
43817
+ dir = parent;
43818
+ }
43819
+ return void 0;
43820
+ }
43840
43821
 
43841
43822
  // src/cli/api-client.ts
43842
- init_config();
43843
43823
  function getApiKey(apiUrl) {
43844
43824
  const isProd = !apiUrl.includes("localhost");
43845
43825
  const key = resolveApiKey(isProd);
@@ -43937,7 +43917,7 @@ function wrapAction(commandName, fn) {
43937
43917
  // package.json
43938
43918
  var package_default = {
43939
43919
  name: "@elevasis/sdk",
43940
- version: "1.1.0",
43920
+ version: "1.3.0",
43941
43921
  description: "SDK for building Elevasis organization resources",
43942
43922
  type: "module",
43943
43923
  bin: {
@@ -43964,9 +43944,11 @@ var package_default = {
43964
43944
  "reference/"
43965
43945
  ],
43966
43946
  scripts: {
43967
- build: `node -e "require('fs').rmSync('dist',{recursive:true,force:true})" && tsc -p tsconfig.core-dts.json && tsc -p tsconfig.build.json && tsup && rollup -c rollup.dts.config.mjs && esbuild src/cli/index.ts --bundle --platform=node --outfile=dist/cli.cjs --format=cjs --external:esbuild --banner:js="#!/usr/bin/env node" && node scripts/copy-reference-docs.mjs && node scripts/generate-navigation.mjs`,
43968
- "check-types": "tsc --noEmit",
43969
- "test:bundle": "pnpm build && vitest run --config vitest.bundle.config.ts"
43947
+ build: `node -e "require('fs').rmSync('dist',{recursive:true,force:true})" && tsc -p tsconfig.core-dts.json && tsc -p tsconfig.build.json && tsup && rollup -c rollup.dts.config.mjs && esbuild src/cli/index.ts --bundle --platform=node --outfile=dist/cli.cjs --format=cjs --external:esbuild --banner:js="#!/usr/bin/env node" && node scripts/copy-reference-docs.mjs && node ../../scripts/monorepo/generate-reference-artifacts.js`,
43948
+ "type-check": "tsc --noEmit",
43949
+ "check-types": "pnpm type-check",
43950
+ test: "pnpm build && node ../../scripts/monorepo/validate-reference-artifacts.js && vitest run --config vitest.bundle.config.ts",
43951
+ "test:bundle": "pnpm test"
43970
43952
  },
43971
43953
  dependencies: {
43972
43954
  esbuild: "^0.25.0"
@@ -44060,8 +44042,9 @@ function bumpVersion(current, type) {
44060
44042
  }
44061
44043
  }
44062
44044
  var IGNORED_DOC_DIRS = /* @__PURE__ */ new Set([".archive"]);
44063
- async function scanDocumentation() {
44064
- const docsDir = (0, import_path2.resolve)("docs");
44045
+ async function scanDocumentation(docsDir) {
44046
+ if (docsDir === false) return void 0;
44047
+ const resolvedDocsDir = (0, import_path2.resolve)(docsDir ?? "docs");
44065
44048
  const files = [];
44066
44049
  let totalSize = 0;
44067
44050
  async function scan(dir, relPrefix) {
@@ -44077,7 +44060,7 @@ async function scanDocumentation() {
44077
44060
  if (entry.isDirectory()) {
44078
44061
  if (IGNORED_DOC_DIRS.has(entry.name)) continue;
44079
44062
  await scan(fullPath, relPath);
44080
- } else if (entry.isFile() && entry.name.endsWith(".mdx")) {
44063
+ } else if (entry.isFile() && (entry.name.endsWith(".mdx") || entry.name.endsWith(".md"))) {
44081
44064
  const raw = await (0, import_promises.readFile)(fullPath, "utf-8");
44082
44065
  const fileSize = Buffer.byteLength(raw, "utf-8");
44083
44066
  if (fileSize > 100 * 1024) {
@@ -44103,427 +44086,9 @@ async function scanDocumentation() {
44103
44086
  }
44104
44087
  }
44105
44088
  }
44106
- await scan(docsDir, "");
44089
+ await scan(resolvedDocsDir, "");
44107
44090
  return files.length > 0 ? files : void 0;
44108
44091
  }
44109
- function escapeMdx(text) {
44110
- if (!text) return "";
44111
- return text.replace(/\|/g, "\\|").replace(/\{/g, "\\{").replace(/\}/g, "\\}");
44112
- }
44113
- async function generateResourceMap(org) {
44114
- const workflows = org.workflows ?? [];
44115
- const agents = org.agents ?? [];
44116
- const lines = [
44117
- "---",
44118
- "title: Resource Map",
44119
- "description: Auto-generated resource inventory (updated on each deploy)",
44120
- "order: 998",
44121
- "---",
44122
- "",
44123
- "# Resource Map",
44124
- "",
44125
- "> Auto-generated by `elevasis-sdk deploy`. Do not edit manually.",
44126
- ""
44127
- ];
44128
- if (workflows.length > 0) {
44129
- lines.push(
44130
- "## Workflows",
44131
- "",
44132
- "| Resource ID | Name | Version | Status | Description |",
44133
- "| --- | --- | --- | --- | --- |"
44134
- );
44135
- for (const w of workflows) {
44136
- const desc = escapeMdx(w.config.description);
44137
- lines.push(
44138
- `| \`${w.config.resourceId}\` | ${escapeMdx(w.config.name)} | ${w.config.version} | ${w.config.status} | ${desc} |`
44139
- );
44140
- }
44141
- lines.push("");
44142
- }
44143
- if (agents.length > 0) {
44144
- lines.push(
44145
- "## Agents",
44146
- "",
44147
- "| Resource ID | Name | Version | Status | Description |",
44148
- "| --- | --- | --- | --- | --- |"
44149
- );
44150
- for (const a of agents) {
44151
- const desc = escapeMdx(a.config.description);
44152
- lines.push(
44153
- `| \`${a.config.resourceId}\` | ${escapeMdx(a.config.name)} | ${a.config.version} | ${a.config.status} | ${desc} |`
44154
- );
44155
- }
44156
- lines.push("");
44157
- }
44158
- lines.push(
44159
- `**Total:** ${workflows.length + agents.length} resources (${workflows.length} workflows, ${agents.length} agents)`,
44160
- ""
44161
- );
44162
- await (0, import_promises.mkdir)((0, import_path2.resolve)("docs"), { recursive: true });
44163
- await (0, import_promises.writeFile)((0, import_path2.resolve)("docs/resource-map.mdx"), lines.join("\n"), "utf-8");
44164
- }
44165
- async function generateProjectMap(org) {
44166
- const workflows = org.workflows ?? [];
44167
- const agents = org.agents ?? [];
44168
- const lastDeploy = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
44169
- const lines = [
44170
- "---",
44171
- "title: Project Map",
44172
- "description: Auto-generated project map (updated on each deploy)",
44173
- "order: 999",
44174
- "---",
44175
- "",
44176
- "# Project Map",
44177
- "",
44178
- "> Auto-generated by `elevasis-sdk deploy` and `/fix`. Do not edit manually.",
44179
- "",
44180
- "## Project Overview",
44181
- "",
44182
- "| Field | Value |",
44183
- "| --- | --- |",
44184
- `| SDK Version | ${SDK_VERSION} |`,
44185
- `| Last Deploy | ${lastDeploy} |`,
44186
- `| Resources | ${workflows.length} workflows, ${agents.length} agents |`,
44187
- ""
44188
- ];
44189
- lines.push(
44190
- "## Source Domains",
44191
- "",
44192
- "Scanned from `src/*/` subdirectories.",
44193
- "",
44194
- "| Domain | Path | Resources | Types |",
44195
- "| --- | --- | --- | --- |"
44196
- );
44197
- try {
44198
- const srcEntries = await (0, import_promises.readdir)((0, import_path2.resolve)("src"), { withFileTypes: true });
44199
- const domainDirs = srcEntries.filter((e) => e.isDirectory());
44200
- if (domainDirs.length === 0) {
44201
- lines.push("| (none) | src/ | 0 | \u2014 |");
44202
- } else {
44203
- for (const d of domainDirs) {
44204
- const domainName = d.name;
44205
- const allResources = [...workflows, ...agents];
44206
- const domainResources = allResources.filter(
44207
- (r) => Array.isArray(r.config.domains) && r.config.domains.includes(domainName)
44208
- );
44209
- const resourceCount = domainResources.length;
44210
- let types;
44211
- if (resourceCount === 0) {
44212
- types = "(utilities)";
44213
- } else {
44214
- const wCount = workflows.filter(
44215
- (w) => Array.isArray(w.config.domains) && w.config.domains.includes(domainName)
44216
- ).length;
44217
- const aCount = agents.filter(
44218
- (a) => Array.isArray(a.config.domains) && a.config.domains.includes(domainName)
44219
- ).length;
44220
- const parts = [];
44221
- if (wCount > 0) parts.push(`${wCount} workflow${wCount !== 1 ? "s" : ""}`);
44222
- if (aCount > 0) parts.push(`${aCount} agent${aCount !== 1 ? "s" : ""}`);
44223
- types = parts.join(", ");
44224
- }
44225
- lines.push(`| ${domainName} | src/${domainName}/ | ${resourceCount} | ${types} |`);
44226
- }
44227
- }
44228
- } catch {
44229
- lines.push("| (src/ not found) | \u2014 | 0 | \u2014 |");
44230
- }
44231
- lines.push("");
44232
- lines.push(
44233
- "## Resources",
44234
- "",
44235
- "| Type | Count |",
44236
- "| --- | --- |",
44237
- `| Workflows | ${workflows.length} |`,
44238
- `| Agents | ${agents.length} |`,
44239
- "",
44240
- `Full inventory (names, versions, descriptions): \`docs/resource-map.mdx\``,
44241
- ""
44242
- );
44243
- lines.push(
44244
- "## Documentation Index",
44245
- "",
44246
- "Scanned from `docs/*.mdx` frontmatter.",
44247
- "",
44248
- "| Title | Path | Description |",
44249
- "| --- | --- | --- |"
44250
- );
44251
- try {
44252
- const docEntries = [];
44253
- async function scanDocsDir(dir, relPrefix) {
44254
- let entries;
44255
- try {
44256
- entries = await (0, import_promises.readdir)(dir, { withFileTypes: true });
44257
- } catch {
44258
- return;
44259
- }
44260
- for (const entry of entries) {
44261
- const relPath = relPrefix ? `${relPrefix}/${entry.name}` : entry.name;
44262
- if (entry.isDirectory()) {
44263
- if (IGNORED_DOC_DIRS.has(entry.name)) continue;
44264
- await scanDocsDir((0, import_path2.resolve)(dir, entry.name), relPath);
44265
- } else if (entry.isFile() && entry.name.endsWith(".mdx") && relPath !== "project-map.mdx" && relPath !== "resource-map.mdx") {
44266
- try {
44267
- const raw = await (0, import_promises.readFile)((0, import_path2.resolve)(dir, entry.name), "utf-8");
44268
- const fmMatch = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/);
44269
- let title = relPath;
44270
- let description = "";
44271
- let order = 9999;
44272
- if (fmMatch) {
44273
- const fm = fmMatch[1];
44274
- const titleMatch = fm.match(/^title:\s*(.+)$/m);
44275
- const descMatch = fm.match(/^description:\s*(.+)$/m);
44276
- const orderMatch = fm.match(/^order:\s*(\d+)$/m);
44277
- if (titleMatch) title = titleMatch[1].trim();
44278
- if (descMatch) description = descMatch[1].trim();
44279
- if (orderMatch) order = parseInt(orderMatch[1], 10);
44280
- }
44281
- docEntries.push({ title, path: `docs/${relPath}`, description, order });
44282
- } catch {
44283
- }
44284
- }
44285
- }
44286
- }
44287
- await scanDocsDir((0, import_path2.resolve)("docs"), "");
44288
- docEntries.sort((a, b) => {
44289
- if (a.order !== b.order) return a.order - b.order;
44290
- return a.title.localeCompare(b.title);
44291
- });
44292
- if (docEntries.length === 0) {
44293
- lines.push("| (none) | \u2014 | \u2014 |");
44294
- } else {
44295
- for (const doc of docEntries) {
44296
- lines.push(`| ${escapeMdx(doc.title)} | ${doc.path} | ${escapeMdx(doc.description)} |`);
44297
- }
44298
- }
44299
- } catch {
44300
- lines.push("| (docs/ not found) | \u2014 | \u2014 |");
44301
- }
44302
- lines.push("");
44303
- lines.push("## SDK Reference", "");
44304
- try {
44305
- const navPath = (0, import_path2.resolve)("node_modules/@elevasis/sdk/reference/_navigation.md");
44306
- const navContent = await (0, import_promises.readFile)(navPath, "utf-8");
44307
- const navLines = navContent.split(/\r?\n/);
44308
- const categories = [];
44309
- let current = null;
44310
- for (const line of navLines) {
44311
- const headingMatch = line.match(/^##\s+(.+)$/);
44312
- if (headingMatch) {
44313
- if (current) categories.push(current);
44314
- current = { name: headingMatch[1].trim(), titles: [], count: 0 };
44315
- continue;
44316
- }
44317
- if (current) {
44318
- const rowMatch = line.match(/^\|\s*([^|]+?)\s*\|/);
44319
- if (rowMatch && !line.match(/^[\s|:-]+$/)) {
44320
- const cellText = rowMatch[1].trim();
44321
- if (cellText && cellText !== "File" && cellText !== "Title" && cellText !== "---") {
44322
- current.titles.push(cellText);
44323
- current.count++;
44324
- }
44325
- }
44326
- }
44327
- }
44328
- if (current) categories.push(current);
44329
- if (categories.length === 0) {
44330
- lines.push("SDK reference found but no categories parsed.", "");
44331
- } else {
44332
- lines.push("| Category | Files | Covers |", "| --- | --- | --- |");
44333
- for (const cat of categories) {
44334
- const covers = cat.titles.slice(0, 5).join(", ") + (cat.titles.length > 5 ? ", ..." : "");
44335
- lines.push(`| ${escapeMdx(cat.name)} | ${cat.count} | ${escapeMdx(covers)} |`);
44336
- }
44337
- lines.push("");
44338
- lines.push("Full reference: `reference/_navigation.md`", "");
44339
- }
44340
- } catch {
44341
- lines.push("SDK reference not found. Run `pnpm install`.", "");
44342
- }
44343
- lines.push("## Command and Rules System", "", "### Commands", "");
44344
- try {
44345
- const cmdEntries = await (0, import_promises.readdir)((0, import_path2.resolve)(".claude/commands"), { withFileTypes: true });
44346
- const cmdFiles = cmdEntries.filter((e) => e.isFile() && e.name.endsWith(".md"));
44347
- if (cmdFiles.length === 0) {
44348
- lines.push("No commands found.", "");
44349
- } else {
44350
- lines.push("| Command | File | Purpose |", "| --- | --- | --- |");
44351
- for (const f of cmdFiles) {
44352
- const cmdName = f.name.replace(/\.md$/, "");
44353
- let purpose = "";
44354
- try {
44355
- const raw = await (0, import_promises.readFile)((0, import_path2.resolve)(".claude/commands", f.name), "utf-8");
44356
- const goalMatch = raw.match(/\*\*Goal:\*\*\s*(.+)/);
44357
- if (goalMatch) {
44358
- purpose = goalMatch[1].trim();
44359
- } else {
44360
- const firstNonEmpty = raw.split(/\r?\n/).find((l) => l.trim() && !l.startsWith("#"));
44361
- purpose = firstNonEmpty ? firstNonEmpty.trim() : "";
44362
- }
44363
- } catch {
44364
- }
44365
- lines.push(`| ${cmdName} | .claude/commands/${f.name} | ${escapeMdx(purpose.slice(0, 80))} |`);
44366
- }
44367
- lines.push("");
44368
- }
44369
- } catch {
44370
- lines.push("No .claude/commands/ directory found.", "");
44371
- }
44372
- lines.push("### Rules (auto-injected)", "");
44373
- try {
44374
- const ruleEntries = await (0, import_promises.readdir)((0, import_path2.resolve)(".claude/rules"), { withFileTypes: true });
44375
- const ruleFiles = ruleEntries.filter((e) => e.isFile() && e.name.endsWith(".md"));
44376
- if (ruleFiles.length === 0) {
44377
- lines.push("No rules found.", "");
44378
- } else {
44379
- lines.push("| Rule | File | Scope |", "| --- | --- | --- |");
44380
- for (const f of ruleFiles) {
44381
- const ruleName = f.name.replace(/\.md$/, "").replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
44382
- let scope = "";
44383
- try {
44384
- const raw = await (0, import_promises.readFile)((0, import_path2.resolve)(".claude/rules", f.name), "utf-8");
44385
- const fmMatch = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/);
44386
- if (fmMatch) {
44387
- const descMatch = fmMatch[1].match(/^description:\s*(.+)$/m);
44388
- if (descMatch) scope = descMatch[1].trim();
44389
- }
44390
- if (!scope) {
44391
- const firstNonEmpty = raw.split(/\r?\n/).find((l) => l.trim() && !l.startsWith("#") && !l.startsWith("---"));
44392
- scope = firstNonEmpty ? firstNonEmpty.trim() : "";
44393
- }
44394
- } catch {
44395
- }
44396
- lines.push(`| ${ruleName} | .claude/rules/${f.name} | ${escapeMdx(scope.slice(0, 80))} |`);
44397
- }
44398
- lines.push("");
44399
- }
44400
- } catch {
44401
- lines.push("No .claude/rules/ directory found.", "");
44402
- }
44403
- lines.push("### Skills", "");
44404
- try {
44405
- const skillEntries = await (0, import_promises.readdir)((0, import_path2.resolve)(".claude/skills"), { withFileTypes: true });
44406
- const skillDirs = skillEntries.filter((e) => e.isDirectory());
44407
- if (skillDirs.length === 0) {
44408
- lines.push("No skills found.", "");
44409
- } else {
44410
- lines.push("| Skill | File | Trigger |", "| --- | --- | --- |");
44411
- for (const d of skillDirs) {
44412
- const skillFile = (0, import_path2.resolve)(".claude/skills", d.name, "SKILL.md");
44413
- let trigger = "";
44414
- try {
44415
- const raw = await (0, import_promises.readFile)(skillFile, "utf-8");
44416
- const fmMatch = raw.match(/^---\r?\n([\s\S]*?)\r?\n---/);
44417
- if (fmMatch) {
44418
- const descMatch = fmMatch[1].match(/^description:\s*(.+)$/m);
44419
- if (descMatch) trigger = descMatch[1].trim();
44420
- }
44421
- if (!trigger) {
44422
- const firstNonEmpty = raw.split(/\r?\n/).find((l) => l.trim() && !l.startsWith("#") && !l.startsWith("---"));
44423
- trigger = firstNonEmpty ? firstNonEmpty.trim() : "";
44424
- }
44425
- } catch {
44426
- }
44427
- lines.push(`| ${d.name} | .claude/skills/${d.name}/SKILL.md | ${escapeMdx(trigger.slice(0, 80))} |`);
44428
- }
44429
- lines.push("");
44430
- }
44431
- } catch {
44432
- lines.push("No .claude/skills/ directory found.", "");
44433
- }
44434
- lines.push("## Memory System", "", "Scanned from `.claude/memory/` structure.", "");
44435
- try {
44436
- const memoryFiles = [];
44437
- async function scanMemory(dir, relPrefix) {
44438
- let entries;
44439
- try {
44440
- entries = await (0, import_promises.readdir)(dir, { withFileTypes: true });
44441
- } catch {
44442
- return;
44443
- }
44444
- for (const entry of entries) {
44445
- const fullPath = (0, import_path2.resolve)(dir, entry.name);
44446
- const relPath = relPrefix ? `${relPrefix}/${entry.name}` : entry.name;
44447
- if (entry.isDirectory()) {
44448
- await scanMemory(fullPath, relPath);
44449
- } else if (entry.isFile()) {
44450
- try {
44451
- const s = await (0, import_promises.stat)(fullPath);
44452
- const mtime = s.mtime.toISOString().split("T")[0];
44453
- let purpose = entry.name.replace(/\.[^.]+$/, "").replace(/-/g, " ").replace(/_/g, " ");
44454
- if (purpose === "index") purpose = "Memory root";
44455
- else purpose = purpose.replace(/\b\w/g, (c) => c.toUpperCase());
44456
- memoryFiles.push({ rel: relPath, purpose, mtime });
44457
- } catch {
44458
- }
44459
- }
44460
- }
44461
- }
44462
- await scanMemory((0, import_path2.resolve)(".claude/memory"), "");
44463
- if (memoryFiles.length === 0) {
44464
- lines.push("No memory files found.", "");
44465
- } else {
44466
- lines.push("| File | Purpose | Last Modified |", "| --- | --- | --- |");
44467
- for (const m of memoryFiles) {
44468
- lines.push(`| .claude/memory/${m.rel} | ${escapeMdx(m.purpose)} | ${m.mtime} |`);
44469
- }
44470
- lines.push("");
44471
- }
44472
- } catch {
44473
- lines.push("Not configured", "");
44474
- }
44475
- lines.push("## Configuration", "");
44476
- let apiKeySet = "no";
44477
- let nodeEnv = "not set";
44478
- try {
44479
- const { findEnvFile: findEnvFile2 } = await Promise.resolve().then(() => (init_config(), config_exports));
44480
- const envContent = await (0, import_promises.readFile)(findEnvFile2() ?? (0, import_path2.resolve)(".env"), "utf-8");
44481
- const apiKeyMatch = envContent.match(/^ELEVASIS_PLATFORM_KEY=(.+)$/m);
44482
- if (apiKeyMatch && apiKeyMatch[1].trim()) apiKeySet = "yes";
44483
- const nodeEnvMatch = envContent.match(/^NODE_ENV=(.+)$/m);
44484
- if (nodeEnvMatch && nodeEnvMatch[1].trim()) nodeEnv = nodeEnvMatch[1].trim();
44485
- } catch {
44486
- }
44487
- lines.push(
44488
- "| Setting | Source | Value |",
44489
- "| --- | --- | --- |",
44490
- `| SDK Version | package.json | ${SDK_VERSION} |`,
44491
- `| API Key Set | .env | ${apiKeySet} |`,
44492
- `| Node Env | .env | ${nodeEnv} |`,
44493
- ""
44494
- );
44495
- await (0, import_promises.mkdir)((0, import_path2.resolve)("docs"), { recursive: true });
44496
- await (0, import_promises.writeFile)((0, import_path2.resolve)("docs/project-map.mdx"), lines.join("\n"), "utf-8");
44497
- }
44498
- async function generateNavigationMap(docs) {
44499
- const excludedFiles = /* @__PURE__ */ new Set(["docs/navigation-map.mdx", "docs/project-map.mdx", "docs/resource-map.mdx"]);
44500
- const filtered = docs.filter((doc) => !excludedFiles.has(doc.path)).sort((a, b) => {
44501
- const orderA = a.frontmatter.order ?? 9999;
44502
- const orderB = b.frontmatter.order ?? 9999;
44503
- if (orderA !== orderB) return orderA - orderB;
44504
- return a.frontmatter.title.localeCompare(b.frontmatter.title);
44505
- });
44506
- const lines = [
44507
- "---",
44508
- "title: Navigation Map",
44509
- "description: Auto-generated table of contents for all documentation (updated on each deploy)",
44510
- "order: 997",
44511
- "---",
44512
- "",
44513
- "# Navigation Map",
44514
- "",
44515
- "> Auto-generated by `elevasis-sdk deploy`. Do not edit manually.",
44516
- "",
44517
- "| Title | Description | Path |",
44518
- "| --- | --- | --- |"
44519
- ];
44520
- for (const doc of filtered) {
44521
- lines.push(`| ${escapeMdx(doc.frontmatter.title)} | ${escapeMdx(doc.frontmatter.description)} | ${doc.path} |`);
44522
- }
44523
- lines.push("");
44524
- await (0, import_promises.mkdir)((0, import_path2.resolve)("docs"), { recursive: true });
44525
- await (0, import_promises.writeFile)((0, import_path2.resolve)("docs/navigation-map.mdx"), lines.join("\n"), "utf-8");
44526
- }
44527
44092
  function registerDeployCommand(program3) {
44528
44093
  program3.command("deploy").description(
44529
44094
  "Validate, bundle, upload, and deploy project resources\n Example: elevasis-sdk deploy --api-url http://localhost:5170"
@@ -44535,6 +44100,14 @@ function registerDeployCommand(program3) {
44535
44100
  const apiUrl = resolveApiUrl(options2.apiUrl, options2.prod);
44536
44101
  const env2 = resolveEnvironment(options2.prod);
44537
44102
  const entryPath = options2.entry ?? "./src/index.ts";
44103
+ let elevasConfig = {};
44104
+ try {
44105
+ const configModule = await loadTsModule("elevasis.config.ts");
44106
+ if (configModule.default && typeof configModule.default === "object") {
44107
+ elevasConfig = configModule.default;
44108
+ }
44109
+ } catch {
44110
+ }
44538
44111
  const authSpinner = ora("Authenticating...").start();
44539
44112
  let orgName;
44540
44113
  try {
@@ -44619,12 +44192,8 @@ function registerDeployCommand(program3) {
44619
44192
  }
44620
44193
  throw error46;
44621
44194
  }
44622
- await generateResourceMap(org);
44623
- await generateProjectMap(org);
44624
- let documentation = await scanDocumentation();
44195
+ const documentation = await scanDocumentation(elevasConfig.docsDir);
44625
44196
  if (documentation) {
44626
- await generateNavigationMap(documentation);
44627
- documentation = await scanDocumentation();
44628
44197
  console.log(
44629
44198
  source_default.gray(
44630
44199
  ` docs ${source_default.white(String(documentation.length))} file${documentation.length !== 1 ? "s" : ""}`
@@ -44771,6 +44340,14 @@ function registerCheckCommand(program3) {
44771
44340
  const entryPath = options2.entry ?? "./src/index.ts";
44772
44341
  const spinner = ora("Validating resources...").start();
44773
44342
  try {
44343
+ let elevasConfig = {};
44344
+ try {
44345
+ const configModule = await loadTsModule("elevasis.config.ts");
44346
+ if (configModule.default && typeof configModule.default === "object") {
44347
+ elevasConfig = configModule.default;
44348
+ }
44349
+ } catch {
44350
+ }
44774
44351
  const entryModule = await loadTsModule(entryPath);
44775
44352
  const org = entryModule.default;
44776
44353
  if (!org) {
@@ -44802,7 +44379,7 @@ function registerCheckCommand(program3) {
44802
44379
  if (relationshipCount > 0) {
44803
44380
  console.log(source_default.gray(` Relationships: ${relationshipCount}`));
44804
44381
  }
44805
- const documentation = await scanDocumentation();
44382
+ const documentation = await scanDocumentation(elevasConfig.docsDir);
44806
44383
  if (documentation) {
44807
44384
  console.log(
44808
44385
  source_default.gray(` Docs: ${documentation.length} file${documentation.length !== 1 ? "s" : ""}`)
@@ -44844,7 +44421,6 @@ function registerCheckCommand(program3) {
44844
44421
 
44845
44422
  // src/cli/commands/exec.ts
44846
44423
  var import_node_fs = require("node:fs");
44847
- init_config();
44848
44424
  var POLL_INTERVAL_MS = 3e3;
44849
44425
  async function pollForCompletion(resourceId, executionId, apiUrl) {
44850
44426
  const pollSpinner = ora("Waiting for completion...").start();
@@ -44964,7 +44540,6 @@ function registerExecCommand(program3) {
44964
44540
  }
44965
44541
 
44966
44542
  // src/cli/commands/resources.ts
44967
- init_config();
44968
44543
  function registerResourcesCommand(program3) {
44969
44544
  program3.command("resources").description("List deployed resources for your organization").option("--api-url <url>", "API URL").option("--json", "Output as JSON").action(wrapAction("resources", async (options2) => {
44970
44545
  const apiUrl = resolveApiUrl(options2.apiUrl);
@@ -45010,7 +44585,6 @@ function registerResourcesCommand(program3) {
45010
44585
  }
45011
44586
 
45012
44587
  // src/cli/commands/executions.ts
45013
- init_config();
45014
44588
  function registerExecutionsCommand(program3) {
45015
44589
  program3.command("executions <resourceId>").description("List execution history for a resource\n Example: elevasis-sdk executions my-workflow --limit 10").option("--api-url <url>", "API URL").option("--json", "Output as JSON").option("--limit <number>", "Limit number of results (default: 50)").option("--status <status>", "Filter by status (running|completed|failed)").action(wrapAction("executions", async (resourceId, options2) => {
45016
44590
  const apiUrl = resolveApiUrl(options2.apiUrl);
@@ -45069,7 +44643,6 @@ function registerExecutionsCommand(program3) {
45069
44643
  }
45070
44644
 
45071
44645
  // src/cli/commands/execution.ts
45072
- init_config();
45073
44646
  function registerExecutionCommand(program3) {
45074
44647
  program3.command("execution <resourceId> <executionId>").description("Get detailed information about a specific execution\n Example: elevasis-sdk execution my-workflow abc-123-uuid --logs-only").option("--api-url <url>", "API URL").option("--json", "Output raw JSON response").option("--logs-only", "Show only execution logs").option("--input", "Include input data in output").option("--result", "Include result data in output").action(wrapAction("execution", async (resourceId, executionId, options2) => {
45075
44648
  const apiUrl = resolveApiUrl(options2.apiUrl);
@@ -45172,7 +44745,6 @@ function displayLog(log) {
45172
44745
  }
45173
44746
 
45174
44747
  // src/cli/commands/deployments.ts
45175
- init_config();
45176
44748
  function registerDeploymentsCommand(program3) {
45177
44749
  program3.command("deployments").description("List deployments for your organization").option("--api-url <url>", "API URL").option("--json", "Output as JSON").action(wrapAction("deployments", async (options2) => {
45178
44750
  const apiUrl = resolveApiUrl(options2.apiUrl);
@@ -45233,7 +44805,6 @@ function registerDeploymentsCommand(program3) {
45233
44805
  }
45234
44806
 
45235
44807
  // src/cli/commands/describe.ts
45236
- init_config();
45237
44808
  function hasSchemaContent(schema) {
45238
44809
  return Object.keys(schema).some((k) => k !== "$schema");
45239
44810
  }
@@ -45303,9 +44874,6 @@ function registerDescribeCommand(program3) {
45303
44874
  );
45304
44875
  }
45305
44876
 
45306
- // src/cli/commands/creds/creds.ts
45307
- init_config();
45308
-
45309
44877
  // src/cli/commands/creds/creds-list.ts
45310
44878
  async function listCreds(apiUrl, json2) {
45311
44879
  const spinner = ora("Fetching credentials...").start();
@@ -45516,9 +45084,6 @@ function registerCredsCommand(program3) {
45516
45084
  }));
45517
45085
  }
45518
45086
 
45519
- // src/cli/commands/error/error.ts
45520
- init_config();
45521
-
45522
45087
  // src/cli/commands/error/error-resolve.ts
45523
45088
  async function resolveError(apiUrl, errorId) {
45524
45089
  const spinner = ora("Resolving error...").start();
@@ -45555,7 +45120,6 @@ function registerErrorCommand(program3) {
45555
45120
  }
45556
45121
 
45557
45122
  // src/cli/commands/rename.ts
45558
- init_config();
45559
45123
  function registerRenameCommand(program3) {
45560
45124
  program3.command("rename <oldResourceId>").description("Rename a resource ID across all platform tables (dry run by default)").requiredOption("--to <newResourceId>", "New resource ID").option("--execute", "Apply the rename (default: dry run preview only)").option("--prod", "Target production (overrides NODE_ENV=development)").option("--api-url <url>", "API URL").action(
45561
45125
  wrapAction("rename", async (oldResourceId, options2) => {
@@ -45594,7 +45158,6 @@ function registerRenameCommand(program3) {
45594
45158
  }
45595
45159
 
45596
45160
  // src/cli/commands/project/projects.ts
45597
- init_config();
45598
45161
  function registerProjectList(program3) {
45599
45162
  program3.command("project:list").description("List all projects\n Example: elevasis-sdk project:list --kind internal").option("--kind <kind>", "Filter by kind: client_engagement | internal | research | other").option("--status <status>", "Filter by status: active | on_track | at_risk | blocked | completed | paused").option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
45600
45163
  wrapAction("project:list", async (options2) => {
@@ -45724,7 +45287,6 @@ Project ${id} deleted.`));
45724
45287
  }
45725
45288
 
45726
45289
  // src/cli/commands/project/milestones.ts
45727
- init_config();
45728
45290
  function registerMilestoneList(program3) {
45729
45291
  program3.command("project:milestone:list").description("List milestones for a project\n Example: elevasis-sdk project:milestone:list --project <uuid>").requiredOption("--project <project-id>", "Project ID (UUID)").option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
45730
45292
  wrapAction("project:milestone:list", async (options2) => {
@@ -45833,7 +45395,6 @@ Milestone ${id} deleted.`));
45833
45395
  }
45834
45396
 
45835
45397
  // src/cli/commands/project/tasks.ts
45836
- init_config();
45837
45398
  function registerTaskList(program3) {
45838
45399
  program3.command("project:task:list").description(
45839
45400
  "List tasks for a project\n Example: elevasis-sdk project:task:list --project <uuid> --status in_progress"
@@ -46103,7 +45664,6 @@ Resume context saved for task ${id}`));
46103
45664
  }
46104
45665
 
46105
45666
  // src/cli/commands/project/notes.ts
46106
- init_config();
46107
45667
  function registerNoteList(program3) {
46108
45668
  program3.command("project:note:list").description("List notes for a project\n Example: elevasis-sdk project:note:list --project <uuid>").requiredOption("--project <project-id>", "Project ID (UUID)").option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
46109
45669
  wrapAction("project:note:list", async (options2) => {
@@ -46216,7 +45776,6 @@ function registerProjectCommands(program3) {
46216
45776
  }
46217
45777
 
46218
45778
  // src/cli/index.ts
46219
- init_config();
46220
45779
  var envPath = findEnvFile();
46221
45780
  if (envPath) {
46222
45781
  (0, import_dotenv.config)({ path: envPath, override: true });