@chosengeneration/light-code 0.64.1 → 0.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/cli.js +125 -27
  2. package/dist/server.js +107 -23
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -40196,6 +40196,7 @@ function dispatcherEnabled(retrieval) {
40196
40196
  function skillRetrievalEnabled(retrieval) {
40197
40197
  return dispatcherEnabled(retrieval) && retrieval?.skills !== false;
40198
40198
  }
40199
+ var aliasNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,48}$/, "Start with a letter or digit, then lowercase letters, digits, dot, dash or underscore");
40199
40200
  var embedderConfigSchema = external_exports.object({
40200
40201
  profileId: external_exports.string().min(1),
40201
40202
  model: external_exports.string().min(1),
@@ -40247,7 +40248,28 @@ var embedderConfigSchema = external_exports.object({
40247
40248
  * keeping their code indexes to themselves — skills are prose somebody wrote on purpose,
40248
40249
  * source is not.
40249
40250
  */
40250
- skillsAlias: external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,48}$/, "Start with a letter or digit, then lowercase letters, digits, dot, dash or underscore")
40251
+ skillsAlias: external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,48}$/, "Start with a letter or digit, then lowercase letters, digits, dot, dash or underscore"),
40252
+ /**
40253
+ * Further names the codebase index answers to, beyond `indexAlias`.
40254
+ *
40255
+ * An index may carry several, and that is what makes *levels* of sharing possible rather than
40256
+ * a single pool: the same index can be reachable as `my-squad`, as `platform-team` and as
40257
+ * `everyone`, and searching one of those reaches exactly the people who attached it. With one
40258
+ * name there is one circle, and you are either in it or out of it.
40259
+ *
40260
+ * Order is meaningful — the first is the default, and is what `scope: "team"` resolves to.
40261
+ * Read through `rag/aliases.ts` together with the singular key, never directly, so the two
40262
+ * spellings cannot drift.
40263
+ */
40264
+ indexAliases: external_exports.array(aliasNameSchema).max(8).optional(),
40265
+ /**
40266
+ * The same for skills.
40267
+ *
40268
+ * Kept separate from the codebase list rather than derived from it, for the reason
40269
+ * `skillsAlias` already records: pooling your source and pooling what you have *taught* the
40270
+ * assistant are different decisions, and a team routinely wants one without the other.
40271
+ */
40272
+ skillsAliases: external_exports.array(aliasNameSchema).max(8).optional()
40251
40273
  }).partial();
40252
40274
  var globalTlsSchema = tlsSettingsSchema;
40253
40275
  var identityConfigSchema = external_exports.object({
@@ -46961,11 +46983,48 @@ Filters: ${JSON.stringify(params.filters)}` : ""}`
46961
46983
 
46962
46984
  // ../../packages/core/dist/tools/searchCodebase.js
46963
46985
  import path10 from "node:path";
46986
+
46987
+ // ../../packages/core/dist/rag/aliases.js
46988
+ function codebaseAliases(config2) {
46989
+ return merge2(config2?.embedder?.indexAlias, config2?.embedder?.indexAliases);
46990
+ }
46991
+ function skillAliases(config2) {
46992
+ return merge2(config2?.embedder?.skillsAlias, config2?.embedder?.skillsAliases);
46993
+ }
46994
+ function aliasForScope(scope, aliases) {
46995
+ const wanted = scope.trim().toLowerCase();
46996
+ if (wanted.length === 0 || wanted === "mine")
46997
+ return void 0;
46998
+ if (wanted === "team")
46999
+ return aliases[0];
47000
+ return aliases.find((alias) => alias.toLowerCase() === wanted);
47001
+ }
47002
+ function merge2(single, many) {
47003
+ const out = [];
47004
+ for (const value of [single, ...many ?? []]) {
47005
+ const trimmed = value?.trim();
47006
+ if (trimmed === void 0 || trimmed.length === 0)
47007
+ continue;
47008
+ if (!out.some((existing) => existing.toLowerCase() === trimmed.toLowerCase()))
47009
+ out.push(trimmed);
47010
+ }
47011
+ return out;
47012
+ }
47013
+
47014
+ // ../../packages/core/dist/tools/searchCodebase.js
46964
47015
  var paramsSchema6 = external_exports.object({
46965
47016
  query: external_exports.string().min(1).describe('What you are looking for, described in plain words \u2014 e.g. "where the retry backoff is calculated".'),
46966
47017
  size: external_exports.number().int().min(1).max(25).optional().describe("How many results to return. Default 8."),
46967
47018
  pathPrefix: external_exports.string().optional().describe('Restrict to a subtree, e.g. "packages/core/src". Omit to search everything indexed.'),
46968
- scope: external_exports.enum(["mine", "team"]).optional().describe(`Whose code to search. "mine" (default) is this workspace only. "team" also searches colleagues' indexed projects \u2014 use it for "how did anyone solve X", never for questions about the code in front of you. Team results are NOT on this machine and cannot be opened or edited.`)
47019
+ /*
47020
+ * A free string rather than an enum, because the scopes are whatever the user configured.
47021
+ *
47022
+ * An index may carry several aliases — a squad, a department, everyone — and each is a level of
47023
+ * sharing. The *description* names the ones that exist here, which is §12's carve-out: it varies
47024
+ * with a setting rather than with the turn, so the tool block stays byte-stable for a session
47025
+ * exactly as `ask_expert`'s does.
47026
+ */
47027
+ scope: external_exports.string().optional().describe('Whose code to search. "mine" (default) is this workspace only. Anything else names a shared scope \u2014 use it for "how did anyone solve X", never for questions about the code in front of you. Shared results are NOT on this machine and cannot be opened or edited.')
46969
47028
  });
46970
47029
  var DEFAULT_SIZE = 8;
46971
47030
  var REMOTE_GUIDANCE = [
@@ -47009,10 +47068,12 @@ function createSearchCodebaseTool(options) {
47009
47068
  const startedAt = Date.now();
47010
47069
  try {
47011
47070
  const size = params.size ?? DEFAULT_SIZE;
47012
- const wantsTeam = params.scope === "team";
47013
- const teamUnavailable = wantsTeam && options.teamAlias === void 0;
47014
- const searchingTeam = wantsTeam && options.teamAlias !== void 0;
47015
- const collection = searchingTeam ? options.teamAlias : options.index;
47071
+ const requested = params.scope?.trim() ?? "mine";
47072
+ const wantsTeam = requested.length > 0 && requested.toLowerCase() !== "mine";
47073
+ const alias = aliasForScope(requested, options.teamAliases ?? []);
47074
+ const teamUnavailable = wantsTeam && alias === void 0;
47075
+ const searchingTeam = wantsTeam && alias !== void 0;
47076
+ const collection = searchingTeam ? alias : options.index;
47016
47077
  const vector = await options.embedder.embed(params.query);
47017
47078
  const hits = await options.searcher.searchByVector(collection, vector, {
47018
47079
  size,
@@ -47058,7 +47119,12 @@ ${hit.text}`;
47058
47119
  "These are approximate. Read the files before relying on them, and use search_files if you know the exact term.",
47059
47120
  ...teamUnavailable ? [
47060
47121
  "",
47061
- "Team scope was asked for but no shared index is configured, so only this workspace was searched. Do not conclude from this that no colleague has solved it \u2014 their work was not looked at."
47122
+ /*
47123
+ * Which it was matters: nothing configured is a different thing to fix from a
47124
+ * scope that was misspelled, and naming the ones that exist turns a dead end
47125
+ * into a retry the model can get right.
47126
+ */
47127
+ (options.teamAliases ?? []).length === 0 ? "A shared scope was asked for but none is configured, so only this workspace was searched. Do not conclude from this that no colleague has solved it \u2014 their work was not looked at." : `There is no shared scope called "${requested}". The ones configured here are: ${(options.teamAliases ?? []).join(", ")}. Only this workspace was searched, so do not conclude that no colleague has solved it.`
47062
47128
  ] : [],
47063
47129
  ...anyRemote ? ["", ...REMOTE_GUIDANCE] : [],
47064
47130
  "",
@@ -47166,8 +47232,10 @@ ${hit.text}`;
47166
47232
  }
47167
47233
  async function indexTeamSkills(options) {
47168
47234
  await options.writer.ensureCollection(options.collection, options.embedder.dimensions, options.signal);
47169
- if (options.alias !== void 0 && options.writer.ensureAlias !== void 0) {
47170
- await options.writer.ensureAlias(options.collection, options.alias, options.signal);
47235
+ if (options.writer.ensureAlias !== void 0) {
47236
+ for (const alias of options.aliases ?? []) {
47237
+ await options.writer.ensureAlias(options.collection, alias, options.signal);
47238
+ }
47171
47239
  }
47172
47240
  if (options.skills.length === 0)
47173
47241
  return 0;
@@ -50318,7 +50386,8 @@ async function indexWorkspace(options) {
50318
50386
  };
50319
50387
  await writer.ensureCollection(index, embedder.dimensions, signal);
50320
50388
  if (options.alias !== void 0 && writer.ensureAlias !== void 0) {
50321
- await writer.ensureAlias(index, options.alias, signal);
50389
+ for (const alias of options.alias)
50390
+ await writer.ensureAlias(index, alias, signal);
50322
50391
  }
50323
50392
  const signature = chunkSignatureFor(options.chunkOptions);
50324
50393
  const stale = options.manifest.model !== embedder.model || options.manifest.dimensions !== embedder.dimensions || options.manifest.chunkSignature !== signature;
@@ -62704,7 +62773,7 @@ ${preview.text}` } : {}
62704
62773
  ...activePlan !== void 0 && activePlan.trim().length > 0 ? { plan: activePlan } : {},
62705
62774
  // Only when a pool actually exists: telling the model about a tool it has not been given
62706
62775
  // is how it comes to report that it looked somewhere it could not reach.
62707
- teamSkillsAvailable: config2.embedder?.skillsAlias !== void 0,
62776
+ teamSkillsAvailable: skillAliases(config2).length > 0,
62708
62777
  /*
62709
62778
  * Read from config rather than from the registry, because the prompt is built before the
62710
62779
  * registry is. Only the *off* case is claimed: "on but uv is missing" leaves the model
@@ -62841,7 +62910,7 @@ ${direction}` : attachMentions(text, mentions);
62841
62910
  * to look and every hit can say whose it is. Both absent on a solo install,
62842
62911
  * where team scope is simply unavailable and says so.
62843
62912
  */
62844
- ...config2.embedder?.indexAlias !== void 0 ? { teamAlias: config2.embedder.indexAlias } : {},
62913
+ ...codebaseAliases(config2).length > 0 ? { teamAliases: codebaseAliases(config2) } : {},
62845
62914
  ...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
62846
62915
  } : void 0,
62847
62916
  /*
@@ -62857,10 +62926,11 @@ ${direction}` : attachMentions(text, mentions);
62857
62926
  * The team's shared skills. Needs an alias, a connection and an embedder — without
62858
62927
  * all three there is nothing to search, and the tool is simply not offered.
62859
62928
  */
62860
- config2.embedder?.skillsAlias !== void 0 && search !== void 0 && embedder !== void 0 ? {
62929
+ skillAliases(config2).length > 0 && search !== void 0 && embedder !== void 0 ? {
62861
62930
  searcher: search.searcher,
62862
62931
  embedder,
62863
- collection: config2.embedder.skillsAlias,
62932
+ // The first is the default circle, exactly as it is for the codebase index.
62933
+ collection: skillAliases(config2)[0],
62864
62934
  ...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
62865
62935
  } : void 0,
62866
62936
  /*
@@ -63834,8 +63904,8 @@ ${direction}` : attachMentions(text, mentions);
63834
63904
  }
63835
63905
  async function handleAttachTeamAlias() {
63836
63906
  const config2 = await loadSettings();
63837
- const alias = config2.embedder?.indexAlias;
63838
- if (alias === void 0) {
63907
+ const aliases = codebaseAliases(config2);
63908
+ if (aliases.length === 0) {
63839
63909
  post({
63840
63910
  type: "teamAliasAttached",
63841
63911
  error: "Set a team index alias in Settings \u2192 Search first \u2014 there is nothing to attach to."
@@ -63860,7 +63930,8 @@ ${direction}` : attachMentions(text, mentions);
63860
63930
  });
63861
63931
  return;
63862
63932
  }
63863
- await writer.ensureAlias(index, alias);
63933
+ for (const alias of aliases)
63934
+ await writer.ensureAlias(index, alias);
63864
63935
  let attributed = 0;
63865
63936
  const owner = indexOwner(config2);
63866
63937
  if (owner !== void 0 && writer.attributeUnowned !== void 0) {
@@ -63870,7 +63941,7 @@ ${direction}` : attachMentions(text, mentions);
63870
63941
  ...project !== void 0 ? { project } : {}
63871
63942
  });
63872
63943
  }
63873
- post({ type: "teamAliasAttached", alias, index, attributed });
63944
+ post({ type: "teamAliasAttached", alias: aliases.join(", "), index, attributed });
63874
63945
  } catch (error51) {
63875
63946
  post({
63876
63947
  type: "teamAliasAttached",
@@ -64545,7 +64616,7 @@ ${direction}` : attachMentions(text, mentions);
64545
64616
  writer: createVectorIndexWriter(httpClient, search.store, await vectorStoreConnectionFor(search.store, search.id)),
64546
64617
  embedder,
64547
64618
  collection,
64548
- ...config2.embedder?.skillsAlias !== void 0 ? { alias: config2.embedder.skillsAlias } : {},
64619
+ aliases: skillAliases(config2),
64549
64620
  skills: withBodies,
64550
64621
  signal,
64551
64622
  onProgress: (done, total) => reportIndexing("teamSkills", "Embedding and sending", { done, total }),
@@ -65052,7 +65123,7 @@ ${direction}` : attachMentions(text, mentions);
65052
65123
  const manifestFile = manifestPath(index, search.id);
65053
65124
  const owner = indexOwner(config2);
65054
65125
  const project = indexProject();
65055
- const alias = config2.embedder?.indexAlias;
65126
+ const aliases = codebaseAliases(config2);
65056
65127
  try {
65057
65128
  const manifest = await loadIndexManifest(manifestFile, embedder);
65058
65129
  const isIgnored = await ignoredFilesPredicate();
@@ -65079,7 +65150,7 @@ ${direction}` : attachMentions(text, mentions);
65079
65150
  */
65080
65151
  ...owner !== void 0 ? { owner } : {},
65081
65152
  ...project !== void 0 ? { project } : {},
65082
- ...alias !== void 0 ? { alias } : {},
65153
+ alias: aliases,
65083
65154
  onProgress: (progress) => post({ type: "indexProgress", progress }),
65084
65155
  signal: indexingAbort.signal
65085
65156
  });
@@ -69529,7 +69600,11 @@ function reachableHosts(bindAddress, port, extra = []) {
69529
69600
  }
69530
69601
  }
69531
69602
  }
69532
- for (const name of extra) add(name);
69603
+ for (const name of extra) {
69604
+ add(name);
69605
+ const trimmed = name.trim().toLowerCase();
69606
+ if (trimmed.length > 0) names.add(trimmed);
69607
+ }
69533
69608
  return [...names];
69534
69609
  }
69535
69610
  function reachableOrigins(hosts, extra = []) {
@@ -69654,6 +69729,10 @@ function checkRequest(request, policy, options) {
69654
69729
  }
69655
69730
  return void 0;
69656
69731
  }
69732
+ var frameAncestors = [];
69733
+ function setFrameAncestors(origins) {
69734
+ frameAncestors = origins.map((origin) => origin.trim()).filter((origin) => origin.length > 0);
69735
+ }
69657
69736
  function securityHeaders() {
69658
69737
  return {
69659
69738
  "Content-Security-Policy": [
@@ -69665,7 +69744,11 @@ function securityHeaders() {
69665
69744
  "img-src 'self' data:",
69666
69745
  "font-src 'self'",
69667
69746
  "connect-src 'self'",
69668
- "frame-ancestors 'none'",
69747
+ /*
69748
+ * `'none'` unless somebody named an origin. A list here is a deliberate act by an operator
69749
+ * who wants this page inside another — a lab, a dashboard — and it names exactly which.
69750
+ */
69751
+ frameAncestors.length === 0 ? "frame-ancestors 'none'" : `frame-ancestors ${frameAncestors.join(" ")}`,
69669
69752
  "base-uri 'none'",
69670
69753
  "form-action 'none'"
69671
69754
  ].join("; "),
@@ -70592,6 +70675,7 @@ var STREAM_PADDING = `: ${(() => {
70592
70675
  async function startServer(options) {
70593
70676
  const log = options.logSink ?? ((line) => process.stderr.write(`${line}
70594
70677
  `));
70678
+ setFrameAncestors(options.allowFrameAncestors ?? []);
70595
70679
  const identity = options.identity ?? (options.noToken === true ? new OpenIdentity() : new SingleUserIdentity(options.handoffSeconds));
70596
70680
  const roles = options.roles ?? SINGLE_USER_POLICY;
70597
70681
  const sharedStore = options.sharedConfig;
@@ -71096,7 +71180,7 @@ function respondJson(response, status, body) {
71096
71180
  }
71097
71181
 
71098
71182
  // src/cli.ts
71099
- var VERSION = true ? "0.64.1" : "unknown (not a packaged build)";
71183
+ var VERSION = true ? "0.68.0" : "unknown (not a packaged build)";
71100
71184
  var compat = installNodeCompat();
71101
71185
  function lastMeaningfulLine(problem) {
71102
71186
  const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));
@@ -71161,7 +71245,9 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
71161
71245
  const dataDir = valueOf(args, "--data-dir") ?? envPaths("light-code", { suffix: "" }).data;
71162
71246
  const port = Number.parseInt(valueOf(args, "--port") ?? "0", 10);
71163
71247
  const noToken = args.includes("--no-token");
71248
+ const printUrl = args.includes("--print-url");
71164
71249
  const publicUrl = valueOf(args, "--public-url");
71250
+ const allowFrameAncestors = valuesOf(args, "--allow-frame-ancestor");
71165
71251
  const allowHosts = valuesOf(args, "--allow-host");
71166
71252
  const allowOrigins = valuesOf(args, "--allow-origin");
71167
71253
  const handoffSeconds = Math.min(
@@ -71169,7 +71255,7 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
71169
71255
  Math.max(1, Number.parseInt(valueOf(args, "--handoff-seconds") ?? "10", 10) || 10)
71170
71256
  );
71171
71257
  const bindAddress = valueOf(args, "--bind");
71172
- const noOpen = args.includes("--no-open") || serverMode;
71258
+ const noOpen = args.includes("--no-open") || serverMode || printUrl;
71173
71259
  let identity;
71174
71260
  let identityProblem;
71175
71261
  if (identityTool !== void 0) {
@@ -71221,6 +71307,7 @@ Did you mean: --admin-id ${strayAdminValue.join(" --admin-id ")}
71221
71307
  * Somebody who typed the address is telling us it is theirs, which is the same statement
71222
71308
  * `--allow-host` makes and this saves them making it twice.
71223
71309
  */
71310
+ allowFrameAncestors,
71224
71311
  allowHosts: [...allowHosts, ...trustedFromPublicUrl(publicUrl).hosts],
71225
71312
  allowOrigins: [...allowOrigins, ...trustedFromPublicUrl(publicUrl).origins],
71226
71313
  /*
@@ -71264,6 +71351,8 @@ Light Code ${VERSION}
71264
71351
  `
71265
71352
  );
71266
71353
  const reachableUrl = publicAddress === void 0 ? noToken ? server.url : launchUrl : publicLaunchUrl(publicAddress, adminMode, noToken ? "" : server.launchToken ?? "");
71354
+ if (printUrl) process.stdout.write(`light-code-url: ${reachableUrl}
71355
+ `);
71267
71356
  if (publicAddress !== void 0) {
71268
71357
  process.stdout.write(
71269
71358
  ` open ${reachableUrl}
@@ -71346,11 +71435,11 @@ Both go through your proxy. Anyone reaching /admin directly is an administrator.
71346
71435
  * working the public address out: the useful URL scrolled past above it, and the useless
71347
71436
  * one had the last word.
71348
71437
  */
71349
- noToken ? `Opening ${server.url}
71438
+ noToken ? `${noOpen ? "Serving on" : "Opening"} ${server.url}
71350
71439
  (If the browser does not open, open this \u2014 there is no time limit:)
71351
71440
  ${reachableUrl}
71352
71441
 
71353
- ` : `Opening ${server.url}
71442
+ ` : `${noOpen ? "Serving on" : "Opening"} ${server.url}
71354
71443
  (If the browser does not open, paste this within ${String(handoffSeconds)} seconds:)
71355
71444
  ${reachableUrl}
71356
71445
 
@@ -71377,8 +71466,10 @@ var KNOWN_FLAGS = /* @__PURE__ */ new Set([
71377
71466
  "--no-open",
71378
71467
  "--no-token",
71379
71468
  "--public-url",
71469
+ "--print-url",
71380
71470
  "--allow-host",
71381
71471
  "--allow-origin",
71472
+ "--allow-frame-ancestor",
71382
71473
  "--server",
71383
71474
  "--admin",
71384
71475
  "--admin-id",
@@ -71465,12 +71556,19 @@ Usage: light-code [options]
71465
71556
  --bind <address> Interface to listen on (default: 127.0.0.1). Use 0.0.0.0 to
71466
71557
  reach it from another machine; it then answers to this
71467
71558
  machine's own hostname and addresses as well as localhost
71559
+ --print-url Print the launch URL on its own line, prefixed light-code-url:,
71560
+ then serve. For a program starting this and needing to know
71561
+ where it went \u2014 an IDE plugin, a script. Implies --no-open.
71468
71562
  --public-url <u> The address this is reachable at from a browser, when that is not
71469
71563
  the one it binds. Printed as the link to open, and trusted as a
71470
71564
  host and origin.
71471
71565
  Under JupyterHub give only the hub's base URL \u2014 the
71472
71566
  /user/<you>/proxy/<port>/ part is worked out, including the
71473
71567
  port, which you cannot know before it starts.
71568
+ --allow-frame-ancestor <o> An origin allowed to embed this page in a frame, e.g.
71569
+ https://your-jupyterhub to show it inside JupyterLab. Off by
71570
+ default: framing is how clickjacking reaches an approval
71571
+ dialog, so each origin is named rather than guessed.
71474
71572
  --allow-host <h> An extra name to answer to, e.g. a reverse proxy or a
71475
71573
  container alias (repeatable)
71476
71574
  --allow-origin <o> An extra origin allowed to call it, e.g. an app embedding
package/dist/server.js CHANGED
@@ -40047,6 +40047,7 @@ function dispatcherEnabled(retrieval) {
40047
40047
  function skillRetrievalEnabled(retrieval) {
40048
40048
  return dispatcherEnabled(retrieval) && retrieval?.skills !== false;
40049
40049
  }
40050
+ var aliasNameSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,48}$/, "Start with a letter or digit, then lowercase letters, digits, dot, dash or underscore");
40050
40051
  var embedderConfigSchema = external_exports.object({
40051
40052
  profileId: external_exports.string().min(1),
40052
40053
  model: external_exports.string().min(1),
@@ -40098,7 +40099,28 @@ var embedderConfigSchema = external_exports.object({
40098
40099
  * keeping their code indexes to themselves — skills are prose somebody wrote on purpose,
40099
40100
  * source is not.
40100
40101
  */
40101
- skillsAlias: external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,48}$/, "Start with a letter or digit, then lowercase letters, digits, dot, dash or underscore")
40102
+ skillsAlias: external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,48}$/, "Start with a letter or digit, then lowercase letters, digits, dot, dash or underscore"),
40103
+ /**
40104
+ * Further names the codebase index answers to, beyond `indexAlias`.
40105
+ *
40106
+ * An index may carry several, and that is what makes *levels* of sharing possible rather than
40107
+ * a single pool: the same index can be reachable as `my-squad`, as `platform-team` and as
40108
+ * `everyone`, and searching one of those reaches exactly the people who attached it. With one
40109
+ * name there is one circle, and you are either in it or out of it.
40110
+ *
40111
+ * Order is meaningful — the first is the default, and is what `scope: "team"` resolves to.
40112
+ * Read through `rag/aliases.ts` together with the singular key, never directly, so the two
40113
+ * spellings cannot drift.
40114
+ */
40115
+ indexAliases: external_exports.array(aliasNameSchema).max(8).optional(),
40116
+ /**
40117
+ * The same for skills.
40118
+ *
40119
+ * Kept separate from the codebase list rather than derived from it, for the reason
40120
+ * `skillsAlias` already records: pooling your source and pooling what you have *taught* the
40121
+ * assistant are different decisions, and a team routinely wants one without the other.
40122
+ */
40123
+ skillsAliases: external_exports.array(aliasNameSchema).max(8).optional()
40102
40124
  }).partial();
40103
40125
  var globalTlsSchema = tlsSettingsSchema;
40104
40126
  var identityConfigSchema = external_exports.object({
@@ -46819,11 +46841,48 @@ Filters: ${JSON.stringify(params.filters)}` : ""}`
46819
46841
 
46820
46842
  // ../../packages/core/dist/tools/searchCodebase.js
46821
46843
  import path9 from "node:path";
46844
+
46845
+ // ../../packages/core/dist/rag/aliases.js
46846
+ function codebaseAliases(config2) {
46847
+ return merge2(config2?.embedder?.indexAlias, config2?.embedder?.indexAliases);
46848
+ }
46849
+ function skillAliases(config2) {
46850
+ return merge2(config2?.embedder?.skillsAlias, config2?.embedder?.skillsAliases);
46851
+ }
46852
+ function aliasForScope(scope, aliases) {
46853
+ const wanted = scope.trim().toLowerCase();
46854
+ if (wanted.length === 0 || wanted === "mine")
46855
+ return void 0;
46856
+ if (wanted === "team")
46857
+ return aliases[0];
46858
+ return aliases.find((alias) => alias.toLowerCase() === wanted);
46859
+ }
46860
+ function merge2(single, many) {
46861
+ const out = [];
46862
+ for (const value of [single, ...many ?? []]) {
46863
+ const trimmed = value?.trim();
46864
+ if (trimmed === void 0 || trimmed.length === 0)
46865
+ continue;
46866
+ if (!out.some((existing) => existing.toLowerCase() === trimmed.toLowerCase()))
46867
+ out.push(trimmed);
46868
+ }
46869
+ return out;
46870
+ }
46871
+
46872
+ // ../../packages/core/dist/tools/searchCodebase.js
46822
46873
  var paramsSchema6 = external_exports.object({
46823
46874
  query: external_exports.string().min(1).describe('What you are looking for, described in plain words \u2014 e.g. "where the retry backoff is calculated".'),
46824
46875
  size: external_exports.number().int().min(1).max(25).optional().describe("How many results to return. Default 8."),
46825
46876
  pathPrefix: external_exports.string().optional().describe('Restrict to a subtree, e.g. "packages/core/src". Omit to search everything indexed.'),
46826
- scope: external_exports.enum(["mine", "team"]).optional().describe(`Whose code to search. "mine" (default) is this workspace only. "team" also searches colleagues' indexed projects \u2014 use it for "how did anyone solve X", never for questions about the code in front of you. Team results are NOT on this machine and cannot be opened or edited.`)
46877
+ /*
46878
+ * A free string rather than an enum, because the scopes are whatever the user configured.
46879
+ *
46880
+ * An index may carry several aliases — a squad, a department, everyone — and each is a level of
46881
+ * sharing. The *description* names the ones that exist here, which is §12's carve-out: it varies
46882
+ * with a setting rather than with the turn, so the tool block stays byte-stable for a session
46883
+ * exactly as `ask_expert`'s does.
46884
+ */
46885
+ scope: external_exports.string().optional().describe('Whose code to search. "mine" (default) is this workspace only. Anything else names a shared scope \u2014 use it for "how did anyone solve X", never for questions about the code in front of you. Shared results are NOT on this machine and cannot be opened or edited.')
46827
46886
  });
46828
46887
  var DEFAULT_SIZE = 8;
46829
46888
  var REMOTE_GUIDANCE = [
@@ -46867,10 +46926,12 @@ function createSearchCodebaseTool(options) {
46867
46926
  const startedAt = Date.now();
46868
46927
  try {
46869
46928
  const size = params.size ?? DEFAULT_SIZE;
46870
- const wantsTeam = params.scope === "team";
46871
- const teamUnavailable = wantsTeam && options.teamAlias === void 0;
46872
- const searchingTeam = wantsTeam && options.teamAlias !== void 0;
46873
- const collection = searchingTeam ? options.teamAlias : options.index;
46929
+ const requested = params.scope?.trim() ?? "mine";
46930
+ const wantsTeam = requested.length > 0 && requested.toLowerCase() !== "mine";
46931
+ const alias = aliasForScope(requested, options.teamAliases ?? []);
46932
+ const teamUnavailable = wantsTeam && alias === void 0;
46933
+ const searchingTeam = wantsTeam && alias !== void 0;
46934
+ const collection = searchingTeam ? alias : options.index;
46874
46935
  const vector = await options.embedder.embed(params.query);
46875
46936
  const hits = await options.searcher.searchByVector(collection, vector, {
46876
46937
  size,
@@ -46916,7 +46977,12 @@ ${hit.text}`;
46916
46977
  "These are approximate. Read the files before relying on them, and use search_files if you know the exact term.",
46917
46978
  ...teamUnavailable ? [
46918
46979
  "",
46919
- "Team scope was asked for but no shared index is configured, so only this workspace was searched. Do not conclude from this that no colleague has solved it \u2014 their work was not looked at."
46980
+ /*
46981
+ * Which it was matters: nothing configured is a different thing to fix from a
46982
+ * scope that was misspelled, and naming the ones that exist turns a dead end
46983
+ * into a retry the model can get right.
46984
+ */
46985
+ (options.teamAliases ?? []).length === 0 ? "A shared scope was asked for but none is configured, so only this workspace was searched. Do not conclude from this that no colleague has solved it \u2014 their work was not looked at." : `There is no shared scope called "${requested}". The ones configured here are: ${(options.teamAliases ?? []).join(", ")}. Only this workspace was searched, so do not conclude that no colleague has solved it.`
46920
46986
  ] : [],
46921
46987
  ...anyRemote ? ["", ...REMOTE_GUIDANCE] : [],
46922
46988
  "",
@@ -47024,8 +47090,10 @@ ${hit.text}`;
47024
47090
  }
47025
47091
  async function indexTeamSkills(options) {
47026
47092
  await options.writer.ensureCollection(options.collection, options.embedder.dimensions, options.signal);
47027
- if (options.alias !== void 0 && options.writer.ensureAlias !== void 0) {
47028
- await options.writer.ensureAlias(options.collection, options.alias, options.signal);
47093
+ if (options.writer.ensureAlias !== void 0) {
47094
+ for (const alias of options.aliases ?? []) {
47095
+ await options.writer.ensureAlias(options.collection, alias, options.signal);
47096
+ }
47029
47097
  }
47030
47098
  if (options.skills.length === 0)
47031
47099
  return 0;
@@ -50176,7 +50244,8 @@ async function indexWorkspace(options) {
50176
50244
  };
50177
50245
  await writer.ensureCollection(index, embedder.dimensions, signal);
50178
50246
  if (options.alias !== void 0 && writer.ensureAlias !== void 0) {
50179
- await writer.ensureAlias(index, options.alias, signal);
50247
+ for (const alias of options.alias)
50248
+ await writer.ensureAlias(index, alias, signal);
50180
50249
  }
50181
50250
  const signature = chunkSignatureFor(options.chunkOptions);
50182
50251
  const stale = options.manifest.model !== embedder.model || options.manifest.dimensions !== embedder.dimensions || options.manifest.chunkSignature !== signature;
@@ -62562,7 +62631,7 @@ ${preview.text}` } : {}
62562
62631
  ...activePlan !== void 0 && activePlan.trim().length > 0 ? { plan: activePlan } : {},
62563
62632
  // Only when a pool actually exists: telling the model about a tool it has not been given
62564
62633
  // is how it comes to report that it looked somewhere it could not reach.
62565
- teamSkillsAvailable: config2.embedder?.skillsAlias !== void 0,
62634
+ teamSkillsAvailable: skillAliases(config2).length > 0,
62566
62635
  /*
62567
62636
  * Read from config rather than from the registry, because the prompt is built before the
62568
62637
  * registry is. Only the *off* case is claimed: "on but uv is missing" leaves the model
@@ -62699,7 +62768,7 @@ ${direction}` : attachMentions(text, mentions);
62699
62768
  * to look and every hit can say whose it is. Both absent on a solo install,
62700
62769
  * where team scope is simply unavailable and says so.
62701
62770
  */
62702
- ...config2.embedder?.indexAlias !== void 0 ? { teamAlias: config2.embedder.indexAlias } : {},
62771
+ ...codebaseAliases(config2).length > 0 ? { teamAliases: codebaseAliases(config2) } : {},
62703
62772
  ...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
62704
62773
  } : void 0,
62705
62774
  /*
@@ -62715,10 +62784,11 @@ ${direction}` : attachMentions(text, mentions);
62715
62784
  * The team's shared skills. Needs an alias, a connection and an embedder — without
62716
62785
  * all three there is nothing to search, and the tool is simply not offered.
62717
62786
  */
62718
- config2.embedder?.skillsAlias !== void 0 && search !== void 0 && embedder !== void 0 ? {
62787
+ skillAliases(config2).length > 0 && search !== void 0 && embedder !== void 0 ? {
62719
62788
  searcher: search.searcher,
62720
62789
  embedder,
62721
- collection: config2.embedder.skillsAlias,
62790
+ // The first is the default circle, exactly as it is for the codebase index.
62791
+ collection: skillAliases(config2)[0],
62722
62792
  ...indexOwner(config2) !== void 0 ? { owner: indexOwner(config2) } : {}
62723
62793
  } : void 0,
62724
62794
  /*
@@ -63692,8 +63762,8 @@ ${direction}` : attachMentions(text, mentions);
63692
63762
  }
63693
63763
  async function handleAttachTeamAlias() {
63694
63764
  const config2 = await loadSettings();
63695
- const alias = config2.embedder?.indexAlias;
63696
- if (alias === void 0) {
63765
+ const aliases = codebaseAliases(config2);
63766
+ if (aliases.length === 0) {
63697
63767
  post({
63698
63768
  type: "teamAliasAttached",
63699
63769
  error: "Set a team index alias in Settings \u2192 Search first \u2014 there is nothing to attach to."
@@ -63718,7 +63788,8 @@ ${direction}` : attachMentions(text, mentions);
63718
63788
  });
63719
63789
  return;
63720
63790
  }
63721
- await writer.ensureAlias(index, alias);
63791
+ for (const alias of aliases)
63792
+ await writer.ensureAlias(index, alias);
63722
63793
  let attributed = 0;
63723
63794
  const owner = indexOwner(config2);
63724
63795
  if (owner !== void 0 && writer.attributeUnowned !== void 0) {
@@ -63728,7 +63799,7 @@ ${direction}` : attachMentions(text, mentions);
63728
63799
  ...project !== void 0 ? { project } : {}
63729
63800
  });
63730
63801
  }
63731
- post({ type: "teamAliasAttached", alias, index, attributed });
63802
+ post({ type: "teamAliasAttached", alias: aliases.join(", "), index, attributed });
63732
63803
  } catch (error51) {
63733
63804
  post({
63734
63805
  type: "teamAliasAttached",
@@ -64403,7 +64474,7 @@ ${direction}` : attachMentions(text, mentions);
64403
64474
  writer: createVectorIndexWriter(httpClient, search.store, await vectorStoreConnectionFor(search.store, search.id)),
64404
64475
  embedder,
64405
64476
  collection,
64406
- ...config2.embedder?.skillsAlias !== void 0 ? { alias: config2.embedder.skillsAlias } : {},
64477
+ aliases: skillAliases(config2),
64407
64478
  skills: withBodies,
64408
64479
  signal,
64409
64480
  onProgress: (done, total) => reportIndexing("teamSkills", "Embedding and sending", { done, total }),
@@ -64910,7 +64981,7 @@ ${direction}` : attachMentions(text, mentions);
64910
64981
  const manifestFile = manifestPath(index, search.id);
64911
64982
  const owner = indexOwner(config2);
64912
64983
  const project = indexProject();
64913
- const alias = config2.embedder?.indexAlias;
64984
+ const aliases = codebaseAliases(config2);
64914
64985
  try {
64915
64986
  const manifest = await loadIndexManifest(manifestFile, embedder);
64916
64987
  const isIgnored = await ignoredFilesPredicate();
@@ -64937,7 +65008,7 @@ ${direction}` : attachMentions(text, mentions);
64937
65008
  */
64938
65009
  ...owner !== void 0 ? { owner } : {},
64939
65010
  ...project !== void 0 ? { project } : {},
64940
- ...alias !== void 0 ? { alias } : {},
65011
+ alias: aliases,
64941
65012
  onProgress: (progress) => post({ type: "indexProgress", progress }),
64942
65013
  signal: indexingAbort.signal
64943
65014
  });
@@ -68840,7 +68911,11 @@ function reachableHosts(bindAddress, port, extra = []) {
68840
68911
  }
68841
68912
  }
68842
68913
  }
68843
- for (const name of extra) add(name);
68914
+ for (const name of extra) {
68915
+ add(name);
68916
+ const trimmed = name.trim().toLowerCase();
68917
+ if (trimmed.length > 0) names.add(trimmed);
68918
+ }
68844
68919
  return [...names];
68845
68920
  }
68846
68921
  function reachableOrigins(hosts, extra = []) {
@@ -69094,6 +69169,10 @@ function checkRequest(request, policy, options) {
69094
69169
  }
69095
69170
  return void 0;
69096
69171
  }
69172
+ var frameAncestors = [];
69173
+ function setFrameAncestors(origins) {
69174
+ frameAncestors = origins.map((origin) => origin.trim()).filter((origin) => origin.length > 0);
69175
+ }
69097
69176
  function securityHeaders() {
69098
69177
  return {
69099
69178
  "Content-Security-Policy": [
@@ -69105,7 +69184,11 @@ function securityHeaders() {
69105
69184
  "img-src 'self' data:",
69106
69185
  "font-src 'self'",
69107
69186
  "connect-src 'self'",
69108
- "frame-ancestors 'none'",
69187
+ /*
69188
+ * `'none'` unless somebody named an origin. A list here is a deliberate act by an operator
69189
+ * who wants this page inside another — a lab, a dashboard — and it names exactly which.
69190
+ */
69191
+ frameAncestors.length === 0 ? "frame-ancestors 'none'" : `frame-ancestors ${frameAncestors.join(" ")}`,
69109
69192
  "base-uri 'none'",
69110
69193
  "form-action 'none'"
69111
69194
  ].join("; "),
@@ -70032,6 +70115,7 @@ var STREAM_PADDING = `: ${(() => {
70032
70115
  async function startServer(options) {
70033
70116
  const log = options.logSink ?? ((line) => process.stderr.write(`${line}
70034
70117
  `));
70118
+ setFrameAncestors(options.allowFrameAncestors ?? []);
70035
70119
  const identity = options.identity ?? (options.noToken === true ? new OpenIdentity() : new SingleUserIdentity(options.handoffSeconds));
70036
70120
  const roles = options.roles ?? SINGLE_USER_POLICY;
70037
70121
  const sharedStore = options.sharedConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chosengeneration/light-code",
3
- "version": "0.64.1",
3
+ "version": "0.68.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",