@chosengeneration/light-code 0.130.1 → 0.131.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
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/cli.cjs
3
- size: 49531140 bytes
4
- sha256: d42d5bec972e54b34622c0e53e51c7e3c7eb72dde03d6664090c193b8339860c
3
+ size: 49559035 bytes
4
+ sha256: 9bbdf6820071134e35ebfa72f8766af3d046c2bfa3cac8375e4c6755bd9284ac
package/dist/server.cjs CHANGED
@@ -24126,7 +24126,7 @@ var require_cross_spawn = __commonJS({
24126
24126
  var cp = require("child_process");
24127
24127
  var parse3 = require_parse2();
24128
24128
  var enoent = require_enoent();
24129
- function spawn13(command, args, options) {
24129
+ function spawn14(command, args, options) {
24130
24130
  const parsed = parse3(command, args, options);
24131
24131
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
24132
24132
  enoent.hookChildProcess(spawned, parsed);
@@ -24138,8 +24138,8 @@ var require_cross_spawn = __commonJS({
24138
24138
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
24139
24139
  return result;
24140
24140
  }
24141
- module2.exports = spawn13;
24142
- module2.exports.spawn = spawn13;
24141
+ module2.exports = spawn14;
24142
+ module2.exports.spawn = spawn14;
24143
24143
  module2.exports.sync = spawnSync;
24144
24144
  module2.exports._parse = parse3;
24145
24145
  module2.exports._enoent = enoent;
@@ -59090,9 +59090,9 @@ async function detectBareInterpreter(configuredPath) {
59090
59090
  return void 0;
59091
59091
  }
59092
59092
  async function pythonVersion(program) {
59093
- const { spawn: spawn13 } = await import("node:child_process");
59093
+ const { spawn: spawn14 } = await import("node:child_process");
59094
59094
  return new Promise((resolve) => {
59095
- const child = spawn13(program, ["-c", 'import sys; print("%d.%d.%d" % sys.version_info[:3])'], {
59095
+ const child = spawn14(program, ["-c", 'import sys; print("%d.%d.%d" % sys.version_info[:3])'], {
59096
59096
  shell: false,
59097
59097
  env: minimalPythonEnv()
59098
59098
  });
@@ -62789,7 +62789,7 @@ function gatewayFromSettings(input, stored) {
62789
62789
 
62790
62790
  // ../../packages/core/dist/host/bridge.js
62791
62791
  var import_node_fs9 = require("node:fs");
62792
- var import_node_child_process14 = require("node:child_process");
62792
+ var import_node_child_process15 = require("node:child_process");
62793
62793
  var import_promises25 = __toESM(require("node:fs/promises"), 1);
62794
62794
 
62795
62795
  // ../../packages/core/dist/jupyter/spec.js
@@ -75221,7 +75221,7 @@ function count2(events) {
75221
75221
  }
75222
75222
  function computeDashboard(input) {
75223
75223
  const { from, to, scope, me } = input;
75224
- const profileOf = (user) => input.profiles?.[shardSegment(user)];
75224
+ const profileOf = (user) => input.profiles?.[shardSegment(user)] ?? input.profiles?.[shardSegment(user).toLowerCase()];
75225
75225
  const who = (user) => {
75226
75226
  const profile = profileOf(user);
75227
75227
  return {
@@ -75334,7 +75334,7 @@ function computeDashboard(input) {
75334
75334
  const contributor = (author) => {
75335
75335
  let entry = contributorMap.get(author);
75336
75336
  if (entry === void 0) {
75337
- entry = { skills: /* @__PURE__ */ new Set(), tools: /* @__PURE__ */ new Set(), uses: 0, reached: /* @__PURE__ */ new Set() };
75337
+ entry = { skills: /* @__PURE__ */ new Set(), tools: /* @__PURE__ */ new Set(), uses: 0, reached: /* @__PURE__ */ new Set(), added: 0, updated: 0 };
75338
75338
  contributorMap.set(author, entry);
75339
75339
  }
75340
75340
  return entry;
@@ -75346,6 +75346,13 @@ function computeDashboard(input) {
75346
75346
  (item.kind === "skill" ? entry.skills : entry.tools).add(item.name);
75347
75347
  if (item.updated !== void 0 && (entry.lastUpdated === void 0 || item.updated > entry.lastUpdated))
75348
75348
  entry.lastUpdated = item.updated;
75349
+ const when3 = item.updated !== void 0 ? Date.parse(item.updated) : NaN;
75350
+ if (Number.isFinite(when3) && when3 >= from && when3 <= to) {
75351
+ if (item.version === void 0 || item.version <= 1)
75352
+ entry.added++;
75353
+ else
75354
+ entry.updated++;
75355
+ }
75349
75356
  }
75350
75357
  const allInRange = input.events.filter((event) => event.t >= from && event.t <= to);
75351
75358
  for (const event of allInRange) {
@@ -75373,6 +75380,9 @@ function computeDashboard(input) {
75373
75380
  tools: entry.tools.size,
75374
75381
  uses: entry.uses,
75375
75382
  reached: entry.reached.size,
75383
+ impact: entry.uses * entry.reached.size,
75384
+ added: entry.added,
75385
+ updated: entry.updated,
75376
75386
  ...entry.lastUpdated !== void 0 ? { lastUpdated: entry.lastUpdated } : {}
75377
75387
  })).sort((a, b) => b.skills + b.tools - (a.skills + a.tools) || b.uses - a.uses);
75378
75388
  const mine = contributorMap.get(me);
@@ -75716,13 +75726,20 @@ function userInfoToolCandidates(names, configured) {
75716
75726
  }
75717
75727
  return names.filter((name) => name !== RECORD_USER_PROFILE && USER_INFO_NAME.test(name)).slice(0, 3);
75718
75728
  }
75719
- function userProfileGuidance(user, candidates) {
75729
+ function userInfoSkillCandidates(skills) {
75730
+ return skills.filter((skill) => USER_INFO_NAME.test(skill.name.replace(/-/g, "_"))).slice(0, 2);
75731
+ }
75732
+ function userProfileGuidance(user, tools, skills = []) {
75733
+ const ways = [
75734
+ ...tools.map((name) => `call \`${name}\``),
75735
+ ...skills.map((skill) => `read the skill "${skill.name}" (${skill.filePath}) and follow it with your own tools`)
75736
+ ];
75720
75737
  return [
75721
75738
  "## Usage dashboard: the user's details",
75722
- `Usage statistics for the team dashboard are filed under the login "${user}", which colleagues cannot read as a person.`,
75723
- `Once in this conversation, before other work, call ${candidates.map((name) => `\`${name}\``).join(" or ")} to look up the current user ("${user}"),`,
75724
- `then call \`${RECORD_USER_PROFILE}\` with the name, email, team, department, title and location it returned and \`source\` set to the tool's name.`,
75725
- "Pass only what the tool returned - never guess a field. If the tool needs input you do not have, or fails, skip this and carry on; do not ask the user about it."
75739
+ `Usage statistics for the team dashboard are filed under the login "${user}", which colleagues cannot read as a person, and the company directory did not say who that is.`,
75740
+ `Once in this conversation, before other work: ${ways.join(", or ")} to look up the current user ("${user}"),`,
75741
+ `then call \`${RECORD_USER_PROFILE}\` with the name, email, team, department, title and location found and \`source\` set to the tool or skill used.`,
75742
+ "Pass only what was found - never guess a field. If it needs input you do not have, or fails, skip this and carry on; do not ask the user about it."
75726
75743
  ].join("\n");
75727
75744
  }
75728
75745
  function createRecordUserProfileTool(options) {
@@ -75754,6 +75771,149 @@ ${describe5(profile)}` };
75754
75771
  };
75755
75772
  }
75756
75773
 
75774
+ // ../../packages/core/dist/usage/directory.js
75775
+ var import_node_child_process14 = require("node:child_process");
75776
+ var ATTRIBUTE_MAP = [
75777
+ ["displayName", "displayName"],
75778
+ ["mail", "email"],
75779
+ ["department", "department"],
75780
+ ["title", "title"],
75781
+ ["physicalDeliveryOfficeName", "location"],
75782
+ ["company", "company"],
75783
+ ["sAMAccountName", "account"]
75784
+ ];
75785
+ function accountPart(name) {
75786
+ return name.split("\\").pop() ?? name;
75787
+ }
75788
+ function entryMatches(entry, name) {
75789
+ const wanted = name.toLowerCase();
75790
+ const account = accountPart(name).toLowerCase();
75791
+ const field2 = (key2) => entry[key2]?.toLowerCase();
75792
+ const upn = field2("userPrincipalName");
75793
+ return field2("sAMAccountName") === account || upn === wanted || upn !== void 0 && upn.split("@")[0] === account || field2("mail") === wanted || field2("displayName") === wanted;
75794
+ }
75795
+ function personFromEntry(entry) {
75796
+ const person = {};
75797
+ for (const [from, to] of ATTRIBUTE_MAP) {
75798
+ const value = entry[from]?.trim();
75799
+ if (value !== void 0 && value.length > 0)
75800
+ person[to] = value.slice(0, 200);
75801
+ }
75802
+ return person;
75803
+ }
75804
+ function profileFromPerson(person) {
75805
+ return {
75806
+ ...person.displayName !== void 0 ? { displayName: person.displayName } : {},
75807
+ ...person.email !== void 0 ? { email: person.email } : {},
75808
+ ...person.department !== void 0 ? { department: person.department, team: person.department } : {},
75809
+ ...person.title !== void 0 ? { title: person.title } : {},
75810
+ ...person.location !== void 0 ? { location: person.location } : {},
75811
+ source: "company directory"
75812
+ };
75813
+ }
75814
+ var DIRECTORY_SCRIPT = String.raw`
75815
+ $ErrorActionPreference = 'Stop'
75816
+ $names = @(([Console]::In.ReadToEnd() | ConvertFrom-Json).names)
75817
+ function Esc([string]$s) { return $s.Replace('\', '\5c').Replace('*', '\2a').Replace('(', '\28').Replace(')', '\29').Replace([string][char]0, '\00') }
75818
+ $attrs = @('sAMAccountName', 'userPrincipalName', 'mail', 'displayName', 'department', 'title', 'physicalDeliveryOfficeName', 'company')
75819
+ try {
75820
+ $entries = New-Object System.Collections.ArrayList
75821
+ for ($i = 0; $i -lt $names.Count; $i += 20) {
75822
+ $last = [Math]::Min($i + 19, $names.Count - 1)
75823
+ $clauses = ''
75824
+ foreach ($n in $names[$i..$last]) {
75825
+ $account = Esc (($n -split '\\')[-1])
75826
+ $whole = Esc $n
75827
+ $clauses += "(sAMAccountName=$account)(userPrincipalName=$whole)(mail=$whole)(displayName=$whole)"
75828
+ }
75829
+ $searcher = New-Object System.DirectoryServices.DirectorySearcher
75830
+ $searcher.Filter = "(&(objectCategory=person)(objectClass=user)(|$clauses))"
75831
+ $searcher.SizeLimit = 200
75832
+ $searcher.ClientTimeout = [TimeSpan]::FromSeconds(15)
75833
+ $searcher.ReferralChasing = [System.DirectoryServices.ReferralChasingOption]::None
75834
+ foreach ($a in $attrs) { [void]$searcher.PropertiesToLoad.Add($a) }
75835
+ foreach ($r in $searcher.FindAll()) {
75836
+ $e = @{}
75837
+ foreach ($a in $attrs) {
75838
+ $v = $r.Properties[$a]
75839
+ if ($v -ne $null -and $v.Count -gt 0) { $e[$a] = [string]$v[0] }
75840
+ }
75841
+ [void]$entries.Add($e)
75842
+ }
75843
+ }
75844
+ $out = @{ ok = $true; available = $true; entries = @($entries) }
75845
+ } catch {
75846
+ $out = @{ ok = $true; available = $false; reason = $_.Exception.Message.Trim() }
75847
+ }
75848
+ 'LCJSON:' + ($out | ConvertTo-Json -Depth 5 -Compress)
75849
+ `;
75850
+ var runWindowsPowerShell = (script, stdin) => new Promise((resolve, reject2) => {
75851
+ const encoded = Buffer.from(script, "utf16le").toString("base64");
75852
+ const child = (0, import_node_child_process14.spawn)("powershell.exe", ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-EncodedCommand", encoded], { windowsHide: true });
75853
+ let out = "";
75854
+ let err = "";
75855
+ const timer = setTimeout(() => {
75856
+ child.kill();
75857
+ reject2(new Error("The directory lookup took longer than a minute."));
75858
+ }, 6e4);
75859
+ child.stdout.setEncoding("utf8").on("data", (chunk) => out += chunk);
75860
+ child.stderr.setEncoding("utf8").on("data", (chunk) => err += chunk);
75861
+ child.on("error", (error51) => {
75862
+ clearTimeout(timer);
75863
+ reject2(error51);
75864
+ });
75865
+ child.on("close", () => {
75866
+ clearTimeout(timer);
75867
+ resolve(out.length > 0 ? out : err);
75868
+ });
75869
+ child.stdin.end(stdin);
75870
+ });
75871
+ function fromEntries(names, entries) {
75872
+ const people = {};
75873
+ const notFound = [];
75874
+ for (const name of names) {
75875
+ const entry = entries.find((candidate) => entryMatches(candidate, name));
75876
+ if (entry === void 0)
75877
+ notFound.push(name);
75878
+ else
75879
+ people[name] = personFromEntry(entry);
75880
+ }
75881
+ return { people, notFound };
75882
+ }
75883
+ async function lookupDirectory(names, options = {}) {
75884
+ const wanted = [...new Set(names.map((name) => name.trim()).filter((name) => name.length > 0 && name.length <= 200))].slice(0, 500);
75885
+ if ((options.platform ?? process.platform) !== "win32")
75886
+ return { available: false, reason: "The company directory is read through Windows; this is not Windows.", via: "none" };
75887
+ if (wanted.length === 0)
75888
+ return { available: true, people: {}, notFound: [], via: options.helper !== void 0 ? "rust" : "powershell" };
75889
+ if (options.helper !== void 0) {
75890
+ const answer = await options.helper({ op: "directory", names: wanted });
75891
+ if (answer["ok"] === true) {
75892
+ if (answer["available"] !== true)
75893
+ return { available: false, reason: String(answer["reason"] ?? "The directory could not be reached."), via: "rust" };
75894
+ const people = {};
75895
+ for (const [name, value] of Object.entries(answer["people"] ?? {})) {
75896
+ const person = {};
75897
+ for (const [, field2] of ATTRIBUTE_MAP)
75898
+ if (typeof value[field2] === "string")
75899
+ person[field2] = value[field2];
75900
+ people[name] = person;
75901
+ }
75902
+ return { available: true, people, notFound: answer["notFound"] ?? [], via: "rust" };
75903
+ }
75904
+ }
75905
+ const run3 = options.runPowerShell ?? runWindowsPowerShell;
75906
+ const output = await run3(DIRECTORY_SCRIPT, JSON.stringify({ names: wanted }));
75907
+ const line = output.split(/\r?\n/).find((each) => each.startsWith("LCJSON:"));
75908
+ if (line === void 0)
75909
+ return { available: false, reason: `The directory lookup gave no answer${output.trim().length > 0 ? `: ${output.trim().slice(0, 200)}` : "."}`, via: "powershell" };
75910
+ const parsed = JSON.parse(line.slice("LCJSON:".length));
75911
+ if (parsed.available !== true)
75912
+ return { available: false, reason: parsed.reason ?? "The directory could not be reached.", via: "powershell" };
75913
+ const entries = Array.isArray(parsed.entries) ? parsed.entries : parsed.entries !== void 0 ? [parsed.entries] : [];
75914
+ return { available: true, ...fromEntries(wanted, entries), via: "powershell" };
75915
+ }
75916
+
75757
75917
  // ../../packages/core/dist/host/bridge.js
75758
75918
  function hostLabel(url2) {
75759
75919
  try {
@@ -75999,6 +76159,7 @@ ${preview.text}` } : {}
75999
76159
  let cachedUsageChoice;
76000
76160
  let usageKicked = false;
76001
76161
  let cachedProfileFresh;
76162
+ let directoryChecked = false;
76002
76163
  let lastToolNames;
76003
76164
  let cachedSearchScope = "project";
76004
76165
  let mirroredToolsDirs = [];
@@ -78042,10 +78203,12 @@ ${preview.text}` } : {}
78042
78203
  parts.push(hubGuidance(hub));
78043
78204
  if (services.fastFs !== void 0)
78044
78205
  parts.push(fastFsGuidance(fastFsOps));
78045
- if (schedule === void 0 && usageCollecting() && cachedProfileFresh === false) {
78206
+ if (schedule === void 0 && usageCollecting() && cachedProfileFresh === false && directoryChecked) {
78046
78207
  const candidates = userInfoCandidates(config2);
78047
- if (candidates.length > 0)
78048
- parts.push(userProfileGuidance(cachedAttribution.author ?? "unknown", candidates));
78208
+ const skillCandidates = candidates.length > 0 ? [] : userInfoSkillCandidates(skills);
78209
+ if (candidates.length > 0 || skillCandidates.length > 0) {
78210
+ parts.push(userProfileGuidance(cachedAttribution.author ?? "unknown", candidates, skillCandidates));
78211
+ }
78049
78212
  }
78050
78213
  if (schedule === void 0 && dispatcherEnabled(config2.retrieval) && search !== void 0 && embedder !== void 0 && docsIndex !== void 0) {
78051
78214
  const everything = currentToolRegistry(void 0, void 0, void 0, void 0, true);
@@ -78736,7 +78899,7 @@ ${direction}` : attachMentions(text, mentions);
78736
78899
  if (typeof fromHub === "string")
78737
78900
  throw new Error(fromHub);
78738
78901
  const git = (args) => new Promise((resolve) => {
78739
- const child = (0, import_node_child_process14.spawn)("git", ["--no-optional-locks", "-C", root, ...args], {
78902
+ const child = (0, import_node_child_process15.spawn)("git", ["--no-optional-locks", "-C", root, ...args], {
78740
78903
  env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
78741
78904
  windowsHide: true
78742
78905
  });
@@ -80846,7 +81009,7 @@ ${redact(shown2, cachedSecretValues)}` }
80846
81009
  return withoutRipgrep();
80847
81010
  try {
80848
81011
  const listed = await new Promise((resolve, reject2) => {
80849
- const child = (0, import_node_child_process14.spawn)(ripgrepPath, ["--files", "--hidden", "--glob", "!.git"], {
81012
+ const child = (0, import_node_child_process15.spawn)(ripgrepPath, ["--files", "--hidden", "--glob", "!.git"], {
80850
81013
  cwd: workspaceRoot
80851
81014
  });
80852
81015
  let out = "";
@@ -81338,7 +81501,7 @@ ${redact(shown2, cachedSecretValues)}` }
81338
81501
  if (relative.startsWith("..") || import_node_path46.default.isAbsolute(relative))
81339
81502
  return found2;
81340
81503
  const output = await new Promise((resolve) => {
81341
- const child = (0, import_node_child_process14.spawn)("git", ["-c", "core.quotePath=false", "log", "--diff-filter=A", "--relative", "--format=@@%an", "--name-only", "--", relative.length > 0 ? relative : "."], {
81504
+ const child = (0, import_node_child_process15.spawn)("git", ["-c", "core.quotePath=false", "log", "--diff-filter=A", "--relative", "--format=@@%an", "--name-only", "--", relative.length > 0 ? relative : "."], {
81342
81505
  cwd: root,
81343
81506
  windowsHide: true
81344
81507
  });
@@ -81962,6 +82125,7 @@ ${redact(shown2, cachedSecretValues)}` }
81962
82125
  await backfillUsageOnce().catch((error51) => logger.warn(`usage: could not import past conversations: ${String(error51)}`));
81963
82126
  await pushUsage({ log: usageLog, store: resolved.store, target: resolved.target, instance: usageInstance });
81964
82127
  usageLastProblem = void 0;
82128
+ void enrichFromDirectory(namesToEnrich(await usageLog.all()));
81965
82129
  await usageLog.prune(14);
81966
82130
  } catch (error51) {
81967
82131
  usageLastProblem = `Could not write to ${resolved.store.label}: ${error51 instanceof Error ? error51.message : String(error51)}`;
@@ -82036,6 +82200,7 @@ ${redact(shown2, cachedSecretValues)}` }
82036
82200
  ...skill.author !== void 0 ? { author: skill.author } : {},
82037
82201
  ...skill.project !== void 0 ? { project: skill.project } : {},
82038
82202
  ...skill.updated !== void 0 ? { updated: skill.updated } : {},
82203
+ ...skill.version !== void 0 ? { version: skill.version } : {},
82039
82204
  deletable: skill.sourceDir !== void 0 && samePath(skill.sourceDir, skillsDir),
82040
82205
  location: where(skill.sourceDir, skillsDir),
82041
82206
  ...hash2 !== void 0 ? { contentHash: hash2 } : {}
@@ -82071,6 +82236,7 @@ ${redact(shown2, cachedSecretValues)}` }
82071
82236
  ...tool.author !== void 0 ? { author: tool.author } : {},
82072
82237
  ...tool.project !== void 0 ? { project: tool.project } : {},
82073
82238
  ...tool.updated !== void 0 ? { updated: tool.updated } : {},
82239
+ ...tool.version !== void 0 ? { version: tool.version } : {},
82074
82240
  deletable: samePath(tool.sourceDir, status2.toolsDir),
82075
82241
  location: where(tool.sourceDir, status2.toolsDir),
82076
82242
  ...hash2 !== void 0 ? { contentHash: hash2 } : {}
@@ -82092,6 +82258,90 @@ ${redact(shown2, cachedSecretValues)}` }
82092
82258
  }
82093
82259
  return items;
82094
82260
  }
82261
+ const usageDirectoryFile = import_node_path46.default.join(storageDir, "usage-directory.json");
82262
+ let directoryRunning;
82263
+ async function readDirectoryCache() {
82264
+ try {
82265
+ const saved = JSON.parse(await import_promises25.default.readFile(usageDirectoryFile, "utf8"));
82266
+ return { ...saved, people: saved.people ?? {} };
82267
+ } catch {
82268
+ return { people: {} };
82269
+ }
82270
+ }
82271
+ function directoryHelper() {
82272
+ const exe = services.fastFs;
82273
+ if (exe === void 0 || fastFsOps !== void 0 && !fastFsOps.has("directory"))
82274
+ return void 0;
82275
+ return (request) => runFastFs(exe, request);
82276
+ }
82277
+ async function enrichFromDirectory(names) {
82278
+ if (directoryRunning !== void 0)
82279
+ return directoryRunning;
82280
+ directoryRunning = (async () => {
82281
+ const now = Date.now();
82282
+ const DAY2 = 864e5;
82283
+ const me = cachedAttribution.author ?? "unknown";
82284
+ const cache = await readDirectoryCache();
82285
+ if (process.platform !== "win32" || cache.unavailable !== void 0 && now - cache.unavailable.at < DAY2) {
82286
+ directoryChecked = true;
82287
+ return;
82288
+ }
82289
+ const wanted = [...new Set([me, ...names].map((name) => name.trim()).filter((name) => name.length > 0 && name !== "unknown" && name !== "_check"))].filter((name) => {
82290
+ const known = cache.people[name.toLowerCase()];
82291
+ return known === void 0 || now - known.at > (known.person !== void 0 ? 30 * DAY2 : 7 * DAY2);
82292
+ }).slice(0, 300);
82293
+ if (wanted.length === 0) {
82294
+ directoryChecked = true;
82295
+ return;
82296
+ }
82297
+ const answer = await lookupDirectory(wanted, { helper: directoryHelper() });
82298
+ if (!answer.available) {
82299
+ cache.unavailable = { at: now, reason: answer.reason, via: answer.via };
82300
+ } else {
82301
+ delete cache.unavailable;
82302
+ cache.via = answer.via;
82303
+ for (const name of wanted) {
82304
+ const person = answer.people[name];
82305
+ cache.people[name.toLowerCase()] = { at: now, ...person !== void 0 ? { person } : {} };
82306
+ }
82307
+ }
82308
+ await import_promises25.default.writeFile(usageDirectoryFile, JSON.stringify(cache), "utf8");
82309
+ directoryChecked = true;
82310
+ const mine = answer.available ? answer.people[me] : void 0;
82311
+ if (mine !== void 0) {
82312
+ await saveUsageProfile({ ...profileFromPerson(mine), updated: (/* @__PURE__ */ new Date()).toISOString() }).catch((error51) => logger.warn(`usage: could not record this user's directory entry: ${String(error51)}`));
82313
+ }
82314
+ logger.info(`usage: company directory ${answer.available ? `answered for ${String(Object.keys(answer.people).length)} of ${String(wanted.length)} names` : `unavailable: ${answer.reason}`} (${answer.via})`);
82315
+ })().catch((error51) => {
82316
+ directoryChecked = true;
82317
+ logger.warn(`usage: directory lookup failed: ${String(error51)}`);
82318
+ }).finally(() => {
82319
+ directoryRunning = void 0;
82320
+ });
82321
+ return directoryRunning;
82322
+ }
82323
+ function directoryProfiles(cache) {
82324
+ const profiles = {};
82325
+ for (const [name, known] of Object.entries(cache.people))
82326
+ if (known.person !== void 0)
82327
+ profiles[shardSegment(name)] = profileFromPerson(known.person);
82328
+ return profiles;
82329
+ }
82330
+ function namesToEnrich(events) {
82331
+ const names = /* @__PURE__ */ new Set();
82332
+ for (const skill of skills)
82333
+ if (skill.author !== void 0)
82334
+ names.add(skill.author);
82335
+ for (const tool of python.status().tools)
82336
+ if (tool.author !== void 0)
82337
+ names.add(tool.author);
82338
+ for (const event of events) {
82339
+ names.add(event.u);
82340
+ if (event.a !== void 0)
82341
+ names.add(event.a);
82342
+ }
82343
+ return [...names];
82344
+ }
82095
82345
  function userInfoCandidates(config2) {
82096
82346
  const names = (lastToolNames ?? []).filter((name) => name !== RECORD_USER_PROFILE);
82097
82347
  return userInfoToolCandidates(names, config2.usage?.userInfoTool);
@@ -82107,6 +82357,15 @@ ${redact(shown2, cachedSecretValues)}` }
82107
82357
  ...choice !== void 0 ? { effective: choice } : {},
82108
82358
  ...config2.usage?.userInfoTool !== void 0 ? { userInfoTool: config2.usage.userInfoTool } : {},
82109
82359
  userInfoCandidates: userInfoCandidates(config2),
82360
+ userInfoSkills: userInfoSkillCandidates(skills).map((skill) => skill.name),
82361
+ directory: await (async () => {
82362
+ const cache = await readDirectoryCache();
82363
+ if (process.platform !== "win32")
82364
+ return { available: false, reason: "Not Windows - the company directory is read through Windows.", people: 0 };
82365
+ if (cache.unavailable !== void 0)
82366
+ return { available: false, reason: cache.unavailable.reason, people: 0, ...cache.via !== void 0 ? { via: cache.via } : {} };
82367
+ return { available: true, people: Object.values(cache.people).filter((known) => known.person !== void 0).length, ...cache.via !== void 0 ? { via: cache.via } : {} };
82368
+ })(),
82110
82369
  ...profile !== void 0 && Object.keys(profile).length > 0 ? { profile } : {},
82111
82370
  ...backfill !== void 0 ? { backfill } : {}
82112
82371
  };
@@ -82158,6 +82417,10 @@ ${redact(shown2, cachedSecretValues)}` }
82158
82417
  const me = cachedAttribution.author ?? "unknown";
82159
82418
  if (local !== void 0 && profiles[shardSegment(me)] === void 0)
82160
82419
  profiles[shardSegment(me)] = local;
82420
+ await Promise.race([enrichFromDirectory(namesToEnrich(events)), new Promise((resolve) => setTimeout(resolve, 8e3))]);
82421
+ for (const [key2, fromDirectory] of Object.entries(directoryProfiles(await readDirectoryCache()))) {
82422
+ profiles[key2] = { ...profiles[key2], ...fromDirectory };
82423
+ }
82161
82424
  const dashboard = computeDashboard({
82162
82425
  events,
82163
82426
  inventory: await usageInventory(),
@@ -85050,7 +85313,7 @@ function searchPath(command, env2) {
85050
85313
  }
85051
85314
 
85052
85315
  // ../../packages/core/dist/lsp/client.js
85053
- var import_node_child_process15 = require("node:child_process");
85316
+ var import_node_child_process16 = require("node:child_process");
85054
85317
  var import_node_url = require("node:url");
85055
85318
  function keyFor(uri) {
85056
85319
  try {
@@ -85080,7 +85343,7 @@ var LspClient = class {
85080
85343
  this.root = root;
85081
85344
  this.log = log;
85082
85345
  const shim = /\.(cmd|bat)$/i.test(executable);
85083
- this.child = shim ? (0, import_node_child_process15.spawn)(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", `"${executable}"`, ...args], { cwd: root, windowsHide: true, windowsVerbatimArguments: true }) : (0, import_node_child_process15.spawn)(executable, args, { cwd: root, windowsHide: true });
85346
+ this.child = shim ? (0, import_node_child_process16.spawn)(process.env.ComSpec ?? "cmd.exe", ["/d", "/s", "/c", `"${executable}"`, ...args], { cwd: root, windowsHide: true, windowsVerbatimArguments: true }) : (0, import_node_child_process16.spawn)(executable, args, { cwd: root, windowsHide: true });
85084
85347
  this.child.stdout?.on("data", (chunk) => this.onData(chunk));
85085
85348
  this.child.stderr?.on("data", (chunk) => {
85086
85349
  const text = chunk.toString("utf8").trim();
@@ -86919,7 +87182,12 @@ data is empty, not 0. Needs Fire Code's helper (Fire Code, or VS Code with Fire
86919
87182
  "user info tool",
86920
87183
  "get_user_info",
86921
87184
  "employee lookup",
86922
- "create whoami"
87185
+ "create whoami",
87186
+ "leaderboard",
87187
+ "company directory",
87188
+ "active directory",
87189
+ "who wrote the most skills",
87190
+ "most contributions"
86923
87191
  ],
86924
87192
  body: `
86925
87193
  **Settings \u2192 Usage** shows which skills and tools are used, by whom, who writes them, and what needs
@@ -86942,11 +87210,23 @@ tools they called and the skills they read, so the dashboard has history from da
86942
87210
  installed its Rust helper does this (and reads a shared folder) in parallel; otherwise it is done in
86943
87211
  Node. It runs once per install.
86944
87212
 
86945
- **People instead of login names.** If a tool that looks users up is available - an MCP or Python tool
86946
- named like \`whoami\`, \`user_info\` or \`employee_lookup\`, or the one named in the panel - the
86947
- assistant calls it once (approved as usual) and records your name, email, team, department, title and
86948
- location with \`record_user_profile\`. The dashboard then shows names and a **By team** table. It asks
86949
- again after 30 days.
87213
+ **People instead of login names.** On a Windows machine on a company domain, names come from the
87214
+ **company directory** first - display name, email, department (shown as the team), title and office -
87215
+ read in the background as you (Windows' own sign-in, nothing to configure), for you, every author named
87216
+ on a skill or tool, and every colleague in the numbers. With Fire Code installed its Rust helper reads the
87217
+ directory; otherwise a fixed PowerShell script does. Only searches, only those fields, only while usage is
87218
+ collected; answers are kept for 30 days. Off a domain, or for someone the directory does not list, the
87219
+ **second way** is used: if a tool that looks users up is available - an MCP or Python tool named like
87220
+ \`whoami\`, \`user_info\` or \`employee_lookup\`, the one named in the panel, or failing those a
87221
+ **skill** named like \`who-am-i\` or \`user-info\` that describes how - the assistant does it once
87222
+ (approved as usual) and records the result with \`record_user_profile\`. The dashboard then shows names and
87223
+ a **By team** table. It asks again after 30 days. Settings \u2192 Usage says whether the directory is reachable.
87224
+
87225
+ **The leaderboard** ranks authors three ways: **Most written** (skills and tools they wrote), **Most
87226
+ impact** (uses of their work \xD7 people it reached, in the range) and **Most active this period** (skills
87227
+ and tools they added or updated in the range - a label at version 1 is new, a later one an update).
87228
+ Authorship comes from the \`author\` label on a skill or the \`__author__\` line in a tool; unlabelled
87229
+ ones count for nobody and are listed under Needs attention.
86950
87230
 
86951
87231
  **Which tools count as a user-info tool.** The name is matched by its words between underscores, so the
86952
87232
  \`py__\` (Python) or \`<server>__\` (MCP) prefix does not matter: \`py__whoami\`, \`py__get_user_info\`,
@@ -88254,7 +88534,7 @@ function createLightCodeHelpTool() {
88254
88534
  }
88255
88535
 
88256
88536
  // ../../packages/core/dist/tools/listFiles.js
88257
- var import_node_child_process16 = require("node:child_process");
88537
+ var import_node_child_process17 = require("node:child_process");
88258
88538
  var import_node_path49 = __toESM(require("node:path"), 1);
88259
88539
 
88260
88540
  // ../../packages/core/dist/tools/ripgrepError.js
@@ -88288,7 +88568,7 @@ function isRipgrepNoMatchError(error51) {
88288
88568
  }
88289
88569
  function runRipgrepFiles(rgPath, dir, signal, includeIgnored) {
88290
88570
  return new Promise((resolve, reject2) => {
88291
- (0, import_node_child_process16.execFile)(rgPath, [
88571
+ (0, import_node_child_process17.execFile)(rgPath, [
88292
88572
  "--files",
88293
88573
  "--hidden",
88294
88574
  ...includeIgnored ? ["--no-ignore-vcs"] : [],
@@ -88497,7 +88777,7 @@ var readDocumentTool = {
88497
88777
  };
88498
88778
 
88499
88779
  // ../../packages/core/dist/tools/searchFiles.js
88500
- var import_node_child_process17 = require("node:child_process");
88780
+ var import_node_child_process18 = require("node:child_process");
88501
88781
  var paramsSchema22 = external_exports.object({
88502
88782
  path: external_exports.string().min(1).default(".").describe("Directory to search, relative to the workspace root."),
88503
88783
  pattern: external_exports.string().min(1).describe("Regular expression to search for."),
@@ -88516,7 +88796,7 @@ function runRipgrepSearch(rgPath, dir, pattern, filePattern, signal, includeIgno
88516
88796
  args.push("-g", filePattern);
88517
88797
  args.push("--regexp", pattern, ".");
88518
88798
  return new Promise((resolve, reject2) => {
88519
- (0, import_node_child_process17.execFile)(rgPath, args, { cwd: dir, signal, maxBuffer: 10 * 1024 * 1024 }, (error51, stdout) => {
88799
+ (0, import_node_child_process18.execFile)(rgPath, args, { cwd: dir, signal, maxBuffer: 10 * 1024 * 1024 }, (error51, stdout) => {
88520
88800
  if (error51 && !isRipgrepNoMatchError2(error51)) {
88521
88801
  reject2(error51);
88522
88802
  return;
@@ -90622,7 +90902,7 @@ var import_promises31 = __toESM(require("node:fs/promises"), 1);
90622
90902
  var import_node_path56 = __toESM(require("node:path"), 1);
90623
90903
 
90624
90904
  // src/credentialTool.ts
90625
- var import_node_child_process18 = require("node:child_process");
90905
+ var import_node_child_process19 = require("node:child_process");
90626
90906
  var import_node_path55 = __toESM(require("node:path"), 1);
90627
90907
  var CREDENTIAL_PREFIX2 = "tool:";
90628
90908
  var WRAPPER = [
@@ -90643,7 +90923,7 @@ async function fetchCredential(options, reference) {
90643
90923
  if (name.length === 0) return { problem: "A credential reference needs a name: tool:<name>." };
90644
90924
  const budget = options.timeoutMs ?? 3e4;
90645
90925
  const run3 = await new Promise((resolve) => {
90646
- const child = (0, import_node_child_process18.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path55.default.resolve(options.file), name], {
90926
+ const child = (0, import_node_child_process19.spawn)(options.interpreter, ["-c", WRAPPER, import_node_path55.default.resolve(options.file), name], {
90647
90927
  windowsHide: true,
90648
90928
  // The environment this was started in, as with the identity function: the libraries that
90649
90929
  // hold credentials are configured through it, and nothing here is model-authored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chosengeneration/light-code",
3
- "version": "0.130.1",
3
+ "version": "0.131.0",
4
4
  "description": "A minimal agentic coding assistant, served to your browser from a local Node server",
5
5
  "license": "MIT",
6
6
  "type": "module",