@gitroll/tacitt-cli 0.6.2 → 0.6.4

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 (42) hide show
  1. package/dist/{agent-setup-Dv_mQ38P.mjs → agent-setup-C7iqLMYm.mjs} +2 -2
  2. package/dist/agent-setup-worker.mjs +5 -5
  3. package/dist/cli.mjs +9 -180
  4. package/dist/codex-title-worker.mjs +1 -1
  5. package/dist/configured-preview-worker.mjs +5 -5
  6. package/dist/configured-session-worker.mjs +5 -5
  7. package/dist/{frame-DGun31Uc.mjs → frame-BGFmADbg.mjs} +1 -1
  8. package/dist/{heap-BR8WjR25.mjs → heap-DQbsSUrB.mjs} +18 -55
  9. package/dist/inspection-worker.mjs +4 -4
  10. package/dist/job-D4N5Pe91.mjs +6284 -0
  11. package/dist/{locate-JYtFmKu-.mjs → locate-CNU4z9G1.mjs} +4 -0
  12. package/dist/{model-C1VzgKLi.mjs → model-CZeHzKif.mjs} +1 -1
  13. package/dist/operation-executor.mjs +3 -3
  14. package/dist/preview-worker.mjs +1 -1
  15. package/dist/privacy-validator.mjs +1 -1
  16. package/dist/{query-CQ6Tr5zC.mjs → query-BMvtisKu.mjs} +1413 -5502
  17. package/dist/{run-hQ_W2p_Y.mjs → run-u2EfHjz4.mjs} +4 -4
  18. package/dist/{src-JoT3L94j.mjs → src-BRwicVza.mjs} +6 -4
  19. package/dist/{src-CGFwLUd6.mjs → src-BgoSvnXe.mjs} +4 -4
  20. package/dist/{src--Ln5GHdz.mjs → src-DmSIVU7-.mjs} +130 -13
  21. package/dist/store-database-worker.mjs +1 -1
  22. package/dist/web/assets/index-CndETc8f.js +169 -0
  23. package/dist/web/index.html +1 -1
  24. package/package.json +1 -1
  25. package/skills/tacitt/INDEX.md +1 -1
  26. package/skills/tacitt/SKILL.md +4 -2
  27. package/skills/tacitt/references/INDEX.md +2 -2
  28. package/skills/tacitt/references/commands.md +2 -0
  29. package/skills/tacitt/references/journey.md +3 -1
  30. package/skills/tacitt/references/remote-workers.md +6 -0
  31. package/skills/tacitt/references/send.md +3 -2
  32. package/skills/tacitt/scripts/INDEX.md +36 -36
  33. package/skills/tacitt/scripts/answer.mjs +41 -11
  34. package/skills/tacitt/scripts/journey-card-consolidation.d.mts +2 -0
  35. package/skills/tacitt/scripts/journey-card-consolidation.mjs +80 -5
  36. package/skills/tacitt/scripts/journey-card-values.d.mts +4 -0
  37. package/skills/tacitt/scripts/journey-card-values.mjs +21 -7
  38. package/skills/tacitt/scripts/journey-tasks.d.mts +1 -0
  39. package/skills/tacitt/scripts/journey-tasks.mjs +28 -12
  40. package/skills/tacitt/scripts/journey.mjs +3 -2
  41. package/dist/job-CYsjL4AT.mjs +0 -990
  42. package/dist/web/assets/index-C9LcK9ls.js +0 -169
@@ -1,5 +1,5 @@
1
- import "./locate-JYtFmKu-.mjs";
2
- import "./src--Ln5GHdz.mjs";
1
+ import "./locate-CNU4z9G1.mjs";
2
+ import "./src-DmSIVU7-.mjs";
3
3
  import { z } from "zod";
4
4
  import { Worker } from "node:worker_threads";
5
5
  //#region apps/cli/src/agent-setup/index.ts
@@ -1,8 +1,8 @@
1
- import { J as listAgentSetup } from "./src-JoT3L94j.mjs";
2
- import { Dn as createStaticProcessor, dn as workspaceSchema, ln as sessionSchema } from "./locate-JYtFmKu-.mjs";
3
- import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-CGFwLUd6.mjs";
4
- import { at as maximumAgentSetupSessions, ui as effectiveTreatmentSchema } from "./src--Ln5GHdz.mjs";
5
- import "./agent-setup-Dv_mQ38P.mjs";
1
+ import { J as listAgentSetup } from "./src-BRwicVza.mjs";
2
+ import { Dn as createStaticProcessor, dn as workspaceSchema, ln as sessionSchema } from "./locate-CNU4z9G1.mjs";
3
+ import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-BgoSvnXe.mjs";
4
+ import { fi as effectiveTreatmentSchema, ot as maximumAgentSetupSessions } from "./src-DmSIVU7-.mjs";
5
+ import "./agent-setup-C7iqLMYm.mjs";
6
6
  import { z } from "zod";
7
7
  import { parentPort, workerData } from "node:worker_threads";
8
8
  //#region apps/cli/src/agent-setup/worker.ts
package/dist/cli.mjs CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { _ as readStateDump, a as readAgentPresence, b as traceStartup, d as helpText, f as parseOptions, g as startupFailure, h as permissionDiagnostic, i as invoke, l as awaitingPassport, m as longCommands, n as readOperation, o as createRuntime, p as businessCommands, r as waitOperation, s as executorEventSchema, t as cancelOperation, u as createRenderActivity, v as createExecutionPort, y as startHost$1 } from "./query-CQ6Tr5zC.mjs";
3
- import { nt as makePrivateDirectory, rt as openPrivateFile } from "./src-JoT3L94j.mjs";
4
- import { $t as safeField, Qt as safeCode, Xt as ApplicationError } from "./locate-JYtFmKu-.mjs";
5
- import { Zn as reviewTransportBytes, et as readWorkspaceOutcomes, oi as stateSchema, st as resolveFailureLocation } from "./src--Ln5GHdz.mjs";
6
- import { _t as isCoordinationBusy } from "./heap-BR8WjR25.mjs";
2
+ import { _ as permissionDiagnostic, a as readAgentPresence, d as guardDetachedStartup, f as createRenderActivity, g as longCommands, h as businessCommands, i as invoke, l as awaitingPassport, m as parseOptions, n as readOperation, o as createRuntime, p as helpText, r as waitOperation, s as executorEventSchema, t as cancelOperation, u as serveDetached, v as startupFailure, y as traceStartup } from "./query-BMvtisKu.mjs";
3
+ import { nt as makePrivateDirectory, rt as openPrivateFile } from "./src-BRwicVza.mjs";
4
+ import { A as createExecutionPort, j as startHost, k as readStateDump } from "./job-D4N5Pe91.mjs";
5
+ import { $t as safeField, Qt as safeCode, Xt as ApplicationError } from "./locate-CNU4z9G1.mjs";
6
+ import { $n as reviewTransportBytes, ci as stateSchema, ct as resolveFailureLocation, tt as readWorkspaceOutcomes } from "./src-DmSIVU7-.mjs";
7
+ import { _t as isCoordinationBusy } from "./heap-DQbsSUrB.mjs";
7
8
  import { constants, createReadStream, write } from "node:fs";
8
9
  import { z } from "zod";
9
10
  import { lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
@@ -148,6 +149,7 @@ function hostFinished(now, endedAt, settledAt) {
148
149
  return now - endedAt >= 108e5 || settledAt !== void 0 && now - settledAt >= 18e5;
149
150
  }
150
151
  async function serve(options, journeyId) {
152
+ guardDetachedStartup();
151
153
  let initializing;
152
154
  let shutdownPhase = "application-and-account";
153
155
  let stopping;
@@ -227,6 +229,7 @@ async function serve(options, journeyId) {
227
229
  }, 100);
228
230
  };
229
231
  const runtime = await createRuntime(options, {
232
+ servingHost: true,
230
233
  stopHost: scheduleStop,
231
234
  settleStartup: async () => {
232
235
  await initializing;
@@ -255,7 +258,7 @@ async function serve(options, journeyId) {
255
258
  await runtime.application.getSensitiveTerms();
256
259
  if (journeyId && !await runtime.application.journey?.get({ journeyId })) throw new ApplicationError("INVALID_TRANSITION");
257
260
  traceStartup("host-start");
258
- host = await startHost$1({
261
+ host = await startHost({
259
262
  application: runtime.application,
260
263
  account: runtime.account,
261
264
  nativeInspection: runtime.nativeInspection,
@@ -949,180 +952,6 @@ function writeInstallNotice(result) {
949
952
  });
950
953
  }
951
954
  //#endregion
952
- //#region apps/cli/src/serve-detach.ts
953
- const readySchema = z.object({
954
- event: z.literal("ready"),
955
- result: z.object({
956
- url: z.string(),
957
- journeyId: z.string()
958
- })
959
- });
960
- const failureSchema = z.object({
961
- ok: z.literal(false),
962
- error: z.object({ code: z.string() })
963
- });
964
- const recordSchema = z.object({
965
- url: z.string(),
966
- journeyId: z.string(),
967
- pid: z.number().int().positive(),
968
- log: z.string()
969
- });
970
- const recordPath = (directory, journeyId) => join(directory, `${journeyId}.host.json`);
971
- function running(pid) {
972
- try {
973
- process.kill(pid, 0);
974
- return true;
975
- } catch {
976
- return false;
977
- }
978
- }
979
- /**
980
- * The detached host this state directory recorded for the journey, while its process runs and
981
- * its URL answers; a stale record (a stopped host, a reused pid) is ignored.
982
- */
983
- async function liveHost(directory, journeyId) {
984
- let record;
985
- try {
986
- const parsed = recordSchema.safeParse(JSON.parse(await readFile(recordPath(directory, journeyId), "utf8")));
987
- if (!parsed.success || parsed.data.journeyId !== journeyId) return null;
988
- record = parsed.data;
989
- } catch {
990
- return null;
991
- }
992
- if (!running(record.pid)) return null;
993
- try {
994
- await fetch(record.url, { signal: AbortSignal.timeout(2e3) });
995
- return record;
996
- } catch {
997
- return null;
998
- }
999
- }
1000
- /** The same CLI arguments without `--detach` and with the journey read from `input`. */
1001
- function hostArguments(args, input) {
1002
- const kept = [];
1003
- for (let index = 0; index < args.length; index += 1) {
1004
- const arg = args[index];
1005
- if (arg === void 0 || arg === "--detach" || arg.startsWith("--input=")) continue;
1006
- if (arg === "--input") {
1007
- index += 1;
1008
- continue;
1009
- }
1010
- kept.push(arg);
1011
- }
1012
- return [
1013
- ...kept,
1014
- "--input",
1015
- input
1016
- ];
1017
- }
1018
- /**
1019
- * Starts `journey.serve` in its own process group, outside the agent tool that ran this command,
1020
- * so an agent host's limit on background tasks does not stop the panel mid-Send (BL-210). The
1021
- * host's output goes to an owner-only log; this command prints its readiness with the pid.
1022
- * A detached host already serving the journey is reused (`reused: true`), so the Skill helper can
1023
- * ensure one owns the panel before the agent's turn ends (ADR 0227).
1024
- */
1025
- async function serveDetached(args, stateDir, journeyId) {
1026
- const directory = join(stateDir, "serve");
1027
- await mkdir(directory, {
1028
- recursive: true,
1029
- mode: 448
1030
- });
1031
- let retries = 0;
1032
- let delay = 500;
1033
- for (;;) {
1034
- const existing = await liveHost(directory, journeyId);
1035
- if (existing) {
1036
- process.stdout.write(`${JSON.stringify({
1037
- ok: true,
1038
- event: "ready",
1039
- result: {
1040
- ...existing,
1041
- reused: true
1042
- }
1043
- })}\n`);
1044
- return;
1045
- }
1046
- const result = await startHost(args, directory, journeyId, Date.now() + 6e4);
1047
- if (!result) return;
1048
- if (!result.busy || retries >= 5) {
1049
- process.stderr.write(`The panel host did not start. Its output is in ${result.log}.\n`);
1050
- process.exitCode = 1;
1051
- return;
1052
- }
1053
- process.stderr.write("COORDINATION_BUSY: retrying panel host startup.\n");
1054
- retries += 1;
1055
- await setTimeout$1(delay);
1056
- delay = Math.min(delay * 2, 4e3);
1057
- }
1058
- }
1059
- /** Retry only an exited child's explicit busy refusal; never start two live owners. */
1060
- async function startHost(args, directory, journeyId, deadline) {
1061
- const id = randomUUID();
1062
- const input = join(directory, `${id}.json`);
1063
- const log = join(directory, `${id}.log`);
1064
- await writeFile(input, JSON.stringify({ journeyId }), { mode: 384 });
1065
- const output = await open(log, "w", 384);
1066
- const entry = process.argv[1];
1067
- if (!entry) throw new Error("INVALID_ARGUMENTS");
1068
- const child = spawn(process.execPath, [
1069
- ...process.execArgv,
1070
- entry,
1071
- ...hostArguments(args, input)
1072
- ], {
1073
- detached: true,
1074
- stdio: [
1075
- "ignore",
1076
- output.fd,
1077
- output.fd
1078
- ]
1079
- });
1080
- let exited = null;
1081
- child.once("exit", (code) => exited = code ?? 1);
1082
- child.unref();
1083
- await output.close();
1084
- let busy = false;
1085
- while (Date.now() < deadline) {
1086
- const ready = (await readFile(log, "utf8")).split("\n").flatMap((line) => {
1087
- try {
1088
- const parsed = JSON.parse(line);
1089
- const failure = failureSchema.safeParse(parsed);
1090
- if (failure.success) busy = failure.data.error.code === "COORDINATION_BUSY";
1091
- const value = readySchema.safeParse(parsed);
1092
- return value.success ? [value.data.result] : [];
1093
- } catch {
1094
- return [];
1095
- }
1096
- })[0];
1097
- if (ready && child.pid !== void 0) {
1098
- const record = {
1099
- ...ready,
1100
- pid: child.pid,
1101
- log
1102
- };
1103
- const temporary = `${recordPath(directory, journeyId)}.${id}.tmp`;
1104
- await writeFile(temporary, JSON.stringify(record), { mode: 384 });
1105
- await rename(temporary, recordPath(directory, journeyId));
1106
- process.stdout.write(`${JSON.stringify({
1107
- ok: true,
1108
- event: "ready",
1109
- result: {
1110
- ...record,
1111
- reused: false
1112
- }
1113
- })}\n`);
1114
- return;
1115
- }
1116
- if (exited !== null) break;
1117
- await setTimeout$1(Math.min(100, Math.max(0, deadline - Date.now())));
1118
- }
1119
- if (exited === null) child.kill();
1120
- return {
1121
- busy: exited !== null && busy,
1122
- log
1123
- };
1124
- }
1125
- //#endregion
1126
955
  //#region apps/cli/src/business-input.ts
1127
956
  const defaultBusinessInputBytes = 1048576;
1128
957
  const reviewCommands = /* @__PURE__ */ new Set([
@@ -1,4 +1,4 @@
1
- import { i as errorCode } from "./model-C1VzgKLi.mjs";
1
+ import { i as errorCode } from "./model-CZeHzKif.mjs";
2
2
  import { a as titleHintLimits, i as encodeTitleError, o as titleInputSchema, t as assertTitleHeap } from "./heap-1FYhGds4.mjs";
3
3
  import { stat } from "node:fs/promises";
4
4
  import { isAbsolute, join } from "node:path";
@@ -1,8 +1,8 @@
1
- import { Y as createConfiguredPreviewStream } from "./src-JoT3L94j.mjs";
2
- import { Dn as createStaticProcessor, dn as workspaceSchema, ln as sessionSchema } from "./locate-JYtFmKu-.mjs";
3
- import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-CGFwLUd6.mjs";
4
- import { ui as effectiveTreatmentSchema } from "./src--Ln5GHdz.mjs";
5
- import { a as classifyRecord, n as assertPreviewHeap, t as runPreview } from "./run-hQ_W2p_Y.mjs";
1
+ import { Y as createConfiguredPreviewStream } from "./src-BRwicVza.mjs";
2
+ import { Dn as createStaticProcessor, dn as workspaceSchema, ln as sessionSchema } from "./locate-CNU4z9G1.mjs";
3
+ import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-BgoSvnXe.mjs";
4
+ import { fi as effectiveTreatmentSchema } from "./src-DmSIVU7-.mjs";
5
+ import { a as classifyRecord, n as assertPreviewHeap, t as runPreview } from "./run-u2EfHjz4.mjs";
6
6
  import { z } from "zod";
7
7
  import { parentPort, workerData } from "node:worker_threads";
8
8
  //#region apps/cli/src/preview/run.ts
@@ -1,8 +1,8 @@
1
- import { et as safeError, h as captureConfiguredSessionJob, j as runConfiguredSessionJob, u as runConfiguredScanJob, z as gitSeedsProvider } from "./src-JoT3L94j.mjs";
2
- import { Dn as createStaticProcessor, Qt as safeCode } from "./locate-JYtFmKu-.mjs";
3
- import { l as createNativeAdapters } from "./src-CGFwLUd6.mjs";
4
- import "./src--Ln5GHdz.mjs";
5
- import { d as runJourneyBaseJob, i as runJourneyOutputVerifyJob, n as runJourneyOutputJob, r as runJourneyOutputShardJob } from "./job-CYsjL4AT.mjs";
1
+ import { et as safeError, h as captureConfiguredSessionJob, j as runConfiguredSessionJob, u as runConfiguredScanJob, z as gitSeedsProvider } from "./src-BRwicVza.mjs";
2
+ import { d as runJourneyBaseJob, i as runJourneyOutputVerifyJob, n as runJourneyOutputJob, r as runJourneyOutputShardJob } from "./job-D4N5Pe91.mjs";
3
+ import { Dn as createStaticProcessor, Qt as safeCode } from "./locate-CNU4z9G1.mjs";
4
+ import { l as createNativeAdapters } from "./src-BgoSvnXe.mjs";
5
+ import "./src-DmSIVU7-.mjs";
6
6
  import { parentPort } from "node:worker_threads";
7
7
  //#region apps/cli/src/configured-session-worker.ts
8
8
  const port = parentPort;
@@ -1,4 +1,4 @@
1
- import { ur as ProcessingError } from "./locate-JYtFmKu-.mjs";
1
+ import { ur as ProcessingError } from "./locate-CNU4z9G1.mjs";
2
2
  //#region packages/processing/src/compression/frame.ts
3
3
  function createZstdFrameCheck(fail = () => {
4
4
  throw new ProcessingError("PROCESSING_INVALID_RECORD");
@@ -1,65 +1,16 @@
1
- import { S as readPrivateReviewPayload, at as windowsOwnerOnly, it as restrictToOwner, rt as openPrivateFile, tt as exclusiveLock, x as writePrivateReviewPayload } from "./src-JoT3L94j.mjs";
2
- import { At as journeyTermSchema, It as termTypeSchema, Mt as reviewTermsResultSchema, Xt as ApplicationError, _ as semanticFindingSchema, b as validateBReview, c as textDigest, d as reviewAlignmentAudit, dt as nativeJourneySchema, er as isStaticCategory, ft as journeyGuidanceSchema, g as validateReviewAlignment, gt as journeyWorkSuggestionSchema, ht as journeyDescribeSchema, i as reviewBatchSchema, it as journeyDigestSchema, jt as reviewTermsInputSchema, kt as privacyTermSchema, l as validateReview, m as reviewAlignmentSchema, nn as reviewFamilies, o as reviewDigest, ot as journeyIdSchema, r as reviewBatchChunks, s as reviewSubmitSchema, sn as fileIdentitySchema, tn as familySelected, tr as staticCategories, u as findingReferenceKey, v as bContextEvidence, wn as createDetectionSummary } from "./locate-JYtFmKu-.mjs";
3
- import { $n as mergeBRepair, $t as journeyResourceSchema, At as validateAttemptAppend, B as validateInspectionBatch, Bt as newJourneyWork, Et as obsoleteJourney, Fn as confirmedHideGroupIds, Ft as applyClassificationProposal, G as validateInspectionFence, Gn as workPrivacyDecisions, Gr as isSkippedWork, Gt as hideFinishSchema, Hn as syncTermGroups, Ht as journeyContextQuerySchema, In as confirmedHideKey, It as classificationCommitSchema, J as validateInspectionQuery, Jn as reviewCandidateResourceSchema, Jr as mergePrivacyTerms, Jt as journeySearchSaveSchema, K as validateInspectionHead, Kr as selectedWorks, Kt as hidePublishSchema, Mn as bMaskedHits, Nt as journeyBatchReadSchema, Pr as journeySendSchema, Pt as journeyReviewStorageQuerySchema, Qn as bReviewDigest, Qt as journeyResourceQuerySchema, Rn as confirmedHideTerms, Un as retireWorkDescription, Ur as isReadingComplete, Ut as journeyContextSchema, V as validateInspectionBatches, Vn as maskedHitsStale, W as validateInspectionClaim, Wn as workDecisionDigest, Wr as isSelectedWork, Wt as hideBeginSchema, X as validateDetectionSummary, Xn as reviewRepairResourceSchema, Xt as journeyPolicyRespondSchema, Y as validateInspectionContribution, Yt as searchScopeDigest, Z as inspectionInputs, Zt as projectPreparationProgress, _ as projectJourneyInventory, _n as journeyCommitResultSchema, _r as preparationSettlementSchema, an as reviewAttemptsResultSchema, ar as scanGitSeedsId, b as bReviewScope, c as reconstructBFields, cn as sessionReconciliationResourceSchema, en as journeyIsolateSchema, fn as sessionReviewQuerySchema, fr as journeyInventoryReadSchema, gn as sessionUsefulnessResourceSchema, gr as preparationBeginSchema, h as semanticGroupKey, hn as sessionUsefulnessInputSchema, ht as candidateSortAvailable, in as reviewAttemptsQuerySchema, ir as scanSessionResourceSchema, jt as journeyGuidance, kr as staticSessionId, kt as attemptBudgetCodePoints, l as reviseGroupMembership, lr as validateScanExclusion, m as hideScopeDigest, mn as sessionReviewStatusSchema, mr as journeyPreparationProgressSchema, nn as sortingApplySchema, nr as scanCanonicalResourceSchema, o as bRereadDigest, oi as stateSchema, pn as sessionReviewResourceSchema, pr as journeyInventorySchema, pt as manualUploadSchema, q as validateInspectionInputs, qr as withReadingProgress, qt as journeySearchResultSchema, rn as reviewAttemptResourceSchema, s as reconcileBSession, sn as sessionReconcileResultSchema, t as scanBatchContextDigest, tn as journeyPlaceSchema, tr as scanAliasResourceSchema, u as resolveGroupSplit, un as sessionRereadResourceSchema, ut as manualUploadBindingSchema, v as preparationScope, vn as journeyCommitSchema, vr as preparationStartSchema, wn as settleConfirmedHides, wt as settleCorrections, xn as confirmedHideDeltaSchema, xr as applyCardAnswers, yn as journeyEventSchema, yr as validatePreparationFacts, zn as dictionaryHides } from "./src--Ln5GHdz.mjs";
1
+ import { S as readPrivateReviewPayload, at as windowsOwnerOnly, it as restrictToOwner, rt as openPrivateFile, tt as exclusiveLock, x as writePrivateReviewPayload } from "./src-BRwicVza.mjs";
2
+ import { At as journeyTermSchema, It as termTypeSchema, Mt as reviewTermsResultSchema, Xt as ApplicationError, _ as semanticFindingSchema, b as validateBReview, c as textDigest, d as reviewAlignmentAudit, dt as nativeJourneySchema, er as isStaticCategory, ft as journeyGuidanceSchema, g as validateReviewAlignment, gt as journeyWorkSuggestionSchema, ht as journeyDescribeSchema, i as reviewBatchSchema, it as journeyDigestSchema, jt as reviewTermsInputSchema, kt as privacyTermSchema, l as validateReview, m as reviewAlignmentSchema, nn as reviewFamilies, o as reviewDigest, ot as journeyIdSchema, r as reviewBatchChunks, s as reviewSubmitSchema, sn as fileIdentitySchema, tn as familySelected, tr as staticCategories, u as findingReferenceKey, v as bContextEvidence, wn as createDetectionSummary } from "./locate-CNU4z9G1.mjs";
3
+ import { $t as projectPreparationProgress, Bn as confirmedHideTerms, Cn as confirmedHideDeltaSchema, Cr as applyCardAnswers, En as settleConfirmedHides, Et as settleCorrections, Ft as journeyBatchReadSchema, G as validateInspectionClaim, Gn as retireWorkDescription, Gr as isReadingComplete, Gt as journeyContextSchema, H as validateInspectionBatches, Ht as newJourneyWork, Ir as journeySendSchema, It as journeyReviewStorageQuerySchema, J as validateInspectionInputs, Jr as selectedWorks, Jt as hidePublishSchema, K as validateInspectionFence, Kn as workDecisionDigest, Kr as isSelectedWork, Kt as hideBeginSchema, Ln as confirmedHideGroupIds, Lt as applyClassificationProposal, Mt as validateAttemptAppend, Nt as journeyGuidance, Ot as obsoleteJourney, Pn as bMaskedHits, Q as inspectionInputs, Qn as reviewRepairResourceSchema, Qt as journeyPolicyRespondSchema, Rn as confirmedHideKey, Rt as classificationCommitSchema, Un as maskedHitsStale, V as validateInspectionBatch, Vn as dictionaryHides, Wn as syncTermGroups, Wt as journeyContextQuerySchema, X as validateInspectionContribution, Xn as reviewCandidateResourceSchema, Xr as mergePrivacyTerms, Xt as journeySearchSaveSchema, Y as validateInspectionQuery, Yr as withReadingProgress, Yt as journeySearchResultSchema, Z as validateDetectionSummary, Zt as searchScopeDigest, _n as sessionUsefulnessInputSchema, an as reviewAttemptResourceSchema, bn as journeyCommitSchema, br as preparationStartSchema, c as reconstructBFields, ci as stateSchema, d as resolveGroupSplit, dr as validateScanExclusion, dt as manualUploadBindingSchema, en as journeyResourceQuerySchema, er as bReviewDigest, fn as sessionRereadResourceSchema, g as semanticGroupKey, gn as sessionReviewStatusSchema, gr as journeyPreparationProgressSchema, gt as candidateSortAvailable, h as hideScopeDigest, hn as sessionReviewResourceSchema, hr as journeyInventorySchema, in as sortingApplySchema, ir as scanCanonicalResourceSchema, jr as staticSessionId, jt as attemptBudgetCodePoints, l as chooseCheapPlacement, ln as sessionReconcileResultSchema, mn as sessionReviewQuerySchema, mr as journeyInventoryReadSchema, mt as manualUploadSchema, nn as journeyIsolateSchema, o as bRereadDigest, on as reviewAttemptsQuerySchema, or as scanSessionResourceSchema, q as validateInspectionHead, qn as workPrivacyDecisions, qr as isSkippedWork, qt as hideFinishSchema, rn as journeyPlaceSchema, rr as scanAliasResourceSchema, s as reconcileBSession, sn as reviewAttemptsResultSchema, sr as scanGitSeedsId, t as scanBatchContextDigest, tn as journeyResourceSchema, tr as mergeBRepair, u as reviseGroupMembership, un as sessionReconciliationResourceSchema, v as projectJourneyInventory, vn as sessionUsefulnessResourceSchema, vr as preparationBeginSchema, x as bReviewScope, xn as journeyEventSchema, xr as validatePreparationFacts, y as preparationScope, yn as journeyCommitResultSchema, yr as preparationSettlementSchema } from "./src-DmSIVU7-.mjs";
4
4
  import { constants } from "node:fs";
5
5
  import { z } from "zod";
6
6
  import { copyFile, link, lstat, mkdir, mkdtemp, open, readFile, realpath, rm, unlink } from "node:fs/promises";
7
7
  import { isAbsolute, join, resolve } from "node:path";
8
+ import { isDeepStrictEqual } from "node:util";
8
9
  import { createHash, randomBytes, randomUUID } from "node:crypto";
9
10
  import { tmpdir } from "node:os";
10
11
  import { AsyncLocalStorage } from "node:async_hooks";
11
12
  import { DatabaseSync } from "node:sqlite";
12
13
  import { getHeapStatistics, setFlagsFromString } from "node:v8";
13
- //#region packages/application/src/journey/placement/evidence.ts
14
- /** The denominator includes unresolved observations; missing evidence cannot increase confidence. */
15
- function dominant(value, signal) {
16
- if (!Number.isSafeInteger(value.total) || value.total < 0) throw new ApplicationError("INVALID_ARGUMENTS");
17
- const ids = /* @__PURE__ */ new Set();
18
- let accounted = 0;
19
- for (const item of value.repositories) {
20
- if (!item.id || ids.has(item.id) || !Number.isSafeInteger(item.count) || item.count <= 0) throw new ApplicationError("INVALID_ARGUMENTS");
21
- ids.add(item.id);
22
- accounted += item.count;
23
- }
24
- if (accounted > value.total) throw new ApplicationError("INVALID_ARGUMENTS");
25
- if (!value.complete) return null;
26
- const sorted = value.repositories.toSorted((a, b) => b.count - a.count || a.id.localeCompare(b.id));
27
- const first = sorted[0], second = sorted[1];
28
- if (!first || !value.total || first.count === second?.count) return null;
29
- const share = first.count / value.total;
30
- if (share < .3) return null;
31
- return {
32
- repositoryId: first.id,
33
- signal,
34
- confidence: share >= .6 ? "high" : "medium",
35
- matched: first.count,
36
- total: value.total,
37
- otherRepositoryIds: sorted.slice(1).map((item) => item.id)
38
- };
39
- }
40
- /** Ray section 3: stop at the first deciding signal, then leave semantic fallback to the agent. */
41
- function chooseCheapPlacement(signals) {
42
- const paths = dominant(signals.paths, "paths");
43
- if (paths) return paths;
44
- const commands = dominant(signals.commands, "cwd");
45
- if (commands) return commands;
46
- for (const signal of ["git", "name"]) {
47
- const candidates = [...new Set(signal === "git" ? signals.git : signals.names)];
48
- if (candidates.length !== 1) continue;
49
- const repositoryId = candidates[0];
50
- if (!repositoryId) throw new ApplicationError("INVALID_ARGUMENTS");
51
- return {
52
- repositoryId,
53
- signal: signal === "git" ? "git" : "name",
54
- confidence: "high",
55
- matched: 1,
56
- total: 1,
57
- otherRepositoryIds: []
58
- };
59
- }
60
- return null;
61
- }
62
- //#endregion
63
14
  //#region packages/local-host/src/store/error.ts
64
15
  const storeErrorCodes = [
65
16
  "STALE_GENERATION",
@@ -3673,9 +3624,12 @@ function readJourneyResources(db, input) {
3673
3624
  const state = readJourney(db, input.journeyId);
3674
3625
  if (!state?.consent) throw new ApplicationError("CONFIRMATION_REQUIRED");
3675
3626
  if (input.kind === "protected-base" || isPrivateResourceKind(input.kind)) throw new ApplicationError("INVALID_ARGUMENTS");
3627
+ const column = input.kind === "plan" ? "id" : "json";
3676
3628
  const ids = "ids" in input ? input.ids : void 0;
3677
3629
  const idPrefix = "idPrefix" in input ? input.idPrefix : void 0;
3678
- return (input.id !== void 0 ? db.prepare("SELECT json FROM journey_resources WHERE journey_id=? AND kind=? AND id=?").all(input.journeyId, input.kind, input.id) : ids !== void 0 ? db.prepare("SELECT json FROM journey_resources WHERE journey_id=? AND kind=? AND id IN (SELECT value FROM json_each(?)) ORDER BY id").all(input.journeyId, input.kind, JSON.stringify(ids)) : idPrefix !== void 0 ? db.prepare("SELECT json FROM journey_resources WHERE journey_id=?1 AND kind=?2 AND substr(id,1,length(?3))=?3 ORDER BY id").all(input.journeyId, input.kind, idPrefix) : db.prepare("SELECT json FROM journey_resources WHERE journey_id=? AND kind=? ORDER BY id").all(input.journeyId, input.kind)).map((row) => {
3630
+ const rows = input.id !== void 0 ? db.prepare(`SELECT ${column} FROM journey_resources WHERE journey_id=? AND kind=? AND id=?`).all(input.journeyId, input.kind, input.id) : ids !== void 0 ? db.prepare(`SELECT ${column} FROM journey_resources WHERE journey_id=? AND kind=? AND id IN (SELECT value FROM json_each(?)) ORDER BY id`).all(input.journeyId, input.kind, JSON.stringify(ids)) : idPrefix !== void 0 ? db.prepare(`SELECT ${column} FROM journey_resources WHERE journey_id=?1 AND kind=?2 AND substr(id,1,length(?3))=?3 ORDER BY id`).all(input.journeyId, input.kind, idPrefix) : db.prepare(`SELECT ${column} FROM journey_resources WHERE journey_id=? AND kind=? ORDER BY id`).all(input.journeyId, input.kind);
3631
+ if (input.kind === "plan") return rows.length ? [readInventoryPlan(db, state)] : [];
3632
+ return rows.map((row) => {
3679
3633
  if (typeof row["json"] !== "string") throw new ApplicationError("CORRUPTED_STATE");
3680
3634
  return journeyResourceSchema.parse(JSON.parse(row["json"]));
3681
3635
  }).filter((resource) => resource.kind !== "base" || state.works.some((work) => work.id === resource.workId && work.inputRevision === resource.inputRevision));
@@ -6766,6 +6720,15 @@ function decodePage(value) {
6766
6720
  nextCursor: page.nextCursor
6767
6721
  };
6768
6722
  }
6723
+ let decodedPlan;
6724
+ function decodeResources(value) {
6725
+ return z.array(z.unknown()).parse(value).map((resource) => {
6726
+ if (decodedPlan && isDeepStrictEqual(resource, decodedPlan)) return structuredClone(decodedPlan);
6727
+ const parsed = journeyResourceSchema.parse(resource);
6728
+ if (parsed.kind === "plan") decodedPlan = structuredClone(parsed);
6729
+ return parsed;
6730
+ });
6731
+ }
6769
6732
  const operations = {
6770
6733
  "journey.review.select-reuse": define(false, reuseQuerySchema, selectReviewReuse, (value) => reuseSelectionSchema.parse(value)),
6771
6734
  "journey.review.finish-reuse": define(true, finishReuseSchema, finishReviewReuse, nothing),
@@ -6806,7 +6769,7 @@ const operations = {
6806
6769
  "journey.review.inspect.select": define(false, inspectionQuerySchema, selectJourneyInspection, (value) => inspectionSelectionSchema.parse(value)),
6807
6770
  "journey.review.inspect.overlay": define(false, overlayPageQuerySchema, selectOverlayPage, (value) => overlayPageSchema.parse(value)),
6808
6771
  "journey.review.inspect.finish": define(false, finishInspectionSchema, finishJourneyInspection, nothing),
6809
- "journey.resources": define(false, journeyResourceQuerySchema, readJourneyResources, (value) => z.array(journeyResourceSchema).parse(value)),
6772
+ "journey.resources": define(false, journeyResourceQuerySchema, readJourneyResources, decodeResources),
6810
6773
  "journey.inventory": define(false, journeyInventoryReadSchema, readJourneyInventory, (value) => journeyInventorySchema.parse(value)),
6811
6774
  "journey.preparation.progress": define(false, journeyInventoryReadSchema, readJourneyPreparationProgress, (value) => journeyPreparationProgressSchema.nullable().parse(value)),
6812
6775
  "journey.preparation.begin": define(true, preparationBeginSchema, beginJourneyPreparation, (value) => preparationStartSchema.parse(value)),
@@ -1,7 +1,7 @@
1
- import { X as createInspectionProcessor } from "./src-JoT3L94j.mjs";
2
- import { Dn as createStaticProcessor } from "./locate-JYtFmKu-.mjs";
3
- import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-CGFwLUd6.mjs";
4
- import { H as validateInspectionRequest } from "./src--Ln5GHdz.mjs";
1
+ import { X as createInspectionProcessor } from "./src-BRwicVza.mjs";
2
+ import { Dn as createStaticProcessor } from "./locate-CNU4z9G1.mjs";
3
+ import { l as createNativeAdapters, u as createGitNameSeedProvider } from "./src-BgoSvnXe.mjs";
4
+ import { U as validateInspectionRequest } from "./src-DmSIVU7-.mjs";
5
5
  import "./messages-D3m3bhva.mjs";
6
6
  import { z } from "zod";
7
7
  import { parentPort, workerData } from "node:worker_threads";