@indigoai-us/hq-cli 5.97.3 → 5.98.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/CHANGELOG.md
CHANGED
|
@@ -7,12 +7,24 @@
|
|
|
7
7
|
* I/O itself.
|
|
8
8
|
*/
|
|
9
9
|
import { Command } from "commander";
|
|
10
|
+
type Backend = "claude" | "codex" | "grok" | "none";
|
|
11
|
+
type SpawnableBackend = Exclude<Backend, "none">;
|
|
10
12
|
/**
|
|
11
13
|
* Kept in TypeScript rather than in a bundled asset: it is an instruction to
|
|
12
14
|
* a locally-installed agent, not a scaffold script that should be packaged.
|
|
13
15
|
*/
|
|
14
16
|
export declare const SIBLING_PROMPT_TEMPLATE = "You are the HQ checkpoint sibling \u2014 a background maintenance agent for this\nHQ install. Your parent session's state is in <payloadPath>. Work\nquietly and do not ask questions; if something is ambiguous, record it in the\nreport instead of guessing.\n\n1. Read the payload. If it lists a transcript path that exists, read its tail (~400 lines)\n both for session context and to extract additional reusable learnings/insights\n the parent did not pass explicitly. Never quote secrets\n or tokens from the transcript. If .claude/skills/checkpoint/SKILL.md exists\n under this HQ root, read it and follow it wherever it goes beyond these instructions;\n the write bounds below always win over the skill text.\n2. Upgrade the thread file named in the payload IN PLACE: verify/repair its\n JSON; fill git.remote_url, git.initial_commit, git.commits_made, and\n git.knowledge_repos by scanning core/knowledge/public/*,\n core/knowledge/private/*, personal/knowledge/*, and companies/*/knowledge\n for symlinks or directories containing .git, recording dirty repositories\n as {\"<name>\": {\"commit\": \"<short>\", \"dirty\": true}}. Fill worker,\n next_steps, and insights; set type to \"checkpoint\"; then rename the file to\n drop -auto- from its filename. Use the renamed path in every reference you\n write afterwards.\n3. For every explicit or transcript-derived learning that is a reusable rule,\n FIRST search the existing policies for one the learning refines, contradicts\n or duplicates. Then take exactly one of these actions and name it in the\n report \u2014 the policy set is curated, not append-only:\n - AMEND an existing policy in place when the learning sharpens it, narrows\n its scope, or adds a case, and the rule as written is still correct.\n - SUPERSEDE it when the learning contradicts it: rewrite the rule to what is\n now true and record inside the file what changed and why.\n - MERGE near-duplicates into the single best-named file, then delete the\n files you merged away.\n - CREATE a new policy only when no existing policy covers the rule.\n Follow core/knowledge/public/hq-core/policies-spec.md. Write under\n personal/policies/ or, only when the payload names a company and the rule is\n company-specific, companies/<company>/policies/.\n DELETION BOUNDS: delete a policy only as the MERGE or SUPERSEDE step above,\n only inside those two directories, and never one whose body marks it HARD \u2014\n if a hard policy now looks wrong, leave it untouched and flag it in the\n report for a human to decide. Never delete a file you have not read.\n Apply the same curation to durable facts (not rules) under\n personal/knowledge/ or companies/<company>/knowledge/: correct a stale fact\n in place rather than appending a second, contradictory copy of it.\n Store up to two explicit or transcript-derived insights per\n core/knowledge/public/hq-core/insights-spec.md when present, otherwise\n workspace/insights/.\n4. Close an active session journal fail-soft with\n bash .claude/skills/_shared/journal.sh close \"<project_dir>\" \"<one-line synthesis>\".\n Write a legacy checkpoint JSON under workspace/checkpoints/<id>.json with\n id, created_at, summary, files, and next_steps for backward compatibility.\n5. Update workspace/threads/recent.md and regenerate\n workspace/threads/INDEX.md. For each company whose knowledge path appears\n in files_touched, regenerate companies/<company>/knowledge/INDEX.md under\n core/knowledge/public/hq-core/index-md-spec.md. Mechanical index generation\n is allowed for those companies, but knowledge/policy content writes remain\n restricted to the payload's named company.\n6. Run .claude/skills/document-release/SKILL.md best-effort when it exists;\n skip silently on any failure. Hook or automation improvements go ONLY under\n personal/hooks/ as proposals.\n7. WRITE BOUNDS: you may write only under personal/, workspace/, and companies/<company>/ as constrained above. You must NEVER write into .claude/, core/, .agents/, .codex/, repos/, or anywhere outside the HQ root.\n8. Write <runDir>/report.md \u2014 full prose: what you read, what you changed\n (paths), and what you skipped and why. List every policy or knowledge file\n you amended, superseded, merged or deleted with the reason, so a human can\n audit and reverse it; a deletion you do not name in the report is a defect.\n Then drain the queue: while\n workspace/checkpoints/sibling/pending.jsonl exists and is non-empty, claim\n it atomically by renaming it aside \u2014\n mv workspace/checkpoints/sibling/pending.jsonl <runDir>/pending-claimed-N.jsonl\n (N counting up from 2) \u2014 and process the claimed payloads with this same\n flow. Repeat until a claim finds nothing left, then update the report.\n NEVER read the queue and truncate it in place: a payload appended between\n your read and the truncate is lost, and its checkpoint is never enriched.\n";
|
|
15
17
|
export declare function renderSiblingPrompt(runDir: string, payloadPath: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Preference order for `--backend auto`: the caller's own backend first, so a
|
|
20
|
+
* claude session keeps using claude and a codex session keeps using codex
|
|
21
|
+
* (same-engine continuity), then the fallback priority claude -> codex -> grok
|
|
22
|
+
* for whatever the caller is not. Deterministic and env-only, so it is unit
|
|
23
|
+
* tested directly.
|
|
24
|
+
*/
|
|
25
|
+
export declare function autoBackendPreference(): SpawnableBackend[];
|
|
26
|
+
export declare function siblingArgs(backend: SpawnableBackend, prompt: string): string[];
|
|
16
27
|
/** Attach the native checkpoint command to the hidden `hq core` group. */
|
|
17
28
|
export declare function registerCoreCheckpointCommand(core: Command): void;
|
|
29
|
+
export {};
|
|
18
30
|
//# sourceMappingURL=core-checkpoint.d.ts.map
|
|
@@ -26,8 +26,12 @@ const GROK_SIBLING_EFFORT = "high";
|
|
|
26
26
|
* plan and exits, having done nothing. The maintenance flow needs many turns.
|
|
27
27
|
*/
|
|
28
28
|
const GROK_SIBLING_MAX_TURNS = "100";
|
|
29
|
-
/**
|
|
30
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Fallback priority for `--backend auto` once the caller's own backend is
|
|
31
|
+
* unavailable, unresponsive, out of credits (surfaces as a crashed run), or
|
|
32
|
+
* simply unknown. First healthy candidate wins.
|
|
33
|
+
*/
|
|
34
|
+
const FALLBACK_BACKEND_ORDER = ["claude", "codex", "grok"];
|
|
31
35
|
/** A backend that cannot answer `--version` this fast is treated as broken. */
|
|
32
36
|
const BACKEND_PROBE_TIMEOUT_MS = 10_000;
|
|
33
37
|
/** A sibling still holding the lock after this long is treated as abandoned. */
|
|
@@ -492,6 +496,32 @@ function crashedBackends(siblingRoot) {
|
|
|
492
496
|
}
|
|
493
497
|
return crashed;
|
|
494
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* The backend of the agent that invoked this checkpoint, when known.
|
|
501
|
+
*
|
|
502
|
+
* Reuses the same runtime signal the Stop gate reads (`HQ_CHECKPOINT_RUNTIME`,
|
|
503
|
+
* set to `codex` by the codex hook adapter and defaulted to `claude` by the
|
|
504
|
+
* claude Stop hook). Grok runs no HQ hooks, so it never auto-invokes a
|
|
505
|
+
* checkpoint and has no reliable caller signal — an `other`/unknown runtime
|
|
506
|
+
* returns null and falls through to the fallback order.
|
|
507
|
+
*/
|
|
508
|
+
function callerBackend() {
|
|
509
|
+
const runtime = checkpointGateRuntime();
|
|
510
|
+
return runtime === "claude" || runtime === "codex" ? runtime : null;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Preference order for `--backend auto`: the caller's own backend first, so a
|
|
514
|
+
* claude session keeps using claude and a codex session keeps using codex
|
|
515
|
+
* (same-engine continuity), then the fallback priority claude -> codex -> grok
|
|
516
|
+
* for whatever the caller is not. Deterministic and env-only, so it is unit
|
|
517
|
+
* tested directly.
|
|
518
|
+
*/
|
|
519
|
+
export function autoBackendPreference() {
|
|
520
|
+
const caller = callerBackend();
|
|
521
|
+
if (!caller)
|
|
522
|
+
return [...FALLBACK_BACKEND_ORDER];
|
|
523
|
+
return [caller, ...FALLBACK_BACKEND_ORDER.filter((name) => name !== caller)];
|
|
524
|
+
}
|
|
495
525
|
function resolveBackend(requested, liveRoot) {
|
|
496
526
|
const value = requested ?? "auto";
|
|
497
527
|
if (!BACKENDS.has(value))
|
|
@@ -499,7 +529,7 @@ function resolveBackend(requested, liveRoot) {
|
|
|
499
529
|
// An explicitly named backend is honoured as given; only `auto` shops around.
|
|
500
530
|
if (value !== "auto")
|
|
501
531
|
return value;
|
|
502
|
-
const available =
|
|
532
|
+
const available = autoBackendPreference().filter((name) => backendOnPath(name) && backendResponds(name));
|
|
503
533
|
if (available.length === 0)
|
|
504
534
|
return "none";
|
|
505
535
|
const crashed = crashedBackends(path.join(liveRoot, "workspace", "checkpoints", "sibling"));
|
|
@@ -507,7 +537,7 @@ function resolveBackend(requested, liveRoot) {
|
|
|
507
537
|
// failure is a weaker signal than running no maintenance sibling at all.
|
|
508
538
|
return available.find((name) => !crashed.has(name)) ?? available[0];
|
|
509
539
|
}
|
|
510
|
-
function siblingArgs(backend, prompt) {
|
|
540
|
+
export function siblingArgs(backend, prompt) {
|
|
511
541
|
switch (backend) {
|
|
512
542
|
case "claude":
|
|
513
543
|
return [
|
|
@@ -517,8 +547,16 @@ function siblingArgs(backend, prompt) {
|
|
|
517
547
|
CLAUDE_SIBLING_MODEL,
|
|
518
548
|
"--effort",
|
|
519
549
|
CLAUDE_SIBLING_EFFORT,
|
|
550
|
+
// `acceptEdits` auto-approves edits only. At the HQ root the scaffold
|
|
551
|
+
// settings make Bash "ask", so a terminal command — the git scan, the
|
|
552
|
+
// journal helper, the queue-draining `mv` — hits an approval gate with
|
|
553
|
+
// no human attached; headless `claude -p` then denies it and the run
|
|
554
|
+
// stalls having written no report. `bypassPermissions` is the same
|
|
555
|
+
// unattended posture codex gets from `-s workspace-write` and grok from
|
|
556
|
+
// `--always-approve --sandbox workspace`. Hooks still fire natively —
|
|
557
|
+
// this only removes the interactive approval gate, not the hook chain.
|
|
520
558
|
"--permission-mode",
|
|
521
|
-
"
|
|
559
|
+
"bypassPermissions",
|
|
522
560
|
];
|
|
523
561
|
case "grok":
|
|
524
562
|
return [
|