@inerrata-corporation/errata 2.0.0-dev.44 → 2.0.0-dev.45

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 (2) hide show
  1. package/errata.mjs +66 -2
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -20931,6 +20931,11 @@ var init_client = __esm({
20931
20931
  async actAs(handle2) {
20932
20932
  return this.json("POST", "/api/gate/act-as", { handle: handle2 });
20933
20933
  }
20934
+ /** Resolve-or-create the org's project for a repo locator (ambient link,
20935
+ * PJ-entity). Requires user identity on the JWT — login-gated like actAs. */
20936
+ async resolveProject(locator, name2) {
20937
+ return this.json("POST", "/api/gate/projects/resolve", name2 ? { locator, name: name2 } : { locator });
20938
+ }
20934
20939
  // ─── ingest ────────────────────────────────────────────────────────
20935
20940
  /** Upload one outbox batch (projected onto the reconciled wire) and fold
20936
20941
  * the per-decision response into flush accounting.
@@ -42664,7 +42669,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
42664
42669
  }
42665
42670
 
42666
42671
  // src/engine.ts
42667
- var DAEMON_VERSION = true ? "2.0.0-dev.44" : "2.0.0-alpha.0";
42672
+ var DAEMON_VERSION = true ? "2.0.0-dev.45" : "2.0.0-alpha.0";
42668
42673
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
42669
42674
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
42670
42675
  var GIT_OP_MUTE_MS = 4e3;
@@ -44722,6 +44727,30 @@ function runNpmInstall(channel) {
44722
44727
  // src/multi.ts
44723
44728
  init_cloud_endpoint_policy();
44724
44729
  init_cloud_auth();
44730
+
44731
+ // src/project-link.ts
44732
+ async function ensureProjectLink(root, profile, client) {
44733
+ const locator = profile.repoLocator;
44734
+ if (!locator) return { linked: false, reason: "no-locator" };
44735
+ if (profile.projectId && profile.projectLocator === locator) {
44736
+ return { linked: false, reason: "already-linked" };
44737
+ }
44738
+ try {
44739
+ const res = await client.resolveProject(locator, profile.name);
44740
+ profile.projectId = res.project.id;
44741
+ profile.projectLocator = locator;
44742
+ saveProfile(root, profile);
44743
+ return { linked: true, projectId: res.project.id, created: res.created };
44744
+ } catch (err2) {
44745
+ return {
44746
+ linked: false,
44747
+ reason: "error",
44748
+ detail: err2 instanceof Error ? err2.message : String(err2)
44749
+ };
44750
+ }
44751
+ }
44752
+
44753
+ // src/multi.ts
44725
44754
  function normPath(p) {
44726
44755
  return p.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
44727
44756
  }
@@ -44869,6 +44898,7 @@ async function startMultiDaemon(opts = {}) {
44869
44898
  return { attached: false, id: null, reason: err2 instanceof Error ? err2.message : "build-failed" };
44870
44899
  }
44871
44900
  records.push(rec);
44901
+ void ambientLinkAll();
44872
44902
  app.route(`/ws/${rec.id}`, rec.webApp);
44873
44903
  try {
44874
44904
  writeFileSync15(
@@ -45075,6 +45105,20 @@ async function startMultiDaemon(opts = {}) {
45075
45105
  if (opts.reindexOnStart !== false && records.length > 0) {
45076
45106
  void reindexAll({ skipEmbed: opts.skipEmbed ?? true });
45077
45107
  }
45108
+ const ambientLinkAll = async () => {
45109
+ const c = loadConfig();
45110
+ if (!c.consent.sync || !hasCloudCredential(c)) return;
45111
+ const client = cloudNow();
45112
+ for (const r of records) {
45113
+ const out2 = await ensureProjectLink(r.root, r.engine.profile, client);
45114
+ if (out2.linked) {
45115
+ console.log(
45116
+ `[errata] linked ${r.engine.profile.name} \u2192 project ${out2.projectId}${out2.created ? " (created)" : ""}`
45117
+ );
45118
+ }
45119
+ }
45120
+ };
45121
+ void ambientLinkAll();
45078
45122
  const packageAutoAll = async () => {
45079
45123
  const out2 = /* @__PURE__ */ new Map();
45080
45124
  for (const r of records) {
@@ -46071,7 +46115,8 @@ async function cmdStatus() {
46071
46115
  console.log(` version: ${DAEMON_VERSION} (update channel: ${cfg.updateChannel})`);
46072
46116
  console.log(` workspace: ${profile ? `${profile.name} (${profile.id})` : "(not initialized)"}`);
46073
46117
  if (profile) {
46074
- console.log(` repo: ${profile.repoLocator ?? "(no git remote \u2014 unlinked)"}`);
46118
+ const link = profile.projectId ? ` \u2192 project ${profile.projectId.slice(0, 8)}` : " (unlinked)";
46119
+ console.log(` repo: ${profile.repoLocator ? `${profile.repoLocator}${link}` : "(no git remote \u2014 unlinked)"}`);
46075
46120
  console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
46076
46121
  console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
46077
46122
  }
@@ -46275,12 +46320,31 @@ async function cmdLoginOAuth(cfg) {
46275
46320
  nextCfg.email = me.handle;
46276
46321
  saveConfig(nextCfg);
46277
46322
  console.log(`logged in as ${me.handle} (${me.tier}) \u2014 tokens stored at ${globalConfigPath()}`);
46323
+ await linkRegisteredWorkspaces(nextCfg);
46278
46324
  } catch (err2) {
46279
46325
  console.error(`signed in, but identity check failed: ${err2 instanceof Error ? err2.message : err2}`);
46280
46326
  console.error(` credentials were not stored; try again or paste a key: errata login --token <key>`);
46281
46327
  process.exitCode = 1;
46282
46328
  }
46283
46329
  }
46330
+ async function linkRegisteredWorkspaces(cfg) {
46331
+ if (!cfg.consent.sync) return;
46332
+ const client = authedCloudClient(cfg);
46333
+ for (const w of listWorkspaces()) {
46334
+ try {
46335
+ const profile = loadProfile(w.path);
46336
+ if (!profile) continue;
46337
+ refreshRepoLocator(w.path, profile);
46338
+ const out2 = await ensureProjectLink(w.path, profile, client);
46339
+ if (out2.linked) {
46340
+ console.log(
46341
+ ` linked ${profile.name} \u2192 project ${out2.projectId}${out2.created ? " (created)" : ""}`
46342
+ );
46343
+ }
46344
+ } catch {
46345
+ }
46346
+ }
46347
+ }
46284
46348
  async function cmdLogin() {
46285
46349
  const cfg = loadConfig();
46286
46350
  const flags2 = parseFlags(rest);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.0-dev.44",
3
+ "version": "2.0.0-dev.45",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {