@skillrecordings/cli 0.14.1 → 0.14.3

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/index.js CHANGED
@@ -1,23 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- import {
3
- createFilterStats,
4
- formatFilterStats,
5
- shouldFilter,
6
- updateFilterStats
7
- } from "./chunk-5ACOI6Z3.js";
8
- import {
9
- Blob as Blob2,
10
- File as File2,
11
- isFile,
12
- isFunction
13
- } from "./chunk-PWWRCN5W.js";
14
- import {
15
- SUPPORT_AGENT_PROMPT,
16
- getApp,
17
- getOutcomeHistory,
18
- getRedis
19
- } from "./chunk-RA5G6CYF.js";
20
- import "./chunk-F4EM72IH.js";
21
2
  import {
22
3
  DEFAULT_CATEGORY_TAG_MAPPING,
23
4
  FrontApiError,
@@ -39,15 +20,44 @@ import {
39
20
  runPipeline,
40
21
  validate,
41
22
  validateSync
42
- } from "./chunk-FT5L3SDS.js";
43
- import "./chunk-KEV3QKXP.js";
23
+ } from "./chunk-A5RBWKVF.js";
44
24
  import "./chunk-HK3PEWFD.js";
25
+ import {
26
+ createFilterStats,
27
+ formatFilterStats,
28
+ shouldFilter,
29
+ updateFilterStats
30
+ } from "./chunk-5ACOI6Z3.js";
31
+ import {
32
+ Blob as Blob2,
33
+ File as File2,
34
+ isFile,
35
+ isFunction
36
+ } from "./chunk-PWWRCN5W.js";
37
+ import {
38
+ SUPPORT_AGENT_PROMPT,
39
+ getApp,
40
+ getOutcomeHistory,
41
+ getRedis
42
+ } from "./chunk-L6YTBYNV.js";
43
+ import "./chunk-KEV3QKXP.js";
44
+ import "./chunk-ZNF7XD2S.js";
45
+ import {
46
+ upsertVector
47
+ } from "./chunk-H3D6VCME.js";
48
+ import "./chunk-F4EM72IH.js";
45
49
  import "./chunk-WYKL32C3.js";
46
50
  import {
47
51
  MemoryService,
48
52
  VotingService,
49
53
  calculateConfidence
50
54
  } from "./chunk-MLNDSBZ4.js";
55
+ import "./chunk-MG37YDAK.js";
56
+ import {
57
+ OnePasswordProvider,
58
+ SECRET_REFS,
59
+ createSecretsProvider
60
+ } from "./chunk-JMAMXCWW.js";
51
61
  import {
52
62
  ActionsTable,
53
63
  AppsTable,
@@ -62,11 +72,6 @@ import {
62
72
  or,
63
73
  sql
64
74
  } from "./chunk-V34YUISF.js";
65
- import "./chunk-ZNF7XD2S.js";
66
- import {
67
- upsertVector
68
- } from "./chunk-H3D6VCME.js";
69
- import "./chunk-MG37YDAK.js";
70
75
  import {
71
76
  __commonJS,
72
77
  __dirname,
@@ -74567,6 +74572,29 @@ async function copy(src, dest) {
74567
74572
  await cp(src, dest, { recursive: true, force: true });
74568
74573
  }
74569
74574
 
74575
+ // src/core/user-config.ts
74576
+ var USER_CONFIG_DIR_NAME = "skill";
74577
+ var USER_CONFIG_PATHS = {
74578
+ /** Age encryption private key file */
74579
+ ageKey: "age.key",
74580
+ /** Encrypted environment variables file */
74581
+ envEncrypted: ".env.user.encrypted",
74582
+ /** Optional plaintext config file */
74583
+ configJson: "config.json"
74584
+ };
74585
+ function getUserConfigDir(configDir) {
74586
+ if (configDir) return configDir;
74587
+ const xdgConfigHome = process.env.XDG_CONFIG_HOME;
74588
+ if (xdgConfigHome && xdgConfigHome.trim() !== "") {
74589
+ return join(xdgConfigHome, USER_CONFIG_DIR_NAME);
74590
+ }
74591
+ const home = homedir() || process.env.HOME || "/tmp";
74592
+ return join(home, ".config", USER_CONFIG_DIR_NAME);
74593
+ }
74594
+ function getUserConfigPath(fileName, configDir) {
74595
+ return join(getUserConfigDir(configDir), fileName);
74596
+ }
74597
+
74570
74598
  // src/core/config-loader.ts
74571
74599
  function parseEnvContent(content) {
74572
74600
  const env = {};
@@ -74582,7 +74610,85 @@ function parseEnvContent(content) {
74582
74610
  }
74583
74611
  return env;
74584
74612
  }
74613
+ async function decryptEnvFile(encryptedPath) {
74614
+ const { existsSync: existsSync15 } = await import("fs");
74615
+ const { readFile: readFile10 } = await import("fs/promises");
74616
+ if (!existsSync15(encryptedPath)) {
74617
+ return {};
74618
+ }
74619
+ const ageKey = await getAgeKeyFrom1Password();
74620
+ if (!ageKey) {
74621
+ return {};
74622
+ }
74623
+ try {
74624
+ const { decrypt } = await import("./crypto-MTXIOCYL.js");
74625
+ const encrypted = await readFile10(encryptedPath);
74626
+ const decrypted = await decrypt(encrypted, ageKey);
74627
+ return parseEnvContent(decrypted);
74628
+ } catch {
74629
+ return {};
74630
+ }
74631
+ }
74632
+ async function getAgeKeyFrom1Password() {
74633
+ if (!process.env.OP_SERVICE_ACCOUNT_TOKEN) {
74634
+ return null;
74635
+ }
74636
+ try {
74637
+ const { OnePasswordProvider: OnePasswordProvider2 } = await import("./secrets-MGVPGMFJ.js");
74638
+ const op = new OnePasswordProvider2();
74639
+ if (!await op.isAvailable()) {
74640
+ return null;
74641
+ }
74642
+ return await op.resolve("op://Support/skill-cli-age-key/private_key");
74643
+ } catch {
74644
+ return null;
74645
+ }
74646
+ }
74647
+ async function loadShippedDefaults(cliRoot2) {
74648
+ const encryptedPath = resolve(cliRoot2, ".env.encrypted");
74649
+ try {
74650
+ return await decryptEnvFile(encryptedPath);
74651
+ } catch {
74652
+ return {};
74653
+ }
74654
+ }
74655
+ async function loadUserOverrides(configDir) {
74656
+ const encryptedPath = getUserConfigPath(
74657
+ USER_CONFIG_PATHS.envEncrypted,
74658
+ configDir
74659
+ );
74660
+ try {
74661
+ return await decryptEnvFile(encryptedPath);
74662
+ } catch {
74663
+ return {};
74664
+ }
74665
+ }
74666
+ async function loadConfigChain(cliRoot2, configDir) {
74667
+ const root2 = cliRoot2 ?? resolve(import.meta.dirname, "../..");
74668
+ const shipped = await loadShippedDefaults(root2);
74669
+ const user = await loadUserOverrides(configDir);
74670
+ const env = {};
74671
+ const provenance = /* @__PURE__ */ new Map();
74672
+ for (const [key, value] of Object.entries(shipped)) {
74673
+ env[key] = value;
74674
+ provenance.set(key, "shipped");
74675
+ }
74676
+ for (const [key, value] of Object.entries(user)) {
74677
+ env[key] = value;
74678
+ provenance.set(key, "user");
74679
+ }
74680
+ return { env, provenance };
74681
+ }
74585
74682
  var globalProvenance = /* @__PURE__ */ new Map();
74683
+ async function initConfig(cliRoot2, configDir) {
74684
+ const result = await loadConfigChain(cliRoot2, configDir);
74685
+ globalProvenance = result.provenance;
74686
+ for (const [key, value] of Object.entries(result.env)) {
74687
+ if (!process.env[key]) {
74688
+ process.env[key] = value;
74689
+ }
74690
+ }
74691
+ }
74586
74692
  function getKeyProvenance(key) {
74587
74693
  return globalProvenance.get(key);
74588
74694
  }
@@ -74857,172 +74963,6 @@ var TableFormatter = class extends BaseFormatter {
74857
74963
  }
74858
74964
  };
74859
74965
 
74860
- // src/core/secrets.ts
74861
- init_esm_shims();
74862
-
74863
- // src/core/secret-refs.ts
74864
- init_esm_shims();
74865
- var SECRET_REFS = {
74866
- DATABASE_URL: "op://Support/skill-cli/DATABASE_URL",
74867
- FRONT_API_TOKEN: "op://Support/skill-cli/FRONT_API_TOKEN",
74868
- FRONT_WEBHOOK_SECRET: "op://Support/skill-cli/FRONT_WEBHOOK_SECRET",
74869
- SUPPORT_WEBHOOK_SECRET: "op://Support/skill-cli/SUPPORT_WEBHOOK_SECRET",
74870
- INNGEST_SIGNING_KEY: "op://Support/skill-cli/INNGEST_SIGNING_KEY",
74871
- INNGEST_EVENT_KEY: "op://Support/skill-cli/INNGEST_EVENT_KEY",
74872
- SLACK_BOT_TOKEN: "op://Support/skill-cli/SLACK_BOT_TOKEN",
74873
- SLACK_SIGNING_SECRET: "op://Support/skill-cli/SLACK_SIGNING_SECRET",
74874
- SLACK_APPROVAL_CHANNEL: "op://Support/skill-cli/SLACK_APPROVAL_CHANNEL",
74875
- UPSTASH_REDIS_REST_URL: "op://Support/skill-cli/UPSTASH_REDIS_REST_URL",
74876
- UPSTASH_REDIS_REST_TOKEN: "op://Support/skill-cli/UPSTASH_REDIS_REST_TOKEN",
74877
- UPSTASH_VECTOR_REST_URL: "op://Support/skill-cli/UPSTASH_VECTOR_REST_URL",
74878
- UPSTASH_VECTOR_REST_TOKEN: "op://Support/skill-cli/UPSTASH_VECTOR_REST_TOKEN",
74879
- STRIPE_SECRET_KEY: "op://Support/skill-cli/STRIPE_SECRET_KEY",
74880
- STRIPE_CONNECT_CLIENT_ID: "op://Support/skill-cli/STRIPE_CONNECT_CLIENT_ID",
74881
- STRIPE_WEBHOOK_SECRET: "op://Support/skill-cli/STRIPE_WEBHOOK_SECRET",
74882
- AXIOM_TOKEN: "op://Support/skill-cli/AXIOM_TOKEN",
74883
- LANGFUSE_PUBLIC_KEY: "op://Support/skill-cli/LANGFUSE_PUBLIC_KEY",
74884
- LANGFUSE_SECRET_KEY: "op://Support/skill-cli/LANGFUSE_SECRET_KEY",
74885
- BETTERAUTH_SECRET: "op://Support/skill-cli/BETTERAUTH_SECRET",
74886
- MYSQL_HOST: "op://Support/skill-cli/MYSQL_HOST",
74887
- MYSQL_PORT: "op://Support/skill-cli/MYSQL_PORT",
74888
- MYSQL_USER: "op://Support/skill-cli/MYSQL_USER",
74889
- MYSQL_PASSWORD: "op://Support/skill-cli/MYSQL_PASSWORD",
74890
- MYSQL_DATABASE: "op://Support/skill-cli/MYSQL_DATABASE",
74891
- QDRANT_URL: "op://Support/skill-cli/QDRANT_URL",
74892
- QDRANT_COLLECTION: "op://Support/skill-cli/QDRANT_COLLECTION",
74893
- OLLAMA_BASE_URL: "op://Support/skill-cli/OLLAMA_BASE_URL",
74894
- EMBEDDING_MODEL: "op://Support/skill-cli/EMBEDDING_MODEL",
74895
- AGE_SECRET_KEY: "op://Support/skill-cli-age-key/private_key"
74896
- };
74897
-
74898
- // src/core/secrets.ts
74899
- var REF_TO_ENV_KEY = new Map(
74900
- Object.entries(SECRET_REFS).map(([envKey, ref]) => [ref, envKey])
74901
- );
74902
- var OnePasswordProvider = class {
74903
- name = "1password";
74904
- cache = /* @__PURE__ */ new Map();
74905
- clientPromise;
74906
- sdkPromise;
74907
- integrationName;
74908
- integrationVersion;
74909
- constructor(options = {}) {
74910
- this.integrationName = options.integrationName ?? "skill-cli";
74911
- this.integrationVersion = options.integrationVersion ?? "0.0.0";
74912
- }
74913
- async isAvailable() {
74914
- if (!process.env.OP_SERVICE_ACCOUNT_TOKEN) {
74915
- return false;
74916
- }
74917
- try {
74918
- await this.getClient();
74919
- return true;
74920
- } catch {
74921
- return false;
74922
- }
74923
- }
74924
- async resolve(ref) {
74925
- if (this.cache.has(ref)) {
74926
- return this.cache.get(ref);
74927
- }
74928
- const client = await this.getClient();
74929
- const secretsClient = client.secrets;
74930
- const value = await secretsClient.resolve(ref);
74931
- if (!value) {
74932
- throw new Error(`1Password returned empty secret for ${ref}`);
74933
- }
74934
- this.cache.set(ref, value);
74935
- return value;
74936
- }
74937
- async resolveAll(refs) {
74938
- if (refs.length === 0) {
74939
- return {};
74940
- }
74941
- const client = await this.getClient();
74942
- const secrets = await this.resolveAllWithClient(client, refs);
74943
- for (const [ref, value] of Object.entries(secrets)) {
74944
- this.cache.set(ref, value);
74945
- }
74946
- return secrets;
74947
- }
74948
- async getClient() {
74949
- if (this.clientPromise) {
74950
- return this.clientPromise;
74951
- }
74952
- const token = process.env.OP_SERVICE_ACCOUNT_TOKEN;
74953
- if (!token) {
74954
- throw new Error("OP_SERVICE_ACCOUNT_TOKEN not set");
74955
- }
74956
- const { createClient } = await this.getSdk();
74957
- this.clientPromise = createClient({
74958
- auth: token,
74959
- integrationName: this.integrationName,
74960
- integrationVersion: this.integrationVersion
74961
- });
74962
- return this.clientPromise;
74963
- }
74964
- async getSdk() {
74965
- if (this.sdkPromise) {
74966
- return this.sdkPromise;
74967
- }
74968
- this.sdkPromise = import("@1password/sdk");
74969
- return this.sdkPromise;
74970
- }
74971
- async resolveAllWithClient(client, refs) {
74972
- const secretsClient = client.secrets;
74973
- if (typeof secretsClient.resolveAll === "function") {
74974
- const resolved = await secretsClient.resolveAll(refs);
74975
- if (Array.isArray(resolved)) {
74976
- const entries2 = resolved.map((item) => {
74977
- if (item && typeof item === "object" && "reference" in item && "value" in item) {
74978
- return [
74979
- item.reference,
74980
- String(item.value)
74981
- ];
74982
- }
74983
- return null;
74984
- }).filter((entry) => Boolean(entry));
74985
- return Object.fromEntries(entries2);
74986
- }
74987
- return resolved;
74988
- }
74989
- const entries = await Promise.all(
74990
- refs.map(async (ref) => [ref, await this.resolve(ref)])
74991
- );
74992
- return Object.fromEntries(entries);
74993
- }
74994
- };
74995
- var EnvProvider = class {
74996
- name = "env";
74997
- async isAvailable() {
74998
- return true;
74999
- }
75000
- async resolve(ref) {
75001
- const envKey = REF_TO_ENV_KEY.get(ref);
75002
- if (!envKey) {
75003
- throw new Error(`No env mapping found for secret ref: ${ref}`);
75004
- }
75005
- const value = process.env[envKey];
75006
- if (!value) {
75007
- throw new Error(`Missing environment secret for ${envKey}`);
75008
- }
75009
- return value;
75010
- }
75011
- async resolveAll(refs) {
75012
- const entries = await Promise.all(
75013
- refs.map(async (ref) => [ref, await this.resolve(ref)])
75014
- );
75015
- return Object.fromEntries(entries);
75016
- }
75017
- };
75018
- async function createSecretsProvider() {
75019
- const onePassword = new OnePasswordProvider();
75020
- if (await onePassword.isAvailable()) {
75021
- return onePassword;
75022
- }
75023
- return new EnvProvider();
75024
- }
75025
-
75026
74966
  // src/core/context.ts
75027
74967
  async function createContext(overrides = {}) {
75028
74968
  const signal = overrides.signal ?? new AbortController().signal;
@@ -77088,16 +77028,16 @@ import { existsSync as existsSync3, mkdirSync, writeFileSync as writeFileSync3 }
77088
77028
  import { homedir as homedir2 } from "os";
77089
77029
  import { join as join2 } from "path";
77090
77030
  import { generateIdentity, identityToRecipient } from "age-encryption";
77091
- function getUserConfigDir() {
77031
+ function getUserConfigDir2() {
77092
77032
  return join2(homedir2(), ".config", "skill");
77093
77033
  }
77094
77034
  function getAgeKeyPath() {
77095
- return join2(getUserConfigDir(), "age.key");
77035
+ return join2(getUserConfigDir2(), "age.key");
77096
77036
  }
77097
77037
  async function configInitAction(ctx, options = {}) {
77098
77038
  const outputJson = options.json === true || ctx.format === "json";
77099
77039
  const keyPath = getAgeKeyPath();
77100
- const configDir = getUserConfigDir();
77040
+ const configDir = getUserConfigDir2();
77101
77041
  if (existsSync3(keyPath) && !options.force) {
77102
77042
  const result = {
77103
77043
  success: false,
@@ -77158,7 +77098,7 @@ init_esm_shims();
77158
77098
  import { existsSync as existsSync4, readFileSync as readFileSync2, writeFileSync as writeFileSync4 } from "fs";
77159
77099
  import { Decrypter, Encrypter, identityToRecipient as identityToRecipient2 } from "age-encryption";
77160
77100
  function getEncryptedConfigPath() {
77161
- return `${getUserConfigDir()}/.env.user.encrypted`;
77101
+ return `${getUserConfigDir2()}/.env.user.encrypted`;
77162
77102
  }
77163
77103
  function parseKeyValue(input2) {
77164
77104
  const match = input2.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
@@ -81270,7 +81210,7 @@ async function runValidateEval(ctx, scenarios, options) {
81270
81210
  return results;
81271
81211
  }
81272
81212
  async function runE2EEval(ctx, scenarios, options) {
81273
- const { runPipeline: runPipeline2 } = await import("./pipeline-MJVBAX5W.js");
81213
+ const { runPipeline: runPipeline2 } = await import("./pipeline-FGI6ICWM.js");
81274
81214
  const concurrency = options.parallel || 1;
81275
81215
  let completed = 0;
81276
81216
  const outputJson = options.outputJson ?? false;
@@ -117427,7 +117367,7 @@ var handlePipelineError = (ctx, error, message, suggestion = "Verify inputs and
117427
117367
  async function runPipelineCommand(ctx, opts) {
117428
117368
  const outputJson = opts.json === true || ctx.format === "json";
117429
117369
  try {
117430
- const { runPipeline: runPipeline2 } = await import("./pipeline-MJVBAX5W.js");
117370
+ const { runPipeline: runPipeline2 } = await import("./pipeline-FGI6ICWM.js");
117431
117371
  const result = await runPipeline2({
117432
117372
  message: {
117433
117373
  subject: opts.subject,
@@ -119890,6 +119830,7 @@ function createMcpServer(options = {}) {
119890
119830
 
119891
119831
  // src/index.ts
119892
119832
  var cliRoot = resolve8(import.meta.dirname, "..");
119833
+ await initConfig(cliRoot);
119893
119834
  var plaintextEnv = loadPlaintextEnv(cliRoot);
119894
119835
  var envLoaded = false;
119895
119836
  for (const [key, value] of Object.entries(plaintextEnv)) {
@@ -119902,9 +119843,9 @@ if (!envLoaded && !process.env.DATABASE_URL) {
119902
119843
  process.env.SKIP_ENV_VALIDATION = "1";
119903
119844
  }
119904
119845
  var runtimeTarget = `bun-${process.platform}-${process.arch}`;
119905
- var buildVersion = typeof BUILD_VERSION !== "undefined" && BUILD_VERSION.length > 0 ? BUILD_VERSION : "0.0.0-dev";
119906
- var buildCommit = typeof BUILD_COMMIT !== "undefined" && BUILD_COMMIT.length > 0 ? BUILD_COMMIT : "dev";
119907
- var buildTarget = typeof BUILD_TARGET !== "undefined" && BUILD_TARGET.length > 0 ? BUILD_TARGET : runtimeTarget;
119846
+ var buildVersion = "0.14.3".length > 0 ? "0.14.3" : "0.0.0-dev";
119847
+ var buildCommit = "ba0a512".length > 0 ? "ba0a512" : "dev";
119848
+ var buildTarget = "node".length > 0 ? "node" : runtimeTarget;
119908
119849
  var isDevBuild = buildVersion.includes("dev") || buildCommit === "dev";
119909
119850
  var versionLabel = `skill v${buildVersion} (${buildCommit}) ${buildTarget}`;
119910
119851
  var program2 = new Command4();