@indigoai-us/hq-cli 5.145.0 → 5.146.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.
@@ -10,6 +10,7 @@ import { WORK_CONTEXT_CONTRACT_VERSION, normalizeTaskId, } from "./contract.js";
10
10
  import { EXIT_INVALID_IDENTITY, EXIT_NOT_TRACKING, EXIT_OK, InvalidDecisionOriginError, NotTrackingError, } from "./errors.js";
11
11
  import { decisionFromCandidates, } from "./organize.js";
12
12
  import { refineProjectBinding } from "./bind-best.js";
13
+ import { rebindNeedsProjectOnPrompt } from "./prompt-rebind.js";
13
14
  import { resolveProjectTask, shouldAskAfter } from "./project.js";
14
15
  import { deriveRemoteOwnerSlug, deriveRepoIdentityKey } from "./repo-remote.js";
15
16
  import { enqueueOutbox, listOutboxOperations, markOutboxAcked, markOutboxQuarantined, markOutboxQueued, replayOutbox, writeAckedRegisterState, } from "./outbox.js";
@@ -509,6 +510,35 @@ export async function reconcileObservation(obs, deps) {
509
510
  diagnostics.push(`project ask: ${refined.reason}`);
510
511
  }
511
512
  }
513
+ const promptSubmit = obs.hookEvent === "UserPromptSubmit" || obs.hookEvent === "user_prompt_submit";
514
+ if (promptSubmit && prior?.contextStatus === "needs_project" && !projectId && prior.companyUid) {
515
+ try {
516
+ const rebound = rebindNeedsProjectOnPrompt({
517
+ sessionId,
518
+ root: deps.root,
519
+ hqRoot,
520
+ cwd,
521
+ companySlug: resolvedCompany.slug ?? prior.companySlug,
522
+ companyUid: resolvedCompany.uid ?? prior.companyUid,
523
+ env,
524
+ nowMs: nowFn().getTime(),
525
+ now: nowFn,
526
+ });
527
+ if (rebound.action === "bound" && rebound.projectId) {
528
+ projectId = rebound.projectId;
529
+ projectBindReason = rebound.reason;
530
+ projectCandidates = undefined;
531
+ projectGate = undefined;
532
+ diagnostics.push(`prompt rebind: ${rebound.reason}`);
533
+ }
534
+ }
535
+ catch (err) {
536
+ diagnostics.push(`prompt rebind failed: ${err instanceof Error ? err.message : String(err)}`);
537
+ }
538
+ }
539
+ const projectHint = !projectId
540
+ ? (prior?.projectHint || projectResolved?.projectId)
541
+ : undefined;
512
542
  const bindResultFields = {
513
543
  ...(projectBindReason ? { projectBindReason } : {}),
514
544
  ...(projectCandidates ? { projectCandidates } : {}),
@@ -516,6 +546,7 @@ export async function reconcileObservation(obs, deps) {
516
546
  const bindStateFields = {
517
547
  ...bindResultFields,
518
548
  ...(projectGate ? { projectGate } : {}),
549
+ ...(projectHint ? { projectHint } : {}),
519
550
  };
520
551
  // Trusted / deterministic auto-bind never asks.
521
552
  // Transcript-sourced sessions never ask (US-018).
@@ -104,6 +104,8 @@ export interface SessionStateFile {
104
104
  * `choose` — the match was unclear. `missing_board` — the server 404'd the project.
105
105
  */
106
106
  projectGate?: "choose" | "missing_board";
107
+ /** Slug the session was trying to bind. Re-checked on the next prompt. */
108
+ projectHint?: string;
107
109
  updatedAt: string;
108
110
  }
109
111
  /**
@@ -32,6 +32,7 @@ export const SESSION_STATE_ALLOWLIST = new Set([
32
32
  "projectBindReason",
33
33
  "projectCandidates",
34
34
  "projectGate",
35
+ "projectHint",
35
36
  "updatedAt",
36
37
  ]);
37
38
  const SESSION_STATE_LOCK_TIMEOUT_MS = 5_000;
@@ -237,6 +238,8 @@ export function projectSessionState(state) {
237
238
  out.projectCandidates = state.projectCandidates;
238
239
  if (state.projectGate)
239
240
  out.projectGate = state.projectGate;
241
+ if (state.projectHint && !state.projectId)
242
+ out.projectHint = state.projectHint;
240
243
  return out;
241
244
  }
242
245
  /**
@@ -295,6 +298,11 @@ export function mergeLocalSessionFields(next, prior, options = {}) {
295
298
  if (!out.companyConfidence && prior.companyConfidence && sameCompanyBinding) {
296
299
  out.companyConfidence = prior.companyConfidence;
297
300
  }
301
+ if (!out.projectId && !out.projectHint && prior.projectHint) {
302
+ out.projectHint = prior.projectHint;
303
+ }
304
+ if (out.projectId)
305
+ out.projectHint = undefined;
298
306
  const sameBinding = prior.companyUid === out.companyUid &&
299
307
  prior.companySlug === out.companySlug &&
300
308
  prior.projectId === out.projectId &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.145.0",
3
+ "version": "5.146.0",
4
4
  "description": "HQ by Indigo management CLI \u2014 modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {