@indigoai-us/hq-cli 5.312.1 → 5.312.2-beta.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 +2 -5
- package/dist/command-catalog.generated.d.ts +0 -65
- package/dist/command-catalog.generated.js +0 -80
- package/dist/commands/cloud.js +1 -0
- package/dist/commands/company.js +0 -2
- package/dist/commands/core.js +0 -7
- package/dist/fast-core.js +3 -10
- package/dist/fast-scaffold.d.ts +0 -2
- package/dist/fast-scaffold.js +0 -11
- package/dist/lib/doctor/checks/work-context.js +1 -9
- package/dist/lib/mesh/client.js +5 -23
- package/dist/lib/mesh/live/daemon/doctor.d.ts +0 -2
- package/dist/lib/mesh/live/daemon/doctor.js +1 -11
- package/dist/lib/search-index/embed-lock.d.ts +0 -2
- package/dist/lib/search-index/embed-lock.js +1 -10
- package/dist/lib/work-context/contract.d.ts +0 -3
- package/dist/lib/work-context/contract.schema.json +1 -3
- package/dist/lib/work-context/outbox.d.ts +5 -14
- package/dist/lib/work-context/outbox.js +5 -48
- package/dist/lib/work-context/reconcile.js +5 -26
- package/dist/main.d.ts +0 -20
- package/dist/main.js +1 -8
- package/package.json +1 -1
- package/assets/scaffold/core/scripts/lib/work-mesh-live-hook.sh +0 -378
- package/assets/scaffold/core/scripts/lib/work-mesh-live-rebind.sh +0 -141
- package/assets/scaffold/core/scripts/migrate-policy-triggers.sh +0 -373
- package/assets/scaffold/core/scripts/register-project.sh +0 -262
- package/assets/scaffold/core/scripts/work-mesh-live-rebind.sh +0 -59
- package/dist/commands/company-rename-flag.d.ts +0 -4
- package/dist/commands/company-rename-flag.js +0 -7
- package/dist/commands/company-rename.d.ts +0 -4
- package/dist/commands/company-rename.js +0 -90
- package/dist/commands/core-eval-trigger-native.d.ts +0 -4
- package/dist/commands/core-eval-trigger-native.js +0 -12
- package/dist/commands/core-migrate-policy-triggers-native.d.ts +0 -21
- package/dist/commands/core-migrate-policy-triggers-native.js +0 -378
- package/dist/commands/core-native-hook-helper-commands.d.ts +0 -4
- package/dist/commands/core-native-hook-helper-commands.js +0 -56
- package/dist/commands/core-native-hook-helpers-flag.d.ts +0 -4
- package/dist/commands/core-native-hook-helpers-flag.js +0 -7
- package/dist/commands/core-register-project-native.d.ts +0 -30
- package/dist/commands/core-register-project-native.js +0 -347
- package/dist/commands/core-work-mesh-live-rebind-native.d.ts +0 -18
- package/dist/commands/core-work-mesh-live-rebind-native.js +0 -262
- package/dist/lib/mesh/denial-codes.d.ts +0 -5
- package/dist/lib/mesh/denial-codes.js +0 -14
- package/dist/utils/core-eval-trigger.d.ts +0 -4
- package/dist/utils/core-eval-trigger.js +0 -88
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Register one local PRD on the Work Mesh Board and record threadId/channelId
|
|
3
|
-
# on the company board.json. Audit and backfill never run unless asked.
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
ROOT="${HQ_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
|
|
7
|
-
|
|
8
|
-
die() {
|
|
9
|
-
echo "$*" >&2
|
|
10
|
-
exit 1
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
resolve_uid() {
|
|
14
|
-
local company="$1"
|
|
15
|
-
if [ -n "${HQ_COMPANY_UID:-}" ]; then
|
|
16
|
-
printf '%s\n' "$HQ_COMPANY_UID"
|
|
17
|
-
return
|
|
18
|
-
fi
|
|
19
|
-
local file="$ROOT/companies/$company/.company-uid"
|
|
20
|
-
if [ -f "$file" ]; then
|
|
21
|
-
tr -d '[:space:]' < "$file"
|
|
22
|
-
return
|
|
23
|
-
fi
|
|
24
|
-
die "no company uid for $company (set HQ_COMPANY_UID or companies/$company/.company-uid)"
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
has_board() {
|
|
28
|
-
local company="$1" project="$2" uid
|
|
29
|
-
uid="$(resolve_uid "$company")"
|
|
30
|
-
[ -f "${HOME}/.hq/work-mesh/cache/projects/${uid}/${project}.json" ]
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
story_not_done() {
|
|
34
|
-
jq -e '[.userStories[]? | select((.status // "") != "done")] | length > 0' "$1" >/dev/null
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
recent_dir() {
|
|
38
|
-
local path="$1" mtime now age
|
|
39
|
-
case "$(uname -s)" in
|
|
40
|
-
Darwin) mtime="$(stat -f %m "$path")" ;;
|
|
41
|
-
*) mtime="$(stat -c %Y "$path")" ;;
|
|
42
|
-
esac
|
|
43
|
-
now="$(date +%s)"
|
|
44
|
-
age=$((now - mtime))
|
|
45
|
-
if [ "$age" -lt $((30 * 86400)) ]; then
|
|
46
|
-
printf 'yes\n'
|
|
47
|
-
else
|
|
48
|
-
printf 'no\n'
|
|
49
|
-
fi
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
# hq mesh project ensure shipped in hq-cli 5.139.0. Probe the subcommand,
|
|
53
|
-
# not the version string: a laptop can be one release behind the supply-chain
|
|
54
|
-
# install guard for up to 24h.
|
|
55
|
-
MIN_HQ_CLI="5.139.0"
|
|
56
|
-
|
|
57
|
-
cli_has_project_ensure() {
|
|
58
|
-
hq mesh project ensure --help >/dev/null 2>&1
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
board_path() {
|
|
62
|
-
printf '%s\n' "$ROOT/companies/$1/board.json"
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
mark_pending() {
|
|
66
|
-
local company="$1" project="$2"
|
|
67
|
-
local board prd rel now title tmp
|
|
68
|
-
board="$(board_path "$company")"
|
|
69
|
-
prd="$ROOT/companies/$company/projects/$project/prd.json"
|
|
70
|
-
rel="companies/$company/projects/$project/prd.json"
|
|
71
|
-
now="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
72
|
-
title="$(jq -r '.name // empty' "$prd" 2>/dev/null || true)"
|
|
73
|
-
[ -n "$title" ] || title="$project"
|
|
74
|
-
mkdir -p "$(dirname "$board")"
|
|
75
|
-
if [ ! -f "$board" ]; then
|
|
76
|
-
jq -n --arg company "$company" '{company:$company, projects:[]}' > "$board"
|
|
77
|
-
fi
|
|
78
|
-
tmp="$(mktemp)"
|
|
79
|
-
jq \
|
|
80
|
-
--arg id "$project" \
|
|
81
|
-
--arg path "$rel" \
|
|
82
|
-
--arg now "$now" \
|
|
83
|
-
--arg title "$title" \
|
|
84
|
-
'
|
|
85
|
-
.projects = (.projects // []) |
|
|
86
|
-
if any(.projects[]; .id == $id or .prd_path == $path or .mesh_project_id == $id) then
|
|
87
|
-
.projects |= map(
|
|
88
|
-
if .id == $id or .prd_path == $path or .mesh_project_id == $id then
|
|
89
|
-
. + {pending_registration:true, updated_at:$now, prd_path:(.prd_path // $path)}
|
|
90
|
-
else . end
|
|
91
|
-
)
|
|
92
|
-
else
|
|
93
|
-
.projects += [{
|
|
94
|
-
id:$id,
|
|
95
|
-
title:$title,
|
|
96
|
-
status:"prd_created",
|
|
97
|
-
scope:"company",
|
|
98
|
-
prd_path:$path,
|
|
99
|
-
pending_registration:true,
|
|
100
|
-
created_at:$now,
|
|
101
|
-
updated_at:$now
|
|
102
|
-
}]
|
|
103
|
-
end
|
|
104
|
-
' "$board" > "$tmp"
|
|
105
|
-
mv "$tmp" "$board"
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
register_one() {
|
|
109
|
-
local company="$1" project="$2"
|
|
110
|
-
local prd="$ROOT/companies/$company/projects/$project/prd.json"
|
|
111
|
-
[ -f "$prd" ] || die "registration incomplete: missing $prd"
|
|
112
|
-
if ! cli_has_project_ensure; then
|
|
113
|
-
mark_pending "$company" "$project"
|
|
114
|
-
die "hq-cli ${MIN_HQ_CLI} or newer is required; ${company}/${project} stays local until then"
|
|
115
|
-
fi
|
|
116
|
-
local ensure_json
|
|
117
|
-
if ! ensure_json="$(hq mesh project ensure "$project" --company "$company" --stories-file "$prd" --json)"; then
|
|
118
|
-
echo "registration incomplete: hq mesh project ensure failed for $company/$project" >&2
|
|
119
|
-
exit 1
|
|
120
|
-
fi
|
|
121
|
-
local thread channel
|
|
122
|
-
thread="$(printf '%s' "$ensure_json" | jq -er '.threadId // empty')" || die "registration incomplete: ensure output missing threadId"
|
|
123
|
-
channel="$(printf '%s' "$ensure_json" | jq -er '.channelId // empty')" || die "registration incomplete: ensure output missing channelId"
|
|
124
|
-
[ -n "$thread" ] || die "registration incomplete: empty threadId"
|
|
125
|
-
[ -n "$channel" ] || die "registration incomplete: empty channelId"
|
|
126
|
-
|
|
127
|
-
local board="$ROOT/companies/$company/board.json"
|
|
128
|
-
local rel="companies/$company/projects/$project/prd.json"
|
|
129
|
-
local now title tmp
|
|
130
|
-
now="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
131
|
-
title="$(jq -r '.name // empty' "$prd")"
|
|
132
|
-
[ -n "$title" ] || title="$project"
|
|
133
|
-
mkdir -p "$(dirname "$board")"
|
|
134
|
-
if [ ! -f "$board" ]; then
|
|
135
|
-
jq -n --arg company "$company" '{company:$company, projects:[]}' > "$board"
|
|
136
|
-
fi
|
|
137
|
-
tmp="$(mktemp)"
|
|
138
|
-
jq \
|
|
139
|
-
--arg id "$project" \
|
|
140
|
-
--arg path "$rel" \
|
|
141
|
-
--arg thread "$thread" \
|
|
142
|
-
--arg channel "$channel" \
|
|
143
|
-
--arg now "$now" \
|
|
144
|
-
--arg title "$title" \
|
|
145
|
-
'
|
|
146
|
-
.projects = (.projects // []) |
|
|
147
|
-
if any(.projects[]; .id == $id or .prd_path == $path or .mesh_project_id == $id) then
|
|
148
|
-
.projects |= map(
|
|
149
|
-
if .id == $id or .prd_path == $path or .mesh_project_id == $id then
|
|
150
|
-
. + {threadId:$thread, channelId:$channel, updated_at:$now, prd_path:(.prd_path // $path), mesh_project_id:$id} | del(.pending_registration)
|
|
151
|
-
else . end
|
|
152
|
-
)
|
|
153
|
-
else
|
|
154
|
-
.projects += [{
|
|
155
|
-
id:$id,
|
|
156
|
-
title:$title,
|
|
157
|
-
status:"prd_created",
|
|
158
|
-
scope:"company",
|
|
159
|
-
prd_path:$path,
|
|
160
|
-
threadId:$thread,
|
|
161
|
-
channelId:$channel,
|
|
162
|
-
mesh_project_id:$id,
|
|
163
|
-
created_at:$now,
|
|
164
|
-
updated_at:$now
|
|
165
|
-
}]
|
|
166
|
-
end
|
|
167
|
-
' "$board" > "$tmp"
|
|
168
|
-
mv "$tmp" "$board"
|
|
169
|
-
jq -e \
|
|
170
|
-
--arg id "$project" \
|
|
171
|
-
--arg path "$rel" \
|
|
172
|
-
--arg thread "$thread" \
|
|
173
|
-
--arg channel "$channel" \
|
|
174
|
-
'any(.projects[]?; (.id == $id or .prd_path == $path or .mesh_project_id == $id) and .threadId == $thread and .channelId == $channel)' \
|
|
175
|
-
"$board" >/dev/null \
|
|
176
|
-
|| die "registration incomplete: board.json entry for $project did not verify"
|
|
177
|
-
echo "registered $company/$project thread=$thread channel=$channel"
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
audit() {
|
|
181
|
-
local company="$1"
|
|
182
|
-
[ -n "$company" ] || die "usage: register-project.sh --audit <company>"
|
|
183
|
-
local dir="$ROOT/companies/$company/projects"
|
|
184
|
-
[ -d "$dir" ] || return 0
|
|
185
|
-
local prd name
|
|
186
|
-
for prd in "$dir"/*/prd.json; do
|
|
187
|
-
[ -f "$prd" ] || continue
|
|
188
|
-
name="$(basename "$(dirname "$prd")")"
|
|
189
|
-
if ! has_board "$company" "$name"; then
|
|
190
|
-
printf '%s\n' "$name"
|
|
191
|
-
fi
|
|
192
|
-
done | sort
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
backfill() {
|
|
196
|
-
local company="" only=0 yes=0
|
|
197
|
-
while [ $# -gt 0 ]; do
|
|
198
|
-
case "$1" in
|
|
199
|
-
--only-active) only=1 ;;
|
|
200
|
-
--yes) yes=1 ;;
|
|
201
|
-
--*) die "unknown flag $1" ;;
|
|
202
|
-
*) company="$1" ;;
|
|
203
|
-
esac
|
|
204
|
-
shift
|
|
205
|
-
done
|
|
206
|
-
[ -n "$company" ] || die "usage: register-project.sh --backfill <company> --only-active [--yes]"
|
|
207
|
-
[ "$only" -eq 1 ] || die "--backfill requires --only-active"
|
|
208
|
-
local dir="$ROOT/companies/$company/projects"
|
|
209
|
-
[ -d "$dir" ] || return 0
|
|
210
|
-
local prd name recent
|
|
211
|
-
local -a targets=()
|
|
212
|
-
for prd in "$dir"/*/prd.json; do
|
|
213
|
-
[ -f "$prd" ] || continue
|
|
214
|
-
name="$(basename "$(dirname "$prd")")"
|
|
215
|
-
story_not_done "$prd" || continue
|
|
216
|
-
recent="$(recent_dir "$(dirname "$prd")")"
|
|
217
|
-
[ "$recent" = "yes" ] || continue
|
|
218
|
-
targets+=("$name")
|
|
219
|
-
done
|
|
220
|
-
IFS=$'\n' targets=($(printf '%s\n' "${targets[@]+"${targets[@]}"}" | sed '/^$/d' | sort))
|
|
221
|
-
unset IFS
|
|
222
|
-
if [ "$yes" -ne 1 ]; then
|
|
223
|
-
local item
|
|
224
|
-
for item in "${targets[@]+"${targets[@]}"}"; do
|
|
225
|
-
echo "would register $company/$item"
|
|
226
|
-
done
|
|
227
|
-
return 0
|
|
228
|
-
fi
|
|
229
|
-
local item
|
|
230
|
-
for item in "${targets[@]+"${targets[@]}"}"; do
|
|
231
|
-
register_one "$company" "$item"
|
|
232
|
-
done
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
retry_pending() {
|
|
236
|
-
local company="${1:-}"
|
|
237
|
-
[ -n "$company" ] || die "usage: register-project.sh --retry-pending <company>"
|
|
238
|
-
cli_has_project_ensure || return 0
|
|
239
|
-
local board
|
|
240
|
-
board="$(board_path "$company")"
|
|
241
|
-
[ -f "$board" ] || return 0
|
|
242
|
-
local id count=0
|
|
243
|
-
while IFS= read -r id; do
|
|
244
|
-
[ -n "$id" ] || continue
|
|
245
|
-
count=$((count + 1))
|
|
246
|
-
[ "$count" -le 3 ] || break
|
|
247
|
-
( register_one "$company" "$id" ) || true
|
|
248
|
-
done < <(jq -r '[.projects[]? | select(.pending_registration == true) | .id // empty] | .[]' "$board" 2>/dev/null || true)
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if [ "${1:-}" = "--audit" ]; then
|
|
252
|
-
audit "${2:-}"
|
|
253
|
-
elif [ "${1:-}" = "--backfill" ]; then
|
|
254
|
-
shift
|
|
255
|
-
backfill "$@"
|
|
256
|
-
elif [ "${1:-}" = "--retry-pending" ]; then
|
|
257
|
-
retry_pending "${2:-}"
|
|
258
|
-
elif [ $# -eq 2 ]; then
|
|
259
|
-
register_one "$1" "$2"
|
|
260
|
-
else
|
|
261
|
-
die "usage: register-project.sh <company> <project> | --audit <company> | --backfill <company> --only-active [--yes] | --retry-pending <company>"
|
|
262
|
-
fi
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# hq-core: public
|
|
3
|
-
# US-011 — enqueue session_end/session_start when project binding changes.
|
|
4
|
-
# Usage:
|
|
5
|
-
# work-mesh-live-rebind.sh --session <sid>
|
|
6
|
-
# Read state file and rebind if project changed vs live-binding marker.
|
|
7
|
-
# work-mesh-live-rebind.sh --session <sid> \
|
|
8
|
-
# --old-company C --old-project P [--old-task T] \
|
|
9
|
-
# --company C2 --project P2 [--task T2]
|
|
10
|
-
set -euo pipefail
|
|
11
|
-
|
|
12
|
-
ROOT="${HQ_ROOT:-${CLAUDE_PROJECT_DIR:-}}"
|
|
13
|
-
if [ -z "$ROOT" ]; then
|
|
14
|
-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
15
|
-
fi
|
|
16
|
-
export HQ_ROOT="$ROOT"
|
|
17
|
-
|
|
18
|
-
# shellcheck source=lib/work-mesh-enqueue.sh
|
|
19
|
-
. "$ROOT/core/scripts/lib/work-mesh-enqueue.sh"
|
|
20
|
-
# shellcheck source=lib/work-mesh-live-hook.sh
|
|
21
|
-
. "$ROOT/core/scripts/lib/work-mesh-live-hook.sh" 2>/dev/null || true
|
|
22
|
-
# shellcheck source=lib/work-mesh-live-rebind.sh
|
|
23
|
-
. "$ROOT/core/scripts/lib/work-mesh-live-rebind.sh"
|
|
24
|
-
|
|
25
|
-
SID=""
|
|
26
|
-
OLD_CO="" OLD_PR="" OLD_TK=""
|
|
27
|
-
NEW_CO="" NEW_PR="" NEW_TK=""
|
|
28
|
-
FROM_STATE=0
|
|
29
|
-
|
|
30
|
-
while [ $# -gt 0 ]; do
|
|
31
|
-
case "$1" in
|
|
32
|
-
--session|--session-id) SID="${2:-}"; shift 2 ;;
|
|
33
|
-
--old-company) OLD_CO="${2:-}"; shift 2 ;;
|
|
34
|
-
--old-project) OLD_PR="${2:-}"; shift 2 ;;
|
|
35
|
-
--old-task) OLD_TK="${2:-}"; shift 2 ;;
|
|
36
|
-
--company|--company-slug) NEW_CO="${2:-}"; shift 2 ;;
|
|
37
|
-
--project) NEW_PR="${2:-}"; shift 2 ;;
|
|
38
|
-
--task) NEW_TK="${2:-}"; shift 2 ;;
|
|
39
|
-
--from-state) FROM_STATE=1; shift ;;
|
|
40
|
-
*) shift ;;
|
|
41
|
-
esac
|
|
42
|
-
done
|
|
43
|
-
|
|
44
|
-
[ -n "$SID" ] || { echo "usage: work-mesh-live-rebind.sh --session <sid> ..." >&2; exit 1; }
|
|
45
|
-
|
|
46
|
-
if [ "$FROM_STATE" -eq 1 ] || [ -z "$NEW_PR" ]; then
|
|
47
|
-
work_mesh_live_maybe_rebind_from_state "$SID"
|
|
48
|
-
else
|
|
49
|
-
if [ -z "$OLD_PR" ]; then
|
|
50
|
-
work_mesh_live_read_binding_marker "$SID"
|
|
51
|
-
old=$REPLY
|
|
52
|
-
OLD_CO="${old%%|*}"
|
|
53
|
-
rest="${old#*|}"
|
|
54
|
-
OLD_PR="${rest%%|*}"
|
|
55
|
-
OLD_TK="${rest#*|}"
|
|
56
|
-
fi
|
|
57
|
-
work_mesh_live_rebind "$SID" "$OLD_CO" "$OLD_PR" "$OLD_TK" "$NEW_CO" "$NEW_PR" "$NEW_TK"
|
|
58
|
-
fi
|
|
59
|
-
exit 0
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { resolveProcessFlagGate } from "../lib/flag-registry.js";
|
|
2
|
-
export const CLI_COMPANY_RENAME_FLAG = "cli.company-rename";
|
|
3
|
-
/** Company display-name updates stay unavailable until hq-flags enables them. */
|
|
4
|
-
export function companyRenameEnabled() {
|
|
5
|
-
return resolveProcessFlagGate(CLI_COMPANY_RENAME_FLAG, { fallback: false }, () => false);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=company-rename-flag.js.map
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import * as yaml from "js-yaml";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import { resolveDefaultHqRoot } from "../utils/hq-root-resolver.js";
|
|
6
|
-
import { parseUserYaml } from "../utils/user-yaml-error.js";
|
|
7
|
-
import { ensureCognitoToken } from "../utils/cognito-session.js";
|
|
8
|
-
import { getEntityUid, vaultApiFetch } from "../utils/vault-api.js";
|
|
9
|
-
import { companyRenameEnabled } from "./company-rename-flag.js";
|
|
10
|
-
function fail(message) {
|
|
11
|
-
console.error(chalk.red(message));
|
|
12
|
-
process.exit(1);
|
|
13
|
-
throw new Error(message);
|
|
14
|
-
}
|
|
15
|
-
function resolveManifestTarget(hqRoot, requestedSlug, companyUid) {
|
|
16
|
-
const manifestPath = path.join(hqRoot, "companies", "manifest.yaml");
|
|
17
|
-
if (!fs.existsSync(manifestPath)) {
|
|
18
|
-
throw new Error(`companies/manifest.yaml not found at ${manifestPath}`);
|
|
19
|
-
}
|
|
20
|
-
const raw = fs.readFileSync(manifestPath, "utf8");
|
|
21
|
-
const parsed = parseUserYaml(raw, manifestPath);
|
|
22
|
-
if (!parsed || !parsed.companies || typeof parsed.companies !== "object") {
|
|
23
|
-
throw new Error("companies/manifest.yaml is malformed — missing top-level .companies map");
|
|
24
|
-
}
|
|
25
|
-
const slug = requestedSlug ?? Object.entries(parsed.companies).find(([, entry]) => entry && typeof entry === "object" && entry.cloud_uid === companyUid)?.[0];
|
|
26
|
-
if (!slug) {
|
|
27
|
-
throw new Error(`No local company manifest entry is bound to ${companyUid}; run from the HQ root or pass --company <slug>.`);
|
|
28
|
-
}
|
|
29
|
-
const value = parsed.companies[slug];
|
|
30
|
-
if (!value || typeof value !== "object") {
|
|
31
|
-
throw new Error(`Company '${slug}' is not present in companies/manifest.yaml.`);
|
|
32
|
-
}
|
|
33
|
-
if (requestedSlug && value.cloud_uid !== companyUid) {
|
|
34
|
-
throw new Error(`Company '${slug}' has no matching cloud_uid in companies/manifest.yaml.`);
|
|
35
|
-
}
|
|
36
|
-
return { slug, path: manifestPath, document: parsed, entry: value };
|
|
37
|
-
}
|
|
38
|
-
function writeManifestName(target, name) {
|
|
39
|
-
target.entry.name = name;
|
|
40
|
-
target.document.companies[target.slug] = target.entry;
|
|
41
|
-
const mode = fs.statSync(target.path).mode;
|
|
42
|
-
const temporaryPath = `${target.path}.tmp.${process.pid}`;
|
|
43
|
-
fs.writeFileSync(temporaryPath, yaml.dump(target.document, { lineWidth: -1, noRefs: true }), { mode });
|
|
44
|
-
fs.chmodSync(temporaryPath, mode);
|
|
45
|
-
fs.renameSync(temporaryPath, target.path);
|
|
46
|
-
}
|
|
47
|
-
/** Register `hq company rename <new name>` for the selected/current company. */
|
|
48
|
-
export function registerCompanyRenameCommand(company) {
|
|
49
|
-
company
|
|
50
|
-
.command("rename <new-name>")
|
|
51
|
-
.description("Rename a cloud-backed company display name")
|
|
52
|
-
.action(async (newName) => {
|
|
53
|
-
if (!companyRenameEnabled()) {
|
|
54
|
-
fail("Company rename is not available yet.");
|
|
55
|
-
}
|
|
56
|
-
const name = newName.trim();
|
|
57
|
-
if (!name)
|
|
58
|
-
fail("Company name cannot be empty.");
|
|
59
|
-
try {
|
|
60
|
-
const requestedSlug = company.opts().company;
|
|
61
|
-
const token = await ensureCognitoToken();
|
|
62
|
-
const companyUid = await getEntityUid(token, { companySlug: requestedSlug });
|
|
63
|
-
const hqRoot = resolveDefaultHqRoot({ onMissing: "throw" });
|
|
64
|
-
const manifestTarget = resolveManifestTarget(hqRoot, requestedSlug, companyUid);
|
|
65
|
-
const response = await vaultApiFetch({
|
|
66
|
-
token,
|
|
67
|
-
path: `/entity/${encodeURIComponent(companyUid)}`,
|
|
68
|
-
method: "PATCH",
|
|
69
|
-
body: { name },
|
|
70
|
-
});
|
|
71
|
-
if (!response.ok) {
|
|
72
|
-
if (response.status === 403) {
|
|
73
|
-
fail("Only a company owner can rename this company.");
|
|
74
|
-
}
|
|
75
|
-
if (response.status === 404) {
|
|
76
|
-
fail("Company not found in HQ Cloud.");
|
|
77
|
-
}
|
|
78
|
-
fail(`Could not rename company (HTTP ${response.status}).`);
|
|
79
|
-
}
|
|
80
|
-
writeManifestName(manifestTarget, name);
|
|
81
|
-
console.log(chalk.green(`Company renamed to ${name}.`));
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
if (error instanceof Error && error.message.startsWith("process.exit"))
|
|
85
|
-
throw error;
|
|
86
|
-
fail(error instanceof Error ? error.message : String(error));
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=company-rename.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { checkTriggerExpressions, evaluateTrigger } from "../utils/core-eval-trigger.js";
|
|
2
|
-
export declare const EVAL_TRIGGER_ASSET = "core/scripts/eval-trigger.sh";
|
|
3
|
-
export declare function runEvalTriggerFast(args: readonly string[], stdin: string, _cwd: string, _root: string | undefined): Promise<number>;
|
|
4
|
-
//# sourceMappingURL=core-eval-trigger-native.d.ts.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** Native implementation of core/scripts/eval-trigger.sh. */
|
|
2
|
-
import { checkTriggerExpressions, evaluateTrigger } from "../utils/core-eval-trigger.js";
|
|
3
|
-
export { checkTriggerExpressions, evaluateTrigger } from "../utils/core-eval-trigger.js";
|
|
4
|
-
export const EVAL_TRIGGER_ASSET = "core/scripts/eval-trigger.sh";
|
|
5
|
-
export async function runEvalTriggerFast(args, stdin, _cwd, _root) {
|
|
6
|
-
if (args[0] === "--check") {
|
|
7
|
-
process.stdout.write(checkTriggerExpressions(stdin));
|
|
8
|
-
return 0;
|
|
9
|
-
}
|
|
10
|
-
return evaluateTrigger(args[0] ?? "", args[1] ?? "");
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=core-eval-trigger-native.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
export declare const MIGRATE_POLICY_TRIGGERS_ASSET = "core/scripts/migrate-policy-triggers.sh";
|
|
3
|
-
export type MigratePolicyDependencies = {
|
|
4
|
-
root: string;
|
|
5
|
-
cwd: string;
|
|
6
|
-
env: NodeJS.ProcessEnv;
|
|
7
|
-
now: () => Date;
|
|
8
|
-
fs: typeof fs;
|
|
9
|
-
evaluatorExists?: () => boolean;
|
|
10
|
-
runFlock?: (lockFd: number, cwd: string, pathValue: string) => {
|
|
11
|
-
status: number | null;
|
|
12
|
-
error?: Error;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export declare function runMigratePolicyTriggers(args: readonly string[], deps: MigratePolicyDependencies): {
|
|
16
|
-
code: number;
|
|
17
|
-
stdout: string;
|
|
18
|
-
stderr: string;
|
|
19
|
-
};
|
|
20
|
-
export declare function runMigratePolicyTriggersFast(args: readonly string[], _stdin: string, cwd: string, root?: string): Promise<number>;
|
|
21
|
-
//# sourceMappingURL=core-migrate-policy-triggers-native.d.ts.map
|