@aident-ai/cli 0.2.1 → 0.2.2-rc.ci.32837080953.1

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 (4) hide show
  1. package/README.md +5 -0
  2. package/dist/cli.mjs +826 -297
  3. package/dist/dsh.mjs +69 -25
  4. package/package.json +17 -17
package/dist/dsh.mjs CHANGED
@@ -531,7 +531,7 @@ import { join as join2 } from "node:path";
531
531
  // src/config.ts
532
532
  import { mkdir, readFile, writeFile } from "node:fs/promises";
533
533
  import { homedir } from "node:os";
534
- import { join } from "node:path";
534
+ import { dirname, join } from "node:path";
535
535
 
536
536
  // src/packages.ts
537
537
  var CLI_PACKAGES = ["loadout", "playbook", "intern"];
@@ -601,18 +601,20 @@ function getLoadoutHostForLegacyAidentHost(host) {
601
601
  }
602
602
 
603
603
  // src/config.ts
604
- function getAidentDir() {
605
- const home = process.env.HOME || process.env.USERPROFILE || homedir();
604
+ function getAidentDir(home = process.env.HOME || process.env.USERPROFILE || homedir()) {
606
605
  return join(home, ".aident");
607
606
  }
608
607
  function getConfigFile() {
609
608
  return join(getAidentDir(), "config.json");
610
609
  }
610
+ function getConfigFileForHome(home) {
611
+ return join(getAidentDir(home), "config.json");
612
+ }
611
613
  var DEFAULT_BASE_URL = "https://loadout.aident.ai";
612
614
  var CONFIG_KEYS = ["baseUrl", "packages"];
613
- async function readConfig() {
615
+ async function readConfig(configFile = getConfigFile()) {
614
616
  try {
615
- const text = await readFile(getConfigFile(), "utf-8");
617
+ const text = await readFile(configFile, "utf-8");
616
618
  const parsed = JSON.parse(text);
617
619
  if (!parsed || typeof parsed !== "object")
618
620
  return {};
@@ -623,15 +625,15 @@ async function readConfig() {
623
625
  return {};
624
626
  }
625
627
  }
626
- async function writeConfig(config) {
627
- await mkdir(getAidentDir(), { recursive: true, mode: 448 });
628
- await writeFile(getConfigFile(), JSON.stringify(config, null, 2) + `
628
+ async function writeConfig(config, configFile = getConfigFile()) {
629
+ await mkdir(dirname(configFile), { recursive: true, mode: 448 });
630
+ await writeFile(configFile, JSON.stringify(config, null, 2) + `
629
631
  `, { mode: 420 });
630
632
  }
631
- async function setConfigValue(key, value) {
632
- const config = await readConfig();
633
+ async function setConfigValue(key, value, configFile = getConfigFile()) {
634
+ const config = await readConfig(configFile);
633
635
  config[key] = value;
634
- await writeConfig(config);
636
+ await writeConfig(config, configFile);
635
637
  }
636
638
  async function unsetConfigValue(key) {
637
639
  const config = await readConfig();
@@ -655,6 +657,10 @@ async function resolveDefaultPackages() {
655
657
  const config = await readConfig();
656
658
  return normalizeCliPackages(config.packages ?? DEFAULT_CLI_PACKAGES);
657
659
  }
660
+ async function resolveOriginClientName() {
661
+ const config = await readConfig();
662
+ return typeof config.originClientName === "string" && config.originClientName.trim() ? config.originClientName.trim() : null;
663
+ }
658
664
  function isKnownConfigKey(key) {
659
665
  return CONFIG_KEYS.includes(key);
660
666
  }
@@ -669,7 +675,8 @@ function normalizeBaseUrl(url) {
669
675
  }
670
676
 
671
677
  // src/version.ts
672
- var VERSION = "0.2.1";
678
+ var VERSION = "0.2.2-rc.ci.32837080953.1";
679
+ var DESKTOP_VERSION = process.env.AIDENT_DESKTOP_VERSION?.trim() || undefined;
673
680
 
674
681
  // src/catalogCache.ts
675
682
  var CACHE_TTL_MS = 5 * 60 * 1000;
@@ -721,12 +728,12 @@ function isCommandCatalog(value) {
721
728
  // src/loadoutSkill.ts
722
729
  import { createHash as createHash3 } from "node:crypto";
723
730
  import { lstat as lstat3, readdir as readdir2, readFile as readFile5, realpath as realpath2 } from "node:fs/promises";
724
- import { basename, dirname as dirname3, join as join6 } from "node:path";
731
+ import { basename, dirname as dirname4, join as join6 } from "node:path";
725
732
 
726
733
  // src/loadoutSkillHosts.ts
727
734
  import { existsSync } from "node:fs";
728
735
  import { homedir as homedir2 } from "node:os";
729
- import { dirname, isAbsolute, join as join3, relative, resolve } from "node:path";
736
+ import { dirname as dirname2, isAbsolute, join as join3, relative, resolve } from "node:path";
730
737
  function getLoadoutSkillTargets(cwd = process.cwd(), home = homedir2(), env = process.env) {
731
738
  const targets = [];
732
739
  const targetsByPath = new Map;
@@ -811,7 +818,7 @@ function getProjectRoots(cwd) {
811
818
  roots.push(current);
812
819
  if (existsSync(join3(current, ".git")))
813
820
  return roots;
814
- const parent = dirname(current);
821
+ const parent = dirname2(current);
815
822
  if (parent === current)
816
823
  return [start];
817
824
  current = parent;
@@ -900,7 +907,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
900
907
  import { constants } from "node:fs";
901
908
  import { access, lstat as lstat2, mkdir as mkdir4, readFile as readFile4, realpath, rename as rename2, symlink, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
902
909
  import { homedir as homedir3 } from "node:os";
903
- import { delimiter, dirname as dirname2, isAbsolute as isAbsolute2, join as join5, posix, win32 as win322 } from "node:path";
910
+ import { delimiter, dirname as dirname3, isAbsolute as isAbsolute2, join as join5, posix, win32 as win322 } from "node:path";
904
911
 
905
912
  // src/directoryLock.ts
906
913
  import { randomUUID } from "node:crypto";
@@ -5660,7 +5667,7 @@ function getPackageManagedCliReplacementStatePath(homeDir) {
5660
5667
  async function writePackageManagedCliReplacementState(homeDir, state) {
5661
5668
  const path = getPackageManagedCliReplacementStatePath(homeDir);
5662
5669
  const temporary = `${path}.${state.transactionId}.tmp`;
5663
- await mkdir4(dirname2(path), { recursive: true, mode: 448 });
5670
+ await mkdir4(dirname3(path), { recursive: true, mode: 448 });
5664
5671
  await writeFile4(temporary, `${JSON.stringify(state)}
5665
5672
  `, { mode: 384, flag: "wx" });
5666
5673
  await rename2(temporary, path);
@@ -5692,7 +5699,7 @@ async function removePackageManagedCliReplacementState(homeDir) {
5692
5699
  await unlink2(getPackageManagedCliReplacementStatePath(homeDir));
5693
5700
  }
5694
5701
  async function createNativeCliSymlink(target, path) {
5695
- await mkdir4(dirname2(path), { recursive: true });
5702
+ await mkdir4(dirname3(path), { recursive: true });
5696
5703
  await symlink(target, path, process.platform === "win32" ? "file" : undefined);
5697
5704
  }
5698
5705
  function getManagerCommand(method, platform = process.platform) {
@@ -6198,6 +6205,15 @@ var KNOWN_CLEAN_LOADOUT_SKILL_REQUIRED_FILE_GIT_BLOB_SHA1 = {
6198
6205
  "references/mcp.md": "3e92c88b1ef94e863bd4ce977a36abc3a0df2138",
6199
6206
  "references/troubleshooting.md": "f819915c8829b028630ef1f8f29ae9433a072ca8"
6200
6207
  }
6208
+ ],
6209
+ "0.4.17": [
6210
+ {
6211
+ "SKILL.md": "7c4225f1e8bc400ead1197e1ea8ddaa79197e160",
6212
+ "references/api.md": "240b913e8c85492f2441326033db91747c54863e",
6213
+ "references/loadout.md": "82bc313f84b430aecafe8cca7512db7e78e73690",
6214
+ "references/mcp.md": "4b59cce600b87e1ae2c7cbda8b61f79cd5776fc4",
6215
+ "references/troubleshooting.md": "f819915c8829b028630ef1f8f29ae9433a072ca8"
6216
+ }
6201
6217
  ]
6202
6218
  };
6203
6219
  async function fetchLoadoutSkillMetadata(baseUrl) {
@@ -6236,7 +6252,7 @@ async function getLoadoutSkillInventory(candidates = getInstalledLoadoutSkillCan
6236
6252
  const resolvedManagedReleasesRoot = await realpath2(managedReleasesRoot).catch(() => managedReleasesRoot);
6237
6253
  const inspected = await Promise.all(candidates.map(async (candidate) => ({
6238
6254
  candidate,
6239
- installation: await inspectLoadoutSkillDirectory(dirname3(candidate.path), resolvedManagedReleasesRoot)
6255
+ installation: await inspectLoadoutSkillDirectory(dirname4(candidate.path), resolvedManagedReleasesRoot)
6240
6256
  })));
6241
6257
  const installations = [];
6242
6258
  const byRealPath = new Map;
@@ -6392,7 +6408,7 @@ function isManagedReleasePath(directory, artifactSha256, managedReleasesRoot) {
6392
6408
  const normalized = path.replaceAll("\\", "/");
6393
6409
  return process.platform === "win32" ? normalized.toLowerCase() : normalized;
6394
6410
  };
6395
- return normalize(dirname3(directory)) === normalize(managedReleasesRoot) && normalize(basename(directory)) === normalize(artifactSha256);
6411
+ return normalize(dirname4(directory)) === normalize(managedReleasesRoot) && normalize(basename(directory)) === normalize(artifactSha256);
6396
6412
  }
6397
6413
  function stateForMissing(error) {
6398
6414
  return isMissingError(error) ? "missing" /* Missing */ : "malformed" /* Malformed */;
@@ -6456,6 +6472,30 @@ function isLoadoutSkillNotice(value) {
6456
6472
  return typeof body.id === "string" && (body.severity === "info" || body.severity === "warning") && typeof body.message === "string";
6457
6473
  }
6458
6474
 
6475
+ // ../web/shared/loadout/LoadoutOriginIdentity.ts
6476
+ var AIDENT_LOADOUT_ORIGIN_CLIENT_HEADER = "x-aident-loadout-origin-client";
6477
+ var AIDENT_LOADOUT_ORIGIN_CLIENT_QUERY_PARAM = "loadout_origin";
6478
+ var LEGACY_LOADOUT_AUDIT_AGENT_NAMES = new Set([
6479
+ "platform",
6480
+ "cli-exec",
6481
+ "mcp",
6482
+ "tool-exec",
6483
+ "capability-exec",
6484
+ "integration-runtime"
6485
+ ]);
6486
+ function normalizeLoadoutOriginClientName(value) {
6487
+ const normalized = value?.trim().replace(/\s+/g, " ");
6488
+ return normalized && normalized.length <= 160 ? normalized : null;
6489
+ }
6490
+ function withLoadoutOriginClient(url, clientName) {
6491
+ const normalized = normalizeLoadoutOriginClientName(clientName);
6492
+ if (!normalized)
6493
+ return url;
6494
+ const resolved = new URL(url);
6495
+ resolved.searchParams.set(AIDENT_LOADOUT_ORIGIN_CLIENT_QUERY_PARAM, normalized);
6496
+ return resolved.toString();
6497
+ }
6498
+
6459
6499
  // src/client.ts
6460
6500
  var CLI_CATALOG_DURATION_HEADER = "x-aident-cli-catalog-duration-ms";
6461
6501
  var CLI_LOCALE = Intl.DateTimeFormat().resolvedOptions().locale;
@@ -6467,9 +6507,10 @@ class CliClient {
6467
6507
  installedSkillVersion;
6468
6508
  loadoutSkillInventory;
6469
6509
  favoriteSkillsStateToken;
6510
+ originClientName;
6470
6511
  commandOperations = new Map;
6471
6512
  catalogDurationMs = null;
6472
- constructor(creds, credentialSource = "stored", packages, installedSkillVersion = null, loadoutSkillInventory = null, favoriteSkillsStateToken = null) {
6513
+ constructor(creds, credentialSource = "stored", packages, installedSkillVersion = null, loadoutSkillInventory = null, favoriteSkillsStateToken = null, originClientName = null) {
6473
6514
  this.creds = creds;
6474
6515
  this.credentialSource = credentialSource;
6475
6516
  if (packages.length === 0)
@@ -6478,6 +6519,7 @@ class CliClient {
6478
6519
  this.installedSkillVersion = installedSkillVersion;
6479
6520
  this.loadoutSkillInventory = loadoutSkillInventory;
6480
6521
  this.favoriteSkillsStateToken = favoriteSkillsStateToken;
6522
+ this.originClientName = originClientName;
6481
6523
  }
6482
6524
  get baseUrl() {
6483
6525
  return this.creds.base_url.replace(/\/+$/, "");
@@ -6603,6 +6645,7 @@ class CliClient {
6603
6645
  "Accept-Language": CLI_LOCALE,
6604
6646
  "User-Agent": `@aident-ai/cli/${VERSION}`,
6605
6647
  [AIDENT_UPDATE_PROTOCOL_HEADER]: AIDENT_UPDATE_PROTOCOL_VERSION,
6648
+ ...this.originClientName ? { [AIDENT_LOADOUT_ORIGIN_CLIENT_HEADER]: this.originClientName } : {},
6606
6649
  ...extraHeaders
6607
6650
  };
6608
6651
  if (body !== undefined)
@@ -7058,16 +7101,17 @@ async function genReconcileFavoriteSkills(resolved, result, dependencies) {
7058
7101
  // src/authenticatedClient.ts
7059
7102
  async function getAuthenticatedClient(packages, options = {}) {
7060
7103
  const activePackages = packages ?? await resolveDefaultPackages();
7061
- const [skillInventory, favoriteSkillsStateToken] = await Promise.all([
7104
+ const [skillInventory, favoriteSkillsStateToken, originClientName] = await Promise.all([
7062
7105
  getLoadoutSkillInventory(),
7063
- getInstalledLoadoutFavoriteSkillsStateToken().catch(() => null)
7106
+ getInstalledLoadoutFavoriteSkillsStateToken().catch(() => null),
7107
+ resolveOriginClientName()
7064
7108
  ]);
7065
7109
  const installedSkillVersion = findInstalledLoadoutSkillVersionFromInventory(skillInventory);
7066
7110
  const envToken = process.env.AIDENT_TOKEN;
7067
7111
  const configuredBaseUrl = options.baseUrl ?? process.env.AIDENT_BASE_URL?.trim();
7068
7112
  if (envToken) {
7069
7113
  const baseUrl2 = configuredBaseUrl || (await readCredentials())?.base_url || await resolveDefaultBaseUrl();
7070
- return new CliClient({ base_url: normalizeBaseUrl(baseUrl2), client_id: "", access_token: envToken }, "env", activePackages, installedSkillVersion, skillInventory, favoriteSkillsStateToken);
7114
+ return new CliClient({ base_url: normalizeBaseUrl(baseUrl2), client_id: "", access_token: envToken }, "env", activePackages, installedSkillVersion, skillInventory, favoriteSkillsStateToken, originClientName);
7071
7115
  }
7072
7116
  let credentials = await readCredentials();
7073
7117
  if (!credentials)
@@ -7090,7 +7134,7 @@ async function getAuthenticatedClient(packages, options = {}) {
7090
7134
  credentials = refreshed;
7091
7135
  }
7092
7136
  }
7093
- return new CliClient(credentials, "stored", activePackages, installedSkillVersion, skillInventory, favoriteSkillsStateToken);
7137
+ return new CliClient(credentials, "stored", activePackages, installedSkillVersion, skillInventory, favoriteSkillsStateToken, originClientName);
7094
7138
  }
7095
7139
 
7096
7140
  // src/dshSchema.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aident-ai/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2-rc.ci.32837080953.1",
4
4
  "description": "Aident CLI — umbrella access to Loadout integrations, Playbook automation, Intern tools, and the Aident platform.",
5
5
  "homepage": "https://aident.ai",
6
6
  "repository": {
@@ -37,27 +37,17 @@
37
37
  "patch": "./cordis.patch.yml"
38
38
  }
39
39
  },
40
- "scripts": {
41
- "build": "bun run scripts/build.ts",
42
- "dev": "AIDENT_CLI_VERSION=$npm_package_version bun run src/cli.ts",
43
- "test": "bun test --timeout=30000 src/__tests__",
44
- "test:e2e": "bun test integration",
45
- "typecheck": "tsc --noEmit",
46
- "format": "pnpm exec prettier . --write",
47
- "lint": "pnpm exec eslint ./src ./integration --cache --cache-location ../../.eslintcache",
48
- "prepublishOnly": "pnpm run build"
49
- },
50
40
  "imports": {
51
41
  "~cli/*": "./src/*",
52
42
  "~e2e/*": "./integration/*",
53
43
  "~shared/*": "../web/shared/*"
54
44
  },
55
45
  "devDependencies": {
56
- "@aident/eslint-config": "workspace:*",
57
- "@aident/prettier-config": "workspace:*",
58
- "@aident/typescript-config": "workspace:*",
59
46
  "@types/node": "^22.0.0",
60
- "typescript": "^5.3.3"
47
+ "typescript": "^5.3.3",
48
+ "@aident/eslint-config": "1.0.0",
49
+ "@aident/typescript-config": "0.0.0",
50
+ "@aident/prettier-config": "1.0.0"
61
51
  },
62
52
  "publishConfig": {
63
53
  "access": "public"
@@ -74,5 +64,15 @@
74
64
  "mcp",
75
65
  "dsh",
76
66
  "deepseek-harness"
77
- ]
78
- }
67
+ ],
68
+ "gitHead": "7e52f1de14f9eb62e37d7cde891bffabef8a55d0",
69
+ "scripts": {
70
+ "build": "bun run scripts/build.ts",
71
+ "dev": "AIDENT_CLI_VERSION=$npm_package_version bun run src/cli.ts",
72
+ "test": "bun test --timeout=30000 src/__tests__",
73
+ "test:e2e": "bun test integration",
74
+ "typecheck": "tsc --noEmit",
75
+ "format": "pnpm exec prettier . --write",
76
+ "lint": "pnpm exec eslint ./src ./integration --cache --cache-location ../../.eslintcache"
77
+ }
78
+ }