@formigio/fazemos-cli 0.10.91 → 0.10.93
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/dist/index.js +220 -35
- package/dist/index.js.map +1 -1
- package/dist/lib/overridePreview.d.ts +65 -0
- package/dist/lib/overridePreview.js +149 -0
- package/dist/lib/overridePreview.js.map +1 -0
- package/dist/manifest/checks.js +401 -0
- package/dist/manifest/checks.js.map +1 -1
- package/dist/manifest/nexoPrefixes.d.ts +31 -0
- package/dist/manifest/nexoPrefixes.js +65 -0
- package/dist/manifest/nexoPrefixes.js.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
+
import { renderOverridePreview, OVERRIDE_REPLACE_COPY } from './lib/overridePreview.js';
|
|
4
5
|
import { config, getEnv, getToken, getActiveEnvName, getActiveEnvSource, setEnvOverride, getActiveOrgId, setActiveOrgId, addEnvironment, hasEnvironments,
|
|
5
6
|
// F15 — project context helpers
|
|
6
7
|
getActiveProjectId, setActiveProjectId, clearActiveProjectId, findProjectBySlug, findProjectById, findOrgById,
|
|
@@ -8301,19 +8302,27 @@ async function preCheckAgentSourceForDelete(opts) {
|
|
|
8301
8302
|
process.exit(1);
|
|
8302
8303
|
}
|
|
8303
8304
|
/**
|
|
8304
|
-
* F17 §8.3 — `agents override <name>`: create/update a
|
|
8305
|
-
* for the named Org agent. PATCH with `{override: <parsed>}`.
|
|
8305
|
+
* F17 §8.3 / BUG178 slice (i) — `agents override <name>`: create/update a
|
|
8306
|
+
* Project override for the named Org agent. PATCH with `{override: <parsed>}`.
|
|
8306
8307
|
*
|
|
8307
|
-
*
|
|
8308
|
-
*
|
|
8308
|
+
* This is a whole-document replace, not a merge: any key present in the
|
|
8309
|
+
* current override but absent from `--config` is DROPPED and reverts to
|
|
8310
|
+
* the Org baseline, and `--config '{}'` deletes the override row entirely.
|
|
8311
|
+
* `renderOverridePreview` (src/lib/overridePreview.ts) computes the
|
|
8312
|
+
* ADDED/CHANGED/UNCHANGED/DROPPED status for every key so the preview
|
|
8313
|
+
* cannot lie about what a save will do (BUG178). --dry-run prints that
|
|
8314
|
+
* preview and exits without calling the API (Kate Q2). --verbose prints
|
|
8315
|
+
* full values instead of the >200-char truncation marker. --yes bypasses
|
|
8316
|
+
* the confirmation prompt.
|
|
8309
8317
|
*/
|
|
8310
8318
|
agentsCmd
|
|
8311
8319
|
.command('override')
|
|
8312
|
-
.description(
|
|
8320
|
+
.description(OVERRIDE_REPLACE_COPY)
|
|
8313
8321
|
.argument('<name>', 'Agent name (e.g., marco)')
|
|
8314
8322
|
.requiredOption('--config <json-or-file>', 'Override config as inline JSON or a file path')
|
|
8315
8323
|
.option('--project <slug>', 'Override active Project for this call')
|
|
8316
8324
|
.option('--dry-run', 'Print the diff without calling the API', false)
|
|
8325
|
+
.option('--verbose', 'Print full values instead of truncating long ones', false)
|
|
8317
8326
|
.option('--yes', 'Skip the confirmation prompt', false)
|
|
8318
8327
|
.action(async (name, opts) => {
|
|
8319
8328
|
try {
|
|
@@ -8339,7 +8348,6 @@ agentsCmd
|
|
|
8339
8348
|
const existing = current.agent;
|
|
8340
8349
|
const proj = findProjectById(orgId, projectId);
|
|
8341
8350
|
const projSlug = proj?.slug ?? projectId;
|
|
8342
|
-
const fieldsToUpdate = Object.keys(override);
|
|
8343
8351
|
console.log(chalk.cyan(`Overriding ${name} for project: ${projSlug}`));
|
|
8344
8352
|
if (existing.source === 'org') {
|
|
8345
8353
|
console.log(`Source: org agent → project-override`);
|
|
@@ -8351,30 +8359,33 @@ agentsCmd
|
|
|
8351
8359
|
console.log(chalk.yellow(`Warning: ${name} is a Project-only agent — this will be rejected by the API.`));
|
|
8352
8360
|
console.log(chalk.gray('Use `fazemos agents add` (update) or PATCH via the UI.'));
|
|
8353
8361
|
}
|
|
8354
|
-
console.log(`Fields to update: ${fieldsToUpdate.join(', ')}`);
|
|
8355
8362
|
console.log('');
|
|
8356
|
-
console.log(chalk.gray(
|
|
8357
|
-
console.log(chalk.gray('Arrays are not merged — they replace.'));
|
|
8363
|
+
console.log(chalk.gray(OVERRIDE_REPLACE_COPY));
|
|
8358
8364
|
console.log('');
|
|
8359
|
-
console.log(chalk.gray('Diff (Org baseline → Project override):'));
|
|
8360
8365
|
const baseline = (existing.org_baseline_config ?? {});
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
const
|
|
8364
|
-
|
|
8365
|
-
const afterStr = JSON.stringify(after).slice(0, 80);
|
|
8366
|
-
console.log(` ${k}:`);
|
|
8367
|
-
console.log(` − ${beforeStr}`);
|
|
8368
|
-
console.log(` + ${afterStr}`);
|
|
8366
|
+
const preview = renderOverridePreview(existing.project_override_config ?? null, override, baseline, { name, verbose: !!opts.verbose });
|
|
8367
|
+
for (const line of preview.lines) {
|
|
8368
|
+
const text = line.style ? chalk[line.style](line.text) : line.text;
|
|
8369
|
+
console.log(text);
|
|
8369
8370
|
}
|
|
8370
8371
|
console.log('');
|
|
8371
8372
|
if (opts.dryRun) {
|
|
8372
8373
|
console.log(chalk.yellow('[dry run] No changes sent to the API.'));
|
|
8373
8374
|
return;
|
|
8374
8375
|
}
|
|
8375
|
-
if (existing.source === 'org' || existing.source === 'project_override') {
|
|
8376
|
+
if (!preview.isDelete && (existing.source === 'org' || existing.source === 'project_override')) {
|
|
8376
8377
|
console.log(`This will diverge ${name}'s config in ${projSlug} from the Org baseline.`);
|
|
8377
8378
|
console.log(`Future Org-level changes to these fields will not propagate.`);
|
|
8379
|
+
}
|
|
8380
|
+
if (preview.isDelete) {
|
|
8381
|
+
console.log(chalk.red(`This DELETES the Project override for ${name}; every field reverts to the Org baseline.`));
|
|
8382
|
+
}
|
|
8383
|
+
if (preview.droppedKeys.length > 0) {
|
|
8384
|
+
console.log(chalk.yellow(`This drops: ${preview.droppedKeys.join(', ')} (reverting to Org baseline).`));
|
|
8385
|
+
}
|
|
8386
|
+
if (existing.source === 'org' ||
|
|
8387
|
+
existing.source === 'project_override' ||
|
|
8388
|
+
preview.droppedKeys.length > 0) {
|
|
8378
8389
|
await confirmOrAbort('Proceed? [y/N]: ', !!opts.yes);
|
|
8379
8390
|
}
|
|
8380
8391
|
const result = await api('PATCH', `/api/organizations/${orgId}/projects/${projectId}/agents/${encodeURIComponent(name)}`, { override }, { noProjectHeader: true });
|
|
@@ -10246,6 +10257,48 @@ Rule slugs (stable; safe to grep in --json output):
|
|
|
10246
10257
|
ids.duplicate_task same task id in multiple implementation buckets
|
|
10247
10258
|
ids.duplicate duplicate id in edge_cases / risks / phase_1_gate.questions
|
|
10248
10259
|
helper.callers_duplicate (warning) api.internal_helper.callers lists same caller twice
|
|
10260
|
+
nexo.node_prefix_invalid a nexo node-id position (anchor / touches[].id / new_nodes[] /
|
|
10261
|
+
legacy new_entry_points[] etc.) has a prefix that is not a real
|
|
10262
|
+
Nexo node prefix (e.g. ep_). Does NOT check top-level
|
|
10263
|
+
entry_points.*.id or free text under nexo (source_files, etc.)
|
|
10264
|
+
new_nodes (and the other array keys) also accept the grouped
|
|
10265
|
+
object-of-arrays shape (new_nodes: {features: [...], ...}); group
|
|
10266
|
+
keys themselves are never checked, only the ids inside each group.
|
|
10267
|
+
nexo.node_shape_unrecognized (warning) a node-id position's shape could not be identified
|
|
10268
|
+
well enough to check prefixes at all, so none were checked —
|
|
10269
|
+
fires at: a nexo.<key> value that is neither an array nor an
|
|
10270
|
+
object of arrays grouped by type; a grouped nexo.<key>.<group>
|
|
10271
|
+
value that isn't itself an array; or a nexo.<key>[i] array entry
|
|
10272
|
+
that is neither a bare string id nor an object with a string .id.
|
|
10273
|
+
deploy.hop_missing_vehicle fires when top-level implementation.deploy_order is present (any
|
|
10274
|
+
shape — string, list, or prose) AND at least 2 deploy-bearing blocks,
|
|
10275
|
+
combined across implementation.<key> (top level) AND one level deep
|
|
10276
|
+
under each of implementation.sequencing.<key> and
|
|
10277
|
+
implementation.slices.<key> (no recursion, no other container names —
|
|
10278
|
+
a new container name needs an ED ruling first, 10-12e), are
|
|
10279
|
+
deploy-bearing (non-empty tasks[]; excludes "release", "deploy_order",
|
|
10280
|
+
and the sequencing/slices containers themselves; excludes a block
|
|
10281
|
+
opted out via deploys: false + a non-empty deploys_reason).
|
|
10282
|
+
implementation.traceability (AC->tasks maps) and
|
|
10283
|
+
implementation.parallel_paths are deliberately NOT walked (10-12e
|
|
10284
|
+
declined a generic "any nested map" walker). Each deploy-bearing block
|
|
10285
|
+
then needs a .vehicle that is present, a string, non-empty, and carries
|
|
10286
|
+
a positive \b-anchored token: PR #N, pull/N, a feat|feature|fix|bugfix|
|
|
10287
|
+
hotfix|release branch ref, a release-vN / vX.Y.Z tag, a 7+ char hex id
|
|
10288
|
+
containing at least one digit (SHA/instance/dispatch id), or
|
|
10289
|
+
TBD-<owner-role>. A bare classification label ("Class C", "own
|
|
10290
|
+
deploy") with no carrier is rejected; an object/array/number vehicle
|
|
10291
|
+
gets its own "missing or not a string" message. deploys:
|
|
10292
|
+
false with a missing/blank deploys_reason is a separate error on the
|
|
10293
|
+
same slug, and fires whenever top-level deploy_order is present at
|
|
10294
|
+
all — regardless of whether the ≥2 structural trigger below also
|
|
10295
|
+
engages, so an un-reasoned opt-out can never drop the count below 2
|
|
10296
|
+
and silently switch the rest of the rule off (Dex C-1). Vehicle
|
|
10297
|
+
grammar is only checked once ≥2 combined deploy-bearing blocks are
|
|
10298
|
+
present; no top-level deploy_order at all means nothing is checked
|
|
10299
|
+
(10-10r rulings 1-3 + 10-12c sequencing-walker ruling + 10-12e
|
|
10300
|
+
slices-container ruling; amends 10-10l §2; Dex C-1/I-1 10-12
|
|
10301
|
+
re-review, ED 83a74d1c).
|
|
10249
10302
|
schema.required required field missing (feature.id, feature.title)
|
|
10250
10303
|
schema.type / schema.anyOf value has wrong shape
|
|
10251
10304
|
manifest.version_missing (warning) add manifest_version: "0.1" at the top of the file
|
|
@@ -10931,18 +10984,31 @@ transition), so this PATCHes to read first when a row is still unread, then
|
|
|
10931
10984
|
PATCHes to actioned. A 409 on a row that is already terminal (actioned or
|
|
10932
10985
|
archived) is reported and is non-fatal — it does not stop the remaining ids.
|
|
10933
10986
|
|
|
10987
|
+
Project scoping (BUG277-CLI containment): the listing and --mark-read are
|
|
10988
|
+
scoped to the caller's resolved project — --project <slug> if given, else the
|
|
10989
|
+
active project (.fazemos.json / fazemos projects switch). A dispatch with a
|
|
10990
|
+
NULL project_id is org-level: it is always listed, but --mark-read NEVER
|
|
10991
|
+
bulk-marks it — org-level rows are only markable by id, via --mark-actioned.
|
|
10992
|
+
--mark-read with no resolvable project fails closed (exits non-zero, marks
|
|
10993
|
+
nothing). Pass --all-projects to skip the project filter on the listing only
|
|
10994
|
+
(read-only widen; refused together with --mark-read).
|
|
10995
|
+
|
|
10934
10996
|
Examples:
|
|
10935
10997
|
fazemos inbox --role chief-of-staff # unread for role
|
|
10936
10998
|
fazemos inbox --role engineering-director --status all
|
|
10937
|
-
fazemos inbox --role project-manager --mark-read # drain + mark read
|
|
10999
|
+
fazemos inbox --role project-manager --mark-read # drain + mark read, scoped to the active project (NULL-project rows are listed but never bulk-marked)
|
|
11000
|
+
fazemos inbox --project other-proj --mark-read # drain a specific project
|
|
11001
|
+
fazemos inbox --all-projects # list across every project in the org (read-only)
|
|
10938
11002
|
fazemos inbox --format json --role luca | jq .
|
|
10939
|
-
fazemos inbox --mark-actioned <id> [<id>...] # stage row(s) to actioned`)
|
|
11003
|
+
fazemos inbox --mark-actioned <id> [<id>...] # stage row(s) to actioned (by id; works on org-level rows too)`)
|
|
10940
11004
|
.option('--role <slug>', 'filter to a specific role-slug (defaults to all roles the caller fills)')
|
|
10941
11005
|
.option('--status <status>', 'unread | read | all (default: unread)', 'unread')
|
|
10942
11006
|
.option('--limit <n>', 'max dispatches to return (default: 50)', (v) => parseInt(v, 10), 50)
|
|
10943
11007
|
.option('--format <format>', 'table | json (default: table)', 'table')
|
|
10944
|
-
.option('--mark-read', 'after listing, PATCH each dispatch to status=read')
|
|
11008
|
+
.option('--mark-read', 'after listing, PATCH each dispatch to status=read (own-project rows only; NULL-project rows are never bulk-marked)')
|
|
10945
11009
|
.option('--mark-actioned <ids...>', 'mark the given dispatch id(s) as actioned (staged read→actioned; a 409 on an already-terminal row is reported and non-fatal)')
|
|
11010
|
+
.option('--project <slug>', 'scope the listing / --mark-read to this project (default: the active project)')
|
|
11011
|
+
.option('--all-projects', 'skip the project filter on the listing (read-only; refused together with --mark-read)', false)
|
|
10946
11012
|
.action(async (opts) => {
|
|
10947
11013
|
try {
|
|
10948
11014
|
// ── DISPATCH-DB-ONLY-INBOX (P2, T2.6) — `--mark-actioned <ids...>` ────
|
|
@@ -11013,23 +11079,126 @@ Examples:
|
|
|
11013
11079
|
if (!validFormats.includes(opts.format)) {
|
|
11014
11080
|
throw new Error(`Invalid --format "${opts.format}". Valid: ${validFormats.join(', ')}`);
|
|
11015
11081
|
}
|
|
11082
|
+
// ── BUG277-CLI: project-scope guard + resolution ────────────────────
|
|
11083
|
+
// Dispatch reads/writes are not server-project-scoped today (fix (b),
|
|
11084
|
+
// API, is a separate train). This is the CLI-side containment: scope
|
|
11085
|
+
// the listing and --mark-read to the caller's resolved project so a
|
|
11086
|
+
// shared filler (e.g. a role filled in both fazemos and
|
|
11087
|
+
// formigio-graph) can't drain another project's rows.
|
|
11088
|
+
//
|
|
11089
|
+
// --mark-read + --all-projects is refused outright — bulk-marking
|
|
11090
|
+
// across every project in the org is exactly the cross-project write
|
|
11091
|
+
// this fix exists to close off.
|
|
11092
|
+
if (opts.markRead && opts.allProjects) {
|
|
11093
|
+
console.error(chalk.red('--mark-read cannot be combined with --all-projects.'));
|
|
11094
|
+
console.error(chalk.gray('Scope the drain with --project <slug>, or drop --mark-read to just list.'));
|
|
11095
|
+
process.exit(1);
|
|
11096
|
+
return;
|
|
11097
|
+
}
|
|
11098
|
+
// Resolution is for the CLIENT-SIDE filter only — `noProjectHeader:
|
|
11099
|
+
// true` stays on every call below, unchanged. --all-projects skips
|
|
11100
|
+
// resolution entirely: it's a "don't filter" switch, never a
|
|
11101
|
+
// `?view=all` query param (the server doesn't define one for this
|
|
11102
|
+
// endpoint). An unresolvable --project <slug> throws
|
|
11103
|
+
// ApiError(UNKNOWN_PROJECT), which the outer catch turns into the
|
|
11104
|
+
// standard exit 1.
|
|
11105
|
+
const resolvedProjectId = opts.allProjects
|
|
11106
|
+
? null
|
|
11107
|
+
: await resolveProjectIdBySlug(opts.project);
|
|
11108
|
+
// Fail closed: a null resolution (no active project, no --project)
|
|
11109
|
+
// marks nothing. `null === null` must never be read as "no filter" —
|
|
11110
|
+
// that would bulk-mark every project's rows, the opposite of the fix.
|
|
11111
|
+
if (opts.markRead && resolvedProjectId == null) {
|
|
11112
|
+
console.error(chalk.red('No active project resolved — refusing to bulk-mark dispatches as read.'));
|
|
11113
|
+
console.error(chalk.gray('Pass --project <slug>, or set an active project: fazemos projects switch <slug>'));
|
|
11114
|
+
process.exit(1);
|
|
11115
|
+
return;
|
|
11116
|
+
}
|
|
11016
11117
|
// Build query
|
|
11017
11118
|
const params = new URLSearchParams();
|
|
11018
11119
|
if (opts.role)
|
|
11019
11120
|
params.set('role', opts.role);
|
|
11020
11121
|
params.set('status', opts.status);
|
|
11021
11122
|
params.set('limit', String(opts.limit));
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11123
|
+
// ── Fetch ────────────────────────────────────────────────
|
|
11124
|
+
// Plain listing: one page, as before. --mark-read pages through
|
|
11125
|
+
// ?cursor= until exhausted (capped at PAGE_CAP) — the client-side
|
|
11126
|
+
// project filter runs AFTER the server's LIMIT, so other-project rows
|
|
11127
|
+
// can fill a page and hide the caller's own-project unread rows
|
|
11128
|
+
// underneath it (page starvation; a false "nothing to mark" on a
|
|
11129
|
+
// shared filler). This is a containment limit: PR B's server-side
|
|
11130
|
+
// project filter removes the need for client paging.
|
|
11131
|
+
const PAGE_CAP = 10;
|
|
11132
|
+
let items = [];
|
|
11133
|
+
let nextCursor = null;
|
|
11134
|
+
let pageCapHit = false;
|
|
11135
|
+
if (opts.markRead) {
|
|
11136
|
+
let cursor;
|
|
11137
|
+
let pages = 0;
|
|
11138
|
+
do {
|
|
11139
|
+
const pageQuery = new URLSearchParams(params);
|
|
11140
|
+
if (cursor)
|
|
11141
|
+
pageQuery.set('cursor', cursor);
|
|
11142
|
+
const page = await api('GET', `/api/dispatches?${pageQuery.toString()}`, undefined, {
|
|
11143
|
+
noProjectHeader: true,
|
|
11144
|
+
});
|
|
11145
|
+
items = items.concat(page.items ?? []);
|
|
11146
|
+
nextCursor = page.nextCursor ?? null;
|
|
11147
|
+
cursor = nextCursor ?? undefined;
|
|
11148
|
+
pages++;
|
|
11149
|
+
} while (cursor && pages < PAGE_CAP);
|
|
11150
|
+
if (cursor) {
|
|
11151
|
+
pageCapHit = true;
|
|
11152
|
+
}
|
|
11153
|
+
}
|
|
11154
|
+
else {
|
|
11155
|
+
const result = await api('GET', `/api/dispatches?${params.toString()}`, undefined, {
|
|
11156
|
+
noProjectHeader: true,
|
|
11157
|
+
});
|
|
11158
|
+
items = result.items ?? [];
|
|
11159
|
+
nextCursor = result.nextCursor ?? null;
|
|
11160
|
+
}
|
|
11161
|
+
// ── Client-side project filter (BUG277-CLI containment) ─────────────
|
|
11162
|
+
// Default: own-project + org-level (NULL project_id) rows. --all-
|
|
11163
|
+
// projects: unfiltered. Unresolved (no --project, no active project,
|
|
11164
|
+
// and NOT --all-projects): NULL rows only — never fail open to
|
|
11165
|
+
// everything.
|
|
11166
|
+
let filteredItems;
|
|
11167
|
+
let unresolvedListing = false;
|
|
11168
|
+
if (opts.allProjects) {
|
|
11169
|
+
filteredItems = items;
|
|
11170
|
+
}
|
|
11171
|
+
else if (resolvedProjectId == null) {
|
|
11172
|
+
unresolvedListing = true;
|
|
11173
|
+
filteredItems = items.filter(d => d.project_id == null);
|
|
11174
|
+
}
|
|
11175
|
+
else {
|
|
11176
|
+
filteredItems = items.filter(d => d.project_id === resolvedProjectId || d.project_id == null);
|
|
11177
|
+
}
|
|
11178
|
+
const hiddenCount = items.length - filteredItems.length;
|
|
11179
|
+
const notes = [];
|
|
11180
|
+
if (unresolvedListing) {
|
|
11181
|
+
notes.push('No active project resolved; showing org-level (NULL-project) dispatches only. Pass --project <slug> or --all-projects to see more.');
|
|
11182
|
+
}
|
|
11183
|
+
if (hiddenCount > 0) {
|
|
11184
|
+
notes.push(`${hiddenCount} other-project row(s) hidden.`);
|
|
11185
|
+
}
|
|
11186
|
+
if (opts.markRead) {
|
|
11187
|
+
const orgLevelUnreadCount = items.filter(d => d.project_id == null && d.status === 'unread').length;
|
|
11188
|
+
if (orgLevelUnreadCount > 0) {
|
|
11189
|
+
notes.push(`${orgLevelUnreadCount} org-level row(s) not marked; use --mark-actioned <id>.`);
|
|
11190
|
+
}
|
|
11191
|
+
}
|
|
11192
|
+
if (pageCapHit) {
|
|
11193
|
+
notes.push(`Stopped after ${PAGE_CAP} page(s) while draining; more dispatches may remain unmarked. Re-run --mark-read to continue.`);
|
|
11194
|
+
}
|
|
11026
11195
|
// ── JSON output ──────────────────────────────────────────
|
|
11027
11196
|
if (opts.format === 'json') {
|
|
11028
|
-
console.log(JSON.stringify(
|
|
11197
|
+
console.log(JSON.stringify({ items: filteredItems, nextCursor }, null, 2));
|
|
11029
11198
|
}
|
|
11030
11199
|
else {
|
|
11031
11200
|
// ── Table output ─────────────────────────────────────
|
|
11032
|
-
if (
|
|
11201
|
+
if (filteredItems.length === 0) {
|
|
11033
11202
|
if (opts.role) {
|
|
11034
11203
|
console.log(chalk.gray(`No ${opts.status} dispatches for role "${opts.role}".`));
|
|
11035
11204
|
}
|
|
@@ -11069,32 +11238,48 @@ Examples:
|
|
|
11069
11238
|
].join(' ');
|
|
11070
11239
|
console.log(header);
|
|
11071
11240
|
console.log(chalk.gray('─'.repeat(130)));
|
|
11072
|
-
for (const d of
|
|
11241
|
+
for (const d of filteredItems) {
|
|
11073
11242
|
const priColor = d.priority === 'high' ? chalk.red : d.priority === 'low' ? chalk.gray : chalk.white;
|
|
11243
|
+
// BUG277-CLI — flag org-level (NULL project_id) rows in the table
|
|
11244
|
+
// so it's visible they're never swept by --mark-read.
|
|
11245
|
+
const orgLevelTag = d.project_id == null ? '[org-level] ' : '';
|
|
11074
11246
|
const row = [
|
|
11075
11247
|
pad(d.to_role ?? '', COL_ROLE),
|
|
11076
11248
|
pad(d.from_role ?? '', COL_FROM),
|
|
11077
11249
|
pad(d.type ?? '', COL_TYPE),
|
|
11078
11250
|
priColor(pad(d.priority ?? 'normal', COL_PRI)),
|
|
11079
11251
|
chalk.gray(pad(age(d.created_at), COL_AGE)),
|
|
11080
|
-
chalk.cyan(pad(d.summary ?? d.body?.split('\n')[0] ?? '', COL_BODY)),
|
|
11252
|
+
chalk.cyan(pad(orgLevelTag + (d.summary ?? d.body?.split('\n')[0] ?? ''), COL_BODY)),
|
|
11081
11253
|
].join(' ');
|
|
11082
11254
|
console.log(row);
|
|
11083
11255
|
}
|
|
11084
11256
|
console.log(chalk.gray('─'.repeat(130)));
|
|
11085
|
-
console.log(chalk.gray(`${
|
|
11257
|
+
console.log(chalk.gray(`${filteredItems.length} dispatch(es) shown.${nextCursor ? ' More available (use --limit to increase).' : ''}`));
|
|
11258
|
+
}
|
|
11259
|
+
}
|
|
11260
|
+
// Notes go to stderr in JSON mode (stdout must stay pure, parseable
|
|
11261
|
+
// JSON) and to stdout alongside the table in table mode.
|
|
11262
|
+
for (const note of notes) {
|
|
11263
|
+
if (opts.format === 'json') {
|
|
11264
|
+
console.error(chalk.gray(note));
|
|
11265
|
+
}
|
|
11266
|
+
else {
|
|
11267
|
+
console.log(chalk.gray(note));
|
|
11086
11268
|
}
|
|
11087
11269
|
}
|
|
11088
11270
|
// ── --mark-read ──────────────────────────────────────────
|
|
11089
11271
|
if (opts.markRead && items.length > 0) {
|
|
11090
|
-
|
|
11091
|
-
|
|
11092
|
-
|
|
11272
|
+
// AC1-NULL: explicit `project_id != null` BEFORE the equality check
|
|
11273
|
+
// — a NULL row must never compare equal to a resolved id by
|
|
11274
|
+
// incidental null-handling.
|
|
11275
|
+
const bulkSet = items.filter(d => d.status === 'unread' && d.project_id != null && d.project_id === resolvedProjectId);
|
|
11276
|
+
if (bulkSet.length === 0) {
|
|
11277
|
+
console.log(chalk.gray('\nAll shown dispatches already read, or excluded by project scope; nothing to mark.'));
|
|
11093
11278
|
}
|
|
11094
11279
|
else {
|
|
11095
11280
|
let marked = 0;
|
|
11096
11281
|
let failed = 0;
|
|
11097
|
-
for (const d of
|
|
11282
|
+
for (const d of bulkSet) {
|
|
11098
11283
|
try {
|
|
11099
11284
|
await api('PATCH', `/api/dispatches/${d.id}`, { status: 'read' }, {
|
|
11100
11285
|
noProjectHeader: true,
|