@indigoai-us/hq-cli 5.345.255 → 5.345.258
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 +72 -0
- package/README.md +21 -0
- package/assets/scaffold/core/scripts/handoff-finalize.sh +981 -46
- package/assets/scaffold/core/scripts/hq-delegate-bundle.sh +51 -2
- package/assets/scaffold/core/scripts/hq-delegate-send.sh +49 -6
- package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +20 -0
- package/assets/scaffold/core/scripts/hq-delegate-verify.sh +56 -10
- package/assets/scaffold/core/scripts/lib/fingerprint.sh +423 -0
- package/assets/scaffold/core/scripts/rebuild-companies-index.sh +10 -1
- package/assets/scaffold/core/scripts/rebuild-company-knowledge-index.sh +10 -1
- package/assets/scaffold/core/scripts/rebuild-projects-index.sh +10 -1
- package/assets/scaffold/core/scripts/register-project.sh +110 -19
- package/contracts/host-canary-release.json +7 -7
- package/dist/command-catalog.generated.d.ts +1 -1
- package/dist/command-catalog.generated.js +1 -1
- package/dist/commands/cloud.js +4 -1
- package/dist/commands/core-delegate-w1b.js +107 -16
- package/dist/commands/core-delegate.d.ts +7 -0
- package/dist/commands/core-delegate.js +66 -2
- package/dist/commands/core-handoff-fast.d.ts +1 -1
- package/dist/commands/core-handoff-fast.js +2 -2
- package/dist/commands/core-handoff.d.ts +3 -1
- package/dist/commands/core-handoff.js +1407 -177
- package/dist/commands/core-register-project-native.js +1 -1
- package/dist/commands/core.js +2 -2
- package/dist/commands/files.d.ts +2 -0
- package/dist/commands/files.js +34 -5
- package/dist/commands/keyed-sync-pull.d.ts +7 -3
- package/dist/commands/keyed-sync-pull.js +90 -22
- package/dist/commands/team-sync.js +1 -1
- package/dist/lib/company-skill-wrapper.js +72 -4
- package/dist/lib/daemon/requests.d.ts +14 -1
- package/dist/lib/daemon/requests.js +17 -3
- package/dist/lib/daemon/run.js +44 -2
- package/dist/lib/daemon/supervisor.d.ts +11 -0
- package/dist/lib/daemon/supervisor.js +33 -0
- package/dist/lib/daemon/sync-perf-telemetry.d.ts +85 -0
- package/dist/lib/daemon/sync-perf-telemetry.js +206 -0
- package/dist/lib/daemon/windows-relaunch.d.ts +55 -0
- package/dist/lib/daemon/windows-relaunch.js +72 -0
- package/dist/lib/doctor/checks/replay-recorder.js +3 -3
- package/dist/lib/flag-snapshot-file.d.ts +47 -1
- package/dist/lib/flag-snapshot-file.js +143 -20
- package/dist/lib/hook-engine/coverage.d.ts +82 -8
- package/dist/lib/hook-engine/coverage.js +192 -14
- package/dist/lib/index-render/companies.js +3 -2
- package/dist/lib/index-render/index.js +2 -1
- package/dist/lib/index-render/session-scope.d.ts +2 -3
- package/dist/lib/index-render/session-scope.js +2 -5
- package/dist/lib/index-render/shared.d.ts +7 -0
- package/dist/lib/index-render/shared.js +9 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +2 -2
- package/dist/lib/work-context/windows-acl.d.ts +14 -0
- package/dist/lib/work-context/windows-acl.js +26 -0
- package/dist/utils/cli-telemetry.d.ts +26 -7
- package/dist/utils/cli-telemetry.js +70 -13
- package/dist/utils/git.js +1 -1
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/sync-perf-telemetry-flag.d.ts +26 -0
- package/dist/utils/sync-perf-telemetry-flag.js +32 -0
- package/dist/utils/telemetry-opt-out.d.ts +13 -0
- package/dist/utils/telemetry-opt-out.js +19 -0
- package/package.json +8 -8
|
@@ -52,6 +52,16 @@ die() {
|
|
|
52
52
|
|
|
53
53
|
command -v jq >/dev/null 2>&1 || die "jq is required but not installed"
|
|
54
54
|
|
|
55
|
+
# jq.exe under Git Bash writes CRLF. $(...) there drops the CR of the last line
|
|
56
|
+
# only, so every earlier line of a multi-line jq result keeps a trailing CR.
|
|
57
|
+
# The read loops over such a result drop it; other shells are left alone.
|
|
58
|
+
# JQ_LINE_CR is that CR under Git Bash and empty elsewhere. It is set once
|
|
59
|
+
# here because a $'\r' written inside "$(...)" was not removed by Git Bash.
|
|
60
|
+
JQ_LINE_CR=""
|
|
61
|
+
case "${OSTYPE:-}:${MSYSTEM:-}" in
|
|
62
|
+
msys*:*|*:MINGW*|*:UCRT*|*:CLANG*|*:MSYS) JQ_LINE_CR=$'\r' ;;
|
|
63
|
+
esac
|
|
64
|
+
|
|
55
65
|
# --- argument parsing --------------------------------------------------------
|
|
56
66
|
|
|
57
67
|
[ "${1:-}" = "build" ] || { usage >&2; exit 1; }
|
|
@@ -93,7 +103,10 @@ esac
|
|
|
93
103
|
# --- identity ----------------------------------------------------------------
|
|
94
104
|
|
|
95
105
|
CREATED_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
96
|
-
|
|
106
|
+
# A short random token keeps two bundles built in the same second apart.
|
|
107
|
+
DELEGATION_SUFFIX="$(LC_ALL=C od -An -N3 -tx1 /dev/urandom 2>/dev/null | tr -d ' \n')"
|
|
108
|
+
[ -n "$DELEGATION_SUFFIX" ] || DELEGATION_SUFFIX="$(printf '%06x' "$(( ($$ * 7919 + RANDOM) % 16777216 ))")"
|
|
109
|
+
DELEGATION_ID="dlg-$(date -u +%Y%m%d-%H%M%S)-$DELEGATION_SUFFIX-$PROJECT"
|
|
97
110
|
WHOAMI_JSON="$(hq whoami --json)" || die "could not read sender identity; update hq-cli if --json is unsupported"
|
|
98
111
|
printf '%s' "$WHOAMI_JSON" | jq -e '.authenticated != false and ((.email // .personUid // .agentUid // "") | length > 0)' >/dev/null \
|
|
99
112
|
|| die "sender identity is missing or expired; run hq login"
|
|
@@ -128,6 +141,23 @@ else
|
|
|
128
141
|
KNOWLEDGE_JSON="[]"
|
|
129
142
|
fi
|
|
130
143
|
|
|
144
|
+
# Pre-bundle check: warn (never fail) on company knowledge entries that are
|
|
145
|
+
# missing locally or are offloaded placeholders, since hq-delegate-verify
|
|
146
|
+
# fails the probe on them after grants are already applied.
|
|
147
|
+
while IFS= read -r kpath; do
|
|
148
|
+
kpath="${kpath%"$JQ_LINE_CR"}"
|
|
149
|
+
[ -n "$kpath" ] || continue
|
|
150
|
+
case "$kpath" in */) continue ;; esac
|
|
151
|
+
kfile="$HQ_ROOT/$kpath"
|
|
152
|
+
if [ ! -e "$kfile" ]; then
|
|
153
|
+
echo "hq-delegate-bundle: WARNING knowledge entry not found locally, so it was probably never uploaded: $kpath (hq sync push it or drop it from metadata.knowledge)" >&2
|
|
154
|
+
elif [ -f "$kfile" ] && [ "$(head -c 16 "$kfile" 2>/dev/null | LC_ALL=C tr -d '\000')" = "HQ-CLOUD-FILE v1" ]; then
|
|
155
|
+
echo "hq-delegate-bundle: WARNING knowledge entry is an offloaded placeholder, not file content: $kpath (restore it before delegating)" >&2
|
|
156
|
+
fi
|
|
157
|
+
done <<KEOF
|
|
158
|
+
$(printf '%s' "$KNOWLEDGE_JSON" | jq -r --arg co "$COMPANY" '.[] | select(startswith("companies/" + $co + "/"))')
|
|
159
|
+
KEOF
|
|
160
|
+
|
|
131
161
|
VAULT_READ_PREFIXES="$(printf '%s' "$KNOWLEDGE_JSON" | jq -r --arg co "$COMPANY" '
|
|
132
162
|
[ .[]
|
|
133
163
|
| select(startswith("companies/" + $co + "/"))
|
|
@@ -148,6 +178,7 @@ VAULT_PREFIXES_JSON="$(
|
|
|
148
178
|
'{prefix: $p, permission: "write", reason: "project dossier"}'
|
|
149
179
|
if [ -n "$VAULT_READ_PREFIXES" ]; then
|
|
150
180
|
printf '%s\n' "$VAULT_READ_PREFIXES" | while IFS= read -r pfx; do
|
|
181
|
+
pfx="${pfx%"$JQ_LINE_CR"}"
|
|
151
182
|
[ -n "$pfx" ] || continue
|
|
152
183
|
jq -cn --arg p "$pfx" \
|
|
153
184
|
'{prefix: $p, permission: "read", reason: "referenced knowledge/policies"}'
|
|
@@ -207,9 +238,27 @@ fi
|
|
|
207
238
|
|
|
208
239
|
# --- checksums of the project dossier ----------------------------------------
|
|
209
240
|
|
|
241
|
+
# Dependency, VCS, and build-cache folders are not part of the dossier: they are
|
|
242
|
+
# reinstallable, can hold thousands of files, and are never what a recipient
|
|
243
|
+
# picks up. The list is capped at CHECKSUM_CAP entries. The cap is applied with
|
|
244
|
+
# awk, which reads all of its input: `head` exits early, and under pipefail the
|
|
245
|
+
# SIGPIPE it hands to `sort` killed this script silently (exit 141) on big
|
|
246
|
+
# project folders.
|
|
247
|
+
CHECKSUM_CAP=200
|
|
248
|
+
CHECKSUM_LIST="$(
|
|
249
|
+
cd "$HQ_ROOT" || exit 1
|
|
250
|
+
find "companies/$COMPANY/projects/$PROJECT" \
|
|
251
|
+
\( -name node_modules -o -name .git -o -name .venv -o -name venv \
|
|
252
|
+
-o -name __pycache__ -o -name .next -o -name .turbo -o -name .cache \) -prune \
|
|
253
|
+
-o -type f ! -name '.DS_Store' -print | LC_ALL=C sort
|
|
254
|
+
)"
|
|
255
|
+
CHECKSUM_TOTAL="$(printf '%s' "$CHECKSUM_LIST" | awk 'END { print NR }')"
|
|
256
|
+
if [ "$CHECKSUM_TOTAL" -gt "$CHECKSUM_CAP" ]; then
|
|
257
|
+
echo "hq-delegate-bundle: project has $CHECKSUM_TOTAL files; checksummed the first $CHECKSUM_CAP" >&2
|
|
258
|
+
fi
|
|
210
259
|
CHECKSUMS_JSON="$(
|
|
211
260
|
cd "$HQ_ROOT" || exit 1
|
|
212
|
-
|
|
261
|
+
printf '%s\n' "$CHECKSUM_LIST" | awk -v cap="$CHECKSUM_CAP" 'NF && NR <= cap' | \
|
|
213
262
|
while IFS= read -r f; do
|
|
214
263
|
jq -cn --arg p "$f" --arg h "$(file_sha256 "$f")" '{key: $p, value: $h}'
|
|
215
264
|
done | jq -s 'from_entries'
|
|
@@ -9,12 +9,19 @@
|
|
|
9
9
|
# Usage:
|
|
10
10
|
# core/scripts/hq-delegate-send.sh --manifest <path> [--send]
|
|
11
11
|
# [--headline <text>] [--note <text>]
|
|
12
|
+
# core/scripts/hq-delegate-send.sh --manifest <path> --reconcile <eventId>
|
|
13
|
+
#
|
|
14
|
+
# --reconcile records an already-delivered handoff DM (sent outside this
|
|
15
|
+
# helper) by eventId: status granted|verified|sending -> sent, so
|
|
16
|
+
# hq-delegate-pickup.sh can --check it. Sends nothing.
|
|
12
17
|
#
|
|
13
18
|
# Without --send: (re)generates PICKUP-PROMPT.md next to the manifest and
|
|
14
19
|
# prints its path — inspectable, idempotent, sends nothing.
|
|
15
20
|
# With --send: requires manifest status "verified" (the US-008 probe must
|
|
16
21
|
# have passed), then delivers ONE `hq dm` with --prompt-file/--details-file
|
|
17
|
-
# and advances status to "sent", recording the DM eventId.
|
|
22
|
+
# and advances status to "sent", recording the DM eventId. An explicit hq dm
|
|
23
|
+
# refusal returns status to "verified" (nothing was delivered); other
|
|
24
|
+
# failures leave it "sending" for --reconcile.
|
|
18
25
|
#
|
|
19
26
|
# The caller (the /delegate skill) humanizes --headline / --note per
|
|
20
27
|
# core/knowledge/public/hq-core/humanize-before-send.md (channel dm, light)
|
|
@@ -37,7 +44,7 @@ HQ_ROOT="${HQ_ROOT:-$(cd "$SCRIPT_DIR/../.." && pwd)}"
|
|
|
37
44
|
# shellcheck source=lib/delegate-brainstorm.sh
|
|
38
45
|
. "$SCRIPT_DIR/lib/delegate-brainstorm.sh"
|
|
39
46
|
|
|
40
|
-
usage() { sed -n '3,
|
|
47
|
+
usage() { sed -n '3,35p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
|
|
41
48
|
die() { echo "hq-delegate-send: $*" >&2; exit 1; }
|
|
42
49
|
|
|
43
50
|
command -v jq >/dev/null 2>&1 || die "jq is required but not installed"
|
|
@@ -70,13 +77,14 @@ case "${OSTYPE:-}:${MSYSTEM:-}" in
|
|
|
70
77
|
;;
|
|
71
78
|
esac
|
|
72
79
|
|
|
73
|
-
MANIFEST="" SEND=0 HEADLINE="" NOTE=""
|
|
80
|
+
MANIFEST="" SEND=0 HEADLINE="" NOTE="" RECONCILE=""
|
|
74
81
|
while [ $# -gt 0 ]; do
|
|
75
82
|
case "$1" in
|
|
76
83
|
--manifest) MANIFEST="${2:-}"; shift 2 ;;
|
|
77
84
|
--send) SEND=1; shift ;;
|
|
78
85
|
--headline) HEADLINE="${2:-}"; shift 2 ;;
|
|
79
86
|
--note) NOTE="${2:-}"; shift 2 ;;
|
|
87
|
+
--reconcile) RECONCILE="${2:-}"; shift 2 ;;
|
|
80
88
|
-h|--help) usage; exit 0 ;;
|
|
81
89
|
*) die "unknown argument: $1" ;;
|
|
82
90
|
esac
|
|
@@ -85,6 +93,23 @@ done
|
|
|
85
93
|
[ -n "$MANIFEST" ] || die "--manifest is required"
|
|
86
94
|
[ -f "$MANIFEST" ] || die "manifest not found: $MANIFEST"
|
|
87
95
|
jq -e . "$MANIFEST" >/dev/null 2>&1 || die "manifest is not valid JSON: $MANIFEST"
|
|
96
|
+
if [ -n "$RECONCILE" ]; then
|
|
97
|
+
[[ "$RECONCILE" =~ ^[A-Za-z0-9_-]+$ ]] || die "--reconcile needs a DM eventId (letters, digits, _ and -)"
|
|
98
|
+
CUR="$(jq -r '.status // empty' "$MANIFEST")"
|
|
99
|
+
case "$CUR" in
|
|
100
|
+
granted|verified|sending) ;;
|
|
101
|
+
sent|picked-up) die "manifest status is '$CUR' - already recorded as sent" ;;
|
|
102
|
+
*) die "manifest status is '$CUR' - only granted, verified, or sending can be reconciled" ;;
|
|
103
|
+
esac
|
|
104
|
+
NOW="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
105
|
+
TMP_MANIFEST="$(mktemp "${MANIFEST}.tmp.XXXXXX")"
|
|
106
|
+
if ! jq --arg now "$NOW" --arg ev "$RECONCILE" '.status = "sent" | .sentAt = $now | .dmEventId = $ev | .sentVia = "reconcile"' \
|
|
107
|
+
"$MANIFEST" > "$TMP_MANIFEST" || ! mv "$TMP_MANIFEST" "$MANIFEST"; then
|
|
108
|
+
rm -f "$TMP_MANIFEST"; die "could not save reconciled send receipt"
|
|
109
|
+
fi
|
|
110
|
+
echo "hq-delegate-send: recorded existing DM (eventId $RECONCILE) - status advanced to 'sent'"
|
|
111
|
+
exit 0
|
|
112
|
+
fi
|
|
88
113
|
LOCK="$MANIFEST.send-lock"
|
|
89
114
|
if [ "$SEND" -eq 1 ]; then
|
|
90
115
|
mkdir "$LOCK" 2>/dev/null || die "verification or delivery is active; retry after it finishes"
|
|
@@ -278,13 +303,31 @@ NORMALIZED="$(jq -cS '.status="granted" | .recipientAccess="unconfirmed" | del(.
|
|
|
278
303
|
|
|
279
304
|
[ -n "$HEADLINE" ] || HEADLINE="Project handoff: $PROJECT — open the brief, pull the files, and acknowledge receipt"
|
|
280
305
|
|
|
306
|
+
DM_ERR="$(mktemp)" || die "could not create a temp file for hq dm output; no DM attempted"
|
|
281
307
|
TMP_MANIFEST="$(mktemp "${MANIFEST}.tmp.XXXXXX")"
|
|
282
308
|
if ! jq '.status = "sending"' "$MANIFEST" > "$TMP_MANIFEST" || ! mv "$TMP_MANIFEST" "$MANIFEST"; then
|
|
283
|
-
rm -f "$TMP_MANIFEST"
|
|
309
|
+
rm -f "$TMP_MANIFEST" "$DM_ERR"
|
|
284
310
|
die "could not persist sending state; no DM attempted"
|
|
285
311
|
fi
|
|
286
|
-
DM_OUT="$(hq dm "$PRINCIPAL" "$HEADLINE" --audience human --prompt-file "$PROMPT" --details-file "$BRIEF")"
|
|
287
|
-
|
|
312
|
+
if ! DM_OUT="$(hq dm "$PRINCIPAL" "$HEADLINE" --audience human --prompt-file "$PROMPT" --details-file "$BRIEF" 2>"$DM_ERR")"; then
|
|
313
|
+
cat "$DM_ERR" >&2
|
|
314
|
+
# An explicit sender-rule refusal is rejected before delivery: nothing was
|
|
315
|
+
# sent, so return to "verified" and let a retry go through. Any other
|
|
316
|
+
# failure may have delivered, so it stays "sending" for reconciliation.
|
|
317
|
+
if grep -Eq 'People can only send human messages|is for agents and bots only' "$DM_ERR"; then
|
|
318
|
+
rm -f "$DM_ERR"
|
|
319
|
+
TMP_MANIFEST="$(mktemp "${MANIFEST}.tmp.XXXXXX")"
|
|
320
|
+
if ! jq '.status = "verified"' "$MANIFEST" > "$TMP_MANIFEST" || ! mv "$TMP_MANIFEST" "$MANIFEST"; then
|
|
321
|
+
rm -f "$TMP_MANIFEST"
|
|
322
|
+
die "hq dm refused the pickup DM (nothing sent) but status could not be restored; it reads sending"
|
|
323
|
+
fi
|
|
324
|
+
die "hq dm refused the pickup DM; nothing was sent and status is back to verified, so a retry is safe"
|
|
325
|
+
fi
|
|
326
|
+
rm -f "$DM_ERR"
|
|
327
|
+
die "hq dm delivery outcome is uncertain; status is sending, inspect DM history before retrying"
|
|
328
|
+
fi
|
|
329
|
+
cat "$DM_ERR" >&2
|
|
330
|
+
rm -f "$DM_ERR"
|
|
288
331
|
|
|
289
332
|
EVENT_ID="$(printf '%s' "$DM_OUT" | grep -oE 'eventId[: ]+[A-Za-z0-9_-]+' | head -1 | sed -E 's/eventId[: ]+//' || true)"
|
|
290
333
|
[ -n "$EVENT_ID" ] || die "DM response has no receipt; status is sending, reconcile DM history before retrying"
|
|
@@ -174,6 +174,26 @@ MESH_PROJECT="$PROJECT"
|
|
|
174
174
|
if [ "$STAGE" = prd ]; then
|
|
175
175
|
MESH_PROJECT="$(jq -r --arg p "$PROJECT" '.metadata.workMeshProjectId // .metadata.projectId // $p' "$PRD_ABS" 2>/dev/null || printf '%s' "$PROJECT")"
|
|
176
176
|
fi
|
|
177
|
+
# Without an explicit metadata id, resolve the board of record: the board.json
|
|
178
|
+
# entry's mesh_project_id, then a suffixed cache slug (<project>-<12 hex>) in
|
|
179
|
+
# the company's Work Mesh cache.
|
|
180
|
+
if [ "$MESH_PROJECT" = "$PROJECT" ]; then
|
|
181
|
+
BOARD_MESH="$(jq -r --arg p "$PROJECT" --arg path "${PRD_PATH:-}" '[.projects[]? | select(.id == $p or .mesh_project_id == $p or (($path != "") and (.prd_path == $path)))] | first | (.mesh_project_id // empty)' "$BOARD" 2>/dev/null | tr -d '\r' || true)"
|
|
182
|
+
if [ -n "$BOARD_MESH" ]; then
|
|
183
|
+
MESH_PROJECT="$BOARD_MESH"
|
|
184
|
+
else
|
|
185
|
+
CO_UID="$(if [ -f "$HQ_ROOT/companies/$COMPANY/.company-uid" ]; then tr -d '[:space:]' < "$HQ_ROOT/companies/$COMPANY/.company-uid" 2>/dev/null || true; fi)"
|
|
186
|
+
if [ -n "$CO_UID" ]; then
|
|
187
|
+
for f in "${HQ_WORK_MESH_CACHE_DIR:-$HOME/.hq/work-mesh/cache/projects}/$CO_UID/$PROJECT"-????????????.json; do
|
|
188
|
+
[ -f "$f" ] || continue
|
|
189
|
+
cand="$(basename "$f" .json)"
|
|
190
|
+
case "${cand#"$PROJECT"-}" in *[!0-9a-f]*) continue ;; esac
|
|
191
|
+
MESH_PROJECT="$cand"
|
|
192
|
+
break
|
|
193
|
+
done
|
|
194
|
+
fi
|
|
195
|
+
fi
|
|
196
|
+
fi
|
|
177
197
|
# Silently tolerated when unavailable (local/offline installs no-op).
|
|
178
198
|
|
|
179
199
|
if command -v hq >/dev/null 2>&1; then
|
|
@@ -35,6 +35,16 @@ die() { echo "hq-delegate-verify: $*" >&2; exit 1; }
|
|
|
35
35
|
|
|
36
36
|
command -v jq >/dev/null 2>&1 || die "jq is required but not installed"
|
|
37
37
|
|
|
38
|
+
# jq.exe under Git Bash writes CRLF. $(...) there drops the CR of the last line
|
|
39
|
+
# only, so every earlier line of a multi-line jq result keeps a trailing CR.
|
|
40
|
+
# The referenced-file loop drops it; other shells are left alone.
|
|
41
|
+
# JQ_LINE_CR is that CR under Git Bash and empty elsewhere. It is set once
|
|
42
|
+
# here because a $'\r' written inside "$(...)" was not removed by Git Bash.
|
|
43
|
+
JQ_LINE_CR=""
|
|
44
|
+
case "${OSTYPE:-}:${MSYSTEM:-}" in
|
|
45
|
+
msys*:*|*:MINGW*|*:UCRT*|*:CLANG*|*:MSYS) JQ_LINE_CR=$'\r' ;;
|
|
46
|
+
esac
|
|
47
|
+
|
|
38
48
|
MANIFEST="" DRY_RUN=0 COMPANY="" PROJECT="" TO="" MODE="transfer"
|
|
39
49
|
while [ $# -gt 0 ]; do
|
|
40
50
|
case "$1" in
|
|
@@ -66,10 +76,15 @@ if [ "$DRY_RUN" -eq 1 ]; then
|
|
|
66
76
|
|
|
67
77
|
# Secret names the US-005 step would grant (same .env.schema derivation).
|
|
68
78
|
REPO_REL="$(printf '%s' "$PLAN_JSON" | jq -r '.repo.path // empty')"
|
|
79
|
+
# An absolute repo.path is used as-is, never under the HQ root (feedback_6ea99712).
|
|
80
|
+
case "$REPO_REL" in
|
|
81
|
+
''|/*|[A-Za-z]:[\\/]*) REPO_ABS="$REPO_REL" ;;
|
|
82
|
+
*) REPO_ABS="$HQ_ROOT/$REPO_REL" ;;
|
|
83
|
+
esac
|
|
69
84
|
SCHEMA=""
|
|
70
85
|
for candidate in \
|
|
71
86
|
"$HQ_ROOT/companies/$COMPANY/projects/$PROJECT/.env.schema" \
|
|
72
|
-
"${
|
|
87
|
+
"${REPO_ABS:+$REPO_ABS/.env.schema}"; do
|
|
73
88
|
[ -n "$candidate" ] && [ -f "$candidate" ] && { SCHEMA="$candidate"; break; }
|
|
74
89
|
done
|
|
75
90
|
SECRET_NAMES="(none — no .env.schema found)"
|
|
@@ -168,7 +183,7 @@ REF_BROWSE_CACHE="$(mktemp -d)"
|
|
|
168
183
|
listing_has_exact_key() {
|
|
169
184
|
local listing="$1" expected="$2"
|
|
170
185
|
printf '%s\n' "$listing" | awk -v expected="$expected" '
|
|
171
|
-
function exact_key(row, expected,
|
|
186
|
+
function exact_key(row, expected, n, f, size, modified) {
|
|
172
187
|
gsub(/\033\[[0-9;]*m/, "", row)
|
|
173
188
|
sub(/[[:space:]]+$/, "", row)
|
|
174
189
|
# hq-cli releases word the creator label differently ("creator access —
|
|
@@ -176,16 +191,18 @@ listing_has_exact_key() {
|
|
|
176
191
|
# prefix with either suffix so any verifier/hq-cli version pair agrees.
|
|
177
192
|
if (row !~ / +(shared-with-you|creator access( — creator-only| \([^()]*\))?|role-bypass|personal-vault|private folder — children are creator-only)$/) return 0
|
|
178
193
|
sub(/ +(shared-with-you|creator access( — creator-only| \([^()]*\))?|role-bypass|personal-vault|private folder — children are creator-only)$/, "", row)
|
|
179
|
-
|
|
180
|
-
|
|
194
|
+
# split() last two fields for validation, then slice those two trailing
|
|
195
|
+
# columns off row so consecutive spaces inside keys stay intact.
|
|
196
|
+
n = split(row, f, / +/)
|
|
197
|
+
if (n < 3) return 0
|
|
198
|
+
modified = f[n]
|
|
181
199
|
if (modified != "—" && modified !~ /^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9]Z$/) return 0
|
|
182
|
-
|
|
183
|
-
sub(/[[:space:]]+$/, "", row)
|
|
184
|
-
size = row
|
|
185
|
-
sub(/^.* +/, "", size)
|
|
200
|
+
size = f[n - 1]
|
|
186
201
|
if (size !~ /^[0-9]+$/) return 0
|
|
187
|
-
|
|
188
|
-
sub(/
|
|
202
|
+
row = substr(row, 1, length(row) - length(modified))
|
|
203
|
+
sub(/ +$/, "", row)
|
|
204
|
+
row = substr(row, 1, length(row) - length(size))
|
|
205
|
+
sub(/ +$/, "", row)
|
|
189
206
|
return row == expected
|
|
190
207
|
}
|
|
191
208
|
NR > 2 && exact_key($0, expected) { found = 1 }
|
|
@@ -215,8 +232,26 @@ REF_COUNT="$(jq -r --arg co "$COMPANY" \
|
|
|
215
232
|
if [ "$REF_COUNT" -gt 0 ]; then
|
|
216
233
|
echo "hq-delegate-verify: probing $REF_COUNT referenced knowledge/policy file(s)"
|
|
217
234
|
while IFS= read -r kpath; do
|
|
235
|
+
kpath="${kpath%"$JQ_LINE_CR"}"
|
|
218
236
|
[ -n "$kpath" ] || continue
|
|
219
237
|
REL="${kpath#companies/$COMPANY/}"
|
|
238
|
+
# A trailing slash names a FOLDER reference (feedback_e1bcf891). Probing it
|
|
239
|
+
# as dirname/basename asks the parent listing for a key that can never
|
|
240
|
+
# exist, so every folder reference failed and blocked the DM. A folder is
|
|
241
|
+
# proven present by a non-empty listing of the folder itself.
|
|
242
|
+
case "$REL" in
|
|
243
|
+
*/)
|
|
244
|
+
LISTING="$(browse_parent "$REL")"
|
|
245
|
+
if [ -z "$(printf '%s' "$LISTING" | tr -d '[:space:]')" ] \
|
|
246
|
+
|| [ "$(printf '%s' "$LISTING" | tr -d '[:space:]')" = "Noobjectsunderthatprefix." ]; then
|
|
247
|
+
echo " FAIL $REL — referenced folder is EMPTY or not in the vault (likely cause: its files were never pushed — hq sync push $kpath --company $COMPANY and re-run)"
|
|
248
|
+
FAILED=1
|
|
249
|
+
else
|
|
250
|
+
echo " pass $REL (folder)"
|
|
251
|
+
fi
|
|
252
|
+
continue
|
|
253
|
+
;;
|
|
254
|
+
esac
|
|
220
255
|
PARENT="$(dirname "$REL")/"
|
|
221
256
|
BASE="$(basename "$REL")"
|
|
222
257
|
LISTING="$(browse_parent "$PARENT")"
|
|
@@ -226,6 +261,17 @@ if [ "$REF_COUNT" -gt 0 ]; then
|
|
|
226
261
|
# exactly the referenced files that sort early in a large parent listing).
|
|
227
262
|
if listing_has_exact_key "$LISTING" "$kpath"; then
|
|
228
263
|
echo " pass $REL"
|
|
264
|
+
elif DIR_LISTING="$(browse_parent "$REL/")" \
|
|
265
|
+
&& [[ "$DIR_LISTING" == *"$kpath/"* ]]; then
|
|
266
|
+
# Directory reference without a trailing slash: reachable when any file
|
|
267
|
+
# exists under that prefix.
|
|
268
|
+
echo " pass $REL (folder)"
|
|
269
|
+
elif hq files cat "$REL" --company "$COMPANY" >/dev/null 2>&1; then
|
|
270
|
+
# The listing check reads the human-oriented browse table, and a
|
|
271
|
+
# throttled or differently formatted listing can miss a row. Before
|
|
272
|
+
# reporting a file missing, read it back directly: a file that reads is
|
|
273
|
+
# in the vault, and a false "missing" here blocks the pickup DM.
|
|
274
|
+
echo " pass $REL (read back)"
|
|
229
275
|
else
|
|
230
276
|
echo " FAIL $REL — granted prefix is reachable but this referenced file is NOT in the vault (likely cause: it was never pushed — hq sync push $kpath --company $COMPANY and re-run)"
|
|
231
277
|
FAILED=1
|