@gh-symphony/cli 0.2.0 → 0.2.3

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/README.md CHANGED
@@ -37,6 +37,7 @@ gh-symphony doctor
37
37
  gh-symphony doctor --fix
38
38
  gh-symphony doctor --json
39
39
  gh-symphony doctor --smoke
40
+ gh-symphony doctor --bundle
40
41
  GITHUB_GRAPHQL_TOKEN=ghp_your_classic_token gh-symphony doctor --json
41
42
  ```
42
43
 
@@ -107,6 +108,56 @@ You can further customize the agent's behavior by editing `WORKFLOW.md` — this
107
108
 
108
109
  > Currently supported runtimes: **Codex**, **Claude Code**
109
110
 
111
+ ### Explicit Priority Mapping
112
+
113
+ GitHub Project V2 does not have a native issue priority. For GitHub Project workflows, dispatch priority is controlled only by the explicit `tracker.priority` policy in `WORKFLOW.md`; there is no fallback from Project fields to labels and no guessed label naming convention. Unmapped values resolve to `priority = null`, so dispatch falls back to created time and identifier.
114
+
115
+ Project field source:
116
+
117
+ ```yaml
118
+ tracker:
119
+ kind: github-project
120
+ project_id: PVT_kwDOxxxxxx
121
+ state_field: Status
122
+ priority:
123
+ source: project-field
124
+ field: Priority
125
+ values:
126
+ Urgent: 0
127
+ High: 1
128
+ Medium: 2
129
+ Low: 3
130
+ ```
131
+
132
+ Label source:
133
+
134
+ ```yaml
135
+ tracker:
136
+ kind: github-project
137
+ project_id: PVT_kwDOxxxxxx
138
+ state_field: Status
139
+ priority:
140
+ source: labels
141
+ labels:
142
+ P0: 0
143
+ P1: 1
144
+ P2: 2
145
+ P3: 3
146
+ ```
147
+
148
+ Disabled:
149
+
150
+ ```yaml
151
+ tracker:
152
+ kind: github-project
153
+ priority:
154
+ source: disabled
155
+ ```
156
+
157
+ Legacy `tracker.priority_field: Priority` still works, but it is deprecated because it derives numeric priority from the live Project option order. Migrate by copying the field name into `tracker.priority.field` and writing each option display name under `values` with the intended number. If both keys are present, `tracker.priority` wins and `gh-symphony doctor` reports a warning.
158
+
159
+ Run `gh-symphony workflow validate` for local schema errors and `gh-symphony doctor` for live drift warnings such as missing Project fields, missing labels, unmapped live options, stale mappings, and active issues whose priority-like value resolves to `priority = null`.
160
+
110
161
  ### Linear Tracker Repositories
111
162
 
112
163
  For Linear, configure the tracker in `WORKFLOW.md` and initialize the repository runtime from the target GitHub repository:
@@ -303,6 +354,22 @@ Without `--issue`, doctor auto-selects one active live issue from the managed pr
303
354
  - launches `gh-symphony setup` when repository runtime setup or GitHub Project binding must be repaired
304
355
  - prints concrete runtime install guidance when the configured command is missing on `PATH`
305
356
 
357
+ `gh-symphony doctor --bundle` creates a redacted support bundle for bug reports:
358
+
359
+ ```bash
360
+ gh-symphony doctor --bundle
361
+ gh-symphony doctor --bundle ./tmp/support-bundle
362
+ gh-symphony doctor --bundle --project-id your-project-id
363
+ gh-symphony doctor --bundle --json
364
+ ```
365
+
366
+ The bundle writes a deterministic directory containing `manifest.json`,
367
+ `doctor.json`, redacted CLI/project config, `WORKFLOW.md`, runtime
368
+ `status.json`/`issues.json` when available, and bounded recent run
369
+ `events.ndjson`, `worker.log`, and `orchestrator.log` tails. Missing optional
370
+ artifacts are listed in `manifest.missing`; redaction and truncation counts are
371
+ reported in the command summary.
372
+
306
373
  The diagnostic checks cover:
307
374
 
308
375
  - the active GitHub auth source (`GITHUB_GRAPHQL_TOKEN` first, otherwise `gh`) and required scopes
@@ -321,6 +388,7 @@ Use JSON output for scripts and CI smoke checks. `--fix --json` includes a remed
321
388
  gh-symphony doctor --json
322
389
  gh-symphony doctor --fix --json
323
390
  gh-symphony doctor --smoke --json
391
+ gh-symphony doctor --bundle --json
324
392
  gh-symphony repo start --once
325
393
  ```
326
394
 
@@ -53,6 +53,7 @@ var DEFAULT_WORKFLOW_TRACKER = {
53
53
  terminalStates: DEFAULT_WORKFLOW_LIFECYCLE.terminalStates,
54
54
  projectId: null,
55
55
  stateFieldName: DEFAULT_WORKFLOW_LIFECYCLE.stateFieldName,
56
+ priority: null,
56
57
  priorityFieldName: null,
57
58
  blockerCheckStates: DEFAULT_WORKFLOW_LIFECYCLE.blockerCheckStates
58
59
  };
@@ -169,6 +170,7 @@ function parseWorkflowMarkdown(markdown, env = process.env, options = {}) {
169
170
  terminalStates,
170
171
  projectId: readOptionalString(tracker, "project_id", env),
171
172
  stateFieldName: readOptionalString(tracker, "state_field", env) ?? DEFAULT_WORKFLOW_TRACKER.stateFieldName,
173
+ priority: readPriorityConfig(tracker, env),
172
174
  priorityFieldName: readOptionalString(tracker, "priority_field", env),
173
175
  blockerCheckStates
174
176
  },
@@ -235,6 +237,52 @@ function validateTrackerConfig(tracker, trackerKind, env) {
235
237
  }
236
238
  }
237
239
  }
240
+ function readPriorityConfig(tracker, env) {
241
+ if (tracker.priority === void 0 || tracker.priority === null) {
242
+ return null;
243
+ }
244
+ const priority = readObject(tracker, "priority", "tracker.priority");
245
+ const source = readRequiredString(priority, "source", env);
246
+ const keys = new Set(Object.keys(priority));
247
+ if (source === "project-field") {
248
+ rejectPriorityKeys(keys, ["source", "field", "values"], source);
249
+ const field = readRequiredString(priority, "field", env);
250
+ const values = readNumberMap(priority, "values", "tracker.priority.values");
251
+ if (Object.keys(values).length === 0) {
252
+ throw new Error(
253
+ 'Workflow front matter field "tracker.priority.values" must be a non-empty object for tracker.priority.source "project-field".'
254
+ );
255
+ }
256
+ return { source, field, values };
257
+ }
258
+ if (source === "labels") {
259
+ rejectPriorityKeys(keys, ["source", "labels"], source);
260
+ const labels = readNumberMap(priority, "labels", "tracker.priority.labels");
261
+ if (Object.keys(labels).length === 0) {
262
+ throw new Error(
263
+ 'Workflow front matter field "tracker.priority.labels" must be a non-empty object for tracker.priority.source "labels".'
264
+ );
265
+ }
266
+ return { source, labels };
267
+ }
268
+ if (source === "disabled") {
269
+ rejectPriorityKeys(keys, ["source"], source);
270
+ return { source };
271
+ }
272
+ throw new Error(
273
+ `Unsupported workflow tracker.priority.source "${source}". Supported values: project-field, labels, disabled.`
274
+ );
275
+ }
276
+ function rejectPriorityKeys(keys, allowedKeys, source) {
277
+ const allowed = new Set(allowedKeys);
278
+ for (const key of keys) {
279
+ if (!allowed.has(key)) {
280
+ throw new Error(
281
+ `Workflow front matter field "tracker.priority.${key}" is not supported for tracker.priority.source "${source}".`
282
+ );
283
+ }
284
+ }
285
+ }
238
286
  function parseLegacyWorkflowMarkdown(markdown) {
239
287
  const promptGuidelines = matchOptionalSection(markdown, "Prompt Guidelines") ?? "";
240
288
  return {
@@ -262,6 +310,10 @@ function parseBlock(lines, startIndex, indent) {
262
310
  index += 1;
263
311
  continue;
264
312
  }
313
+ if (line.trim().startsWith("#")) {
314
+ index += 1;
315
+ continue;
316
+ }
265
317
  const lineIndent = countIndent(line);
266
318
  if (lineIndent < indent) {
267
319
  break;
@@ -306,11 +358,16 @@ function parseBlock(lines, startIndex, indent) {
306
358
  );
307
359
  }
308
360
  collectionType = "object";
309
- const separatorIndex = trimmed.indexOf(":");
361
+ const separatorIndex = findMappingSeparator(trimmed);
310
362
  if (separatorIndex < 0) {
311
363
  throw new Error(`Invalid workflow front matter line "${trimmed}".`);
312
364
  }
313
- const key = trimmed.slice(0, separatorIndex).trim();
365
+ const rawKey = trimmed.slice(0, separatorIndex).trim();
366
+ const parsedKey = parseScalar(rawKey);
367
+ if (typeof parsedKey !== "string") {
368
+ throw new Error(`Invalid workflow front matter key "${rawKey}".`);
369
+ }
370
+ const key = parsedKey;
314
371
  const remainder = trimmed.slice(separatorIndex + 1).trim();
315
372
  if (remainder === "|" || remainder === "|-") {
316
373
  const [multiline, nextIndex2] = parseMultilineScalar(
@@ -355,6 +412,30 @@ function parseMultilineScalar(lines, startIndex, indent) {
355
412
  function countIndent(line) {
356
413
  return line.match(/^ */)?.[0].length ?? 0;
357
414
  }
415
+ function findMappingSeparator(value) {
416
+ let quote = null;
417
+ for (let index = 0; index < value.length; index += 1) {
418
+ const char = value[index];
419
+ if (quote) {
420
+ if (char === "\\") {
421
+ index += 1;
422
+ continue;
423
+ }
424
+ if (char === quote) {
425
+ quote = null;
426
+ }
427
+ continue;
428
+ }
429
+ if (char === '"' || char === "'") {
430
+ quote = char;
431
+ continue;
432
+ }
433
+ if (char === ":") {
434
+ return index;
435
+ }
436
+ }
437
+ return -1;
438
+ }
358
439
  function parseScalar(value) {
359
440
  if (value === "null") return null;
360
441
  if (value === "true") return true;
@@ -363,8 +444,18 @@ function parseScalar(value) {
363
444
  return parseInlineArray(value);
364
445
  }
365
446
  if (/^-?\d+$/.test(value)) return Number.parseInt(value, 10);
366
- if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
367
- return value.slice(1, -1);
447
+ if (value.startsWith('"') && value.endsWith('"')) {
448
+ try {
449
+ const parsed = JSON.parse(value);
450
+ if (typeof parsed === "string") {
451
+ return parsed;
452
+ }
453
+ } catch {
454
+ throw new Error(`Invalid quoted workflow front matter scalar "${value}".`);
455
+ }
456
+ }
457
+ if (value.startsWith("'") && value.endsWith("'")) {
458
+ return value.slice(1, -1).replace(/''/g, "'");
368
459
  }
369
460
  return value;
370
461
  }
@@ -559,13 +650,13 @@ function readOptionalIntegerLike(input, key) {
559
650
  }
560
651
  throw new Error(`Workflow front matter field "${key}" must be an integer.`);
561
652
  }
562
- function readNumberMap(input, key) {
653
+ function readNumberMap(input, key, path = key) {
563
654
  const value = input[key];
564
655
  if (value === void 0 || value === null) {
565
656
  return {};
566
657
  }
567
658
  if (typeof value !== "object" || Array.isArray(value)) {
568
- throw new Error(`Workflow front matter field "${key}" must be an object.`);
659
+ throw new Error(`Workflow front matter field "${path}" must be an object.`);
569
660
  }
570
661
  const result = {};
571
662
  for (const [entryKey, entryValue] of Object.entries(value)) {
@@ -573,12 +664,12 @@ function readNumberMap(input, key) {
573
664
  result[entryKey] = entryValue;
574
665
  continue;
575
666
  }
576
- if (typeof entryValue === "string" && /^\d+$/.test(entryValue)) {
667
+ if (typeof entryValue === "string" && /^-?\d+$/.test(entryValue)) {
577
668
  result[entryKey] = Number.parseInt(entryValue, 10);
578
669
  continue;
579
670
  }
580
671
  throw new Error(
581
- `Workflow front matter field "${key}.${entryKey}" must be an integer.`
672
+ `Workflow front matter field "${path}.${entryKey}" must be an integer.`
582
673
  );
583
674
  }
584
675
  return result;
@@ -1542,31 +1633,176 @@ var SENSITIVE_KEY_SUBSTRINGS = [
1542
1633
  "api_key"
1543
1634
  ];
1544
1635
  function redactObservabilitySecrets(value) {
1545
- return redactValue(value);
1636
+ return redactObservabilitySecretsWithStats(value).value;
1637
+ }
1638
+ function redactObservabilitySecretsWithStats(value) {
1639
+ const counts = createRedactionCounts();
1640
+ const redacted = redactValue(value, counts, {
1641
+ redactStringValues: false
1642
+ });
1643
+ return { value: redacted, redactions: summarizeRedactionCounts(counts) };
1644
+ }
1645
+ function redactObservabilityDiagnosticsWithStats(value) {
1646
+ const counts = createRedactionCounts();
1647
+ const redacted = redactValue(value, counts, {
1648
+ redactStringValues: true
1649
+ });
1650
+ return { value: redacted, redactions: summarizeRedactionCounts(counts) };
1546
1651
  }
1547
- function redactValue(value) {
1652
+ function redactObservabilityTextWithStats(text) {
1653
+ const counts = createRedactionCounts();
1654
+ return {
1655
+ value: redactTextValue(text, counts),
1656
+ redactions: summarizeRedactionCounts(counts)
1657
+ };
1658
+ }
1659
+ function redactValue(value, counts, options) {
1548
1660
  if (Array.isArray(value)) {
1549
- return value.map((item) => redactValue(item));
1661
+ return value.map((item) => redactValue(item, counts, options));
1662
+ }
1663
+ if (typeof value === "string" && options.redactStringValues) {
1664
+ return redactTextValue(value, counts);
1550
1665
  }
1551
1666
  if (!isRecord3(value)) {
1552
1667
  return value;
1553
1668
  }
1554
1669
  return Object.fromEntries(
1555
- Object.entries(value).map(([key, nested]) => [
1556
- key,
1557
- shouldRedactKey(key) ? REDACTED : redactValue(nested)
1558
- ])
1670
+ Object.entries(value).map(([key, nested]) => {
1671
+ const redactionClass = redactionClassForKey(key);
1672
+ if (redactionClass) {
1673
+ incrementRedaction(counts, redactionClass);
1674
+ return [key, REDACTED];
1675
+ }
1676
+ return [key, redactValue(nested, counts, options)];
1677
+ })
1559
1678
  );
1560
1679
  }
1561
- function shouldRedactKey(key) {
1680
+ function redactionClassForKey(key) {
1562
1681
  const normalizedKey = key.toLowerCase();
1563
- return normalizedKey === "token" || normalizedKey.endsWith("token") || SENSITIVE_KEY_SUBSTRINGS.some(
1682
+ if (normalizedKey.includes("authorization")) {
1683
+ return "authorization_header";
1684
+ }
1685
+ if (normalizedKey.includes("apikey") || normalizedKey.includes("api-key") || normalizedKey.includes("api_key")) {
1686
+ return "api_key";
1687
+ }
1688
+ if (normalizedKey.includes("secret")) {
1689
+ return "secret_key";
1690
+ }
1691
+ if (normalizedKey === "token" || normalizedKey.endsWith("token")) {
1692
+ return "env_token";
1693
+ }
1694
+ if (SENSITIVE_KEY_SUBSTRINGS.some(
1564
1695
  (pattern) => normalizedKey.includes(pattern.toLowerCase())
1565
- );
1696
+ )) {
1697
+ return "secret_key";
1698
+ }
1699
+ return null;
1566
1700
  }
1567
1701
  function isRecord3(value) {
1568
1702
  return value != null && typeof value === "object";
1569
1703
  }
1704
+ function redactTextValue(text, counts) {
1705
+ let redacted = replaceAndCount(
1706
+ text,
1707
+ /\b(Authorization\s*:\s*Bearer\s+)([^\s]+)/gi,
1708
+ "authorization_header",
1709
+ counts,
1710
+ "$1[REDACTED]"
1711
+ );
1712
+ redacted = replaceAndCount(
1713
+ redacted,
1714
+ /\b(X-API-Key\s*:\s*)([^\s]+)/gi,
1715
+ "api_key",
1716
+ counts,
1717
+ "$1[REDACTED]"
1718
+ );
1719
+ redacted = replaceAndCount(
1720
+ redacted,
1721
+ /^([A-Z0-9_]*(?:TOKEN)\w*\s*=\s*)([^\s]+)/gim,
1722
+ "env_token",
1723
+ counts,
1724
+ "$1[REDACTED]"
1725
+ );
1726
+ redacted = replaceAndCount(
1727
+ redacted,
1728
+ /^([A-Z0-9_]*(?:API_KEY)\w*\s*=\s*)([^\s]+)/gim,
1729
+ "api_key",
1730
+ counts,
1731
+ "$1[REDACTED]"
1732
+ );
1733
+ redacted = replaceAndCount(
1734
+ redacted,
1735
+ /^([A-Z0-9_]*(?:SECRET)\w*\s*=\s*)([^\s]+)/gim,
1736
+ "secret_key",
1737
+ counts,
1738
+ "$1[REDACTED]"
1739
+ );
1740
+ redacted = replaceAndCount(
1741
+ redacted,
1742
+ /((?:"token"|'token'|token)\s*:\s*)(?:"([^"]*)"|'([^']*)'|([^\s,}\]]+))/gi,
1743
+ "env_token",
1744
+ counts,
1745
+ '$1"[REDACTED]"'
1746
+ );
1747
+ redacted = replaceAndCount(
1748
+ redacted,
1749
+ /((?:"secret"|'secret'|secret)\s*:\s*)(?:"([^"]*)"|'([^']*)'|([^\s,}\]]+))/gi,
1750
+ "secret_key",
1751
+ counts,
1752
+ '$1"[REDACTED]"'
1753
+ );
1754
+ redacted = replaceAndCount(
1755
+ redacted,
1756
+ /((?:"apiKey"|'apiKey'|apiKey)\s*:\s*)(?:"([^"]*)"|'([^']*)'|([^\s,}\]]+))/g,
1757
+ "api_key",
1758
+ counts,
1759
+ '$1"[REDACTED]"'
1760
+ );
1761
+ redacted = replaceAndCount(
1762
+ redacted,
1763
+ /\bghp_[A-Za-z0-9_]+/g,
1764
+ "env_token",
1765
+ counts,
1766
+ "[REDACTED]"
1767
+ );
1768
+ redacted = replaceAndCount(
1769
+ redacted,
1770
+ /\blin_[A-Za-z0-9_]+/g,
1771
+ "api_key",
1772
+ counts,
1773
+ "[REDACTED]"
1774
+ );
1775
+ redacted = replaceAndCount(
1776
+ redacted,
1777
+ /\bsk-[A-Za-z0-9_-]+/g,
1778
+ "api_key",
1779
+ counts,
1780
+ "[REDACTED]"
1781
+ );
1782
+ return redacted;
1783
+ }
1784
+ function replaceAndCount(text, pattern, redactionClass, counts, replacement) {
1785
+ return text.replace(pattern, (...args) => {
1786
+ const matched = typeof args[0] === "string" ? args[0] : "";
1787
+ if (matched.includes(REDACTED)) {
1788
+ return matched;
1789
+ }
1790
+ incrementRedaction(counts, redactionClass);
1791
+ return replacement.replace(/\$(\d+)/g, (_placeholder, index) => {
1792
+ const group = args[Number.parseInt(index, 10)];
1793
+ return typeof group === "string" ? group : "";
1794
+ });
1795
+ });
1796
+ }
1797
+ function createRedactionCounts() {
1798
+ return /* @__PURE__ */ new Map();
1799
+ }
1800
+ function incrementRedaction(counts, redactionClass) {
1801
+ counts.set(redactionClass, (counts.get(redactionClass) ?? 0) + 1);
1802
+ }
1803
+ function summarizeRedactionCounts(counts) {
1804
+ return Array.from(counts.entries()).filter(([, count]) => count > 0).map(([redactionClass, count]) => ({ class: redactionClass, count })).sort((left, right) => left.class.localeCompare(right.class));
1805
+ }
1570
1806
 
1571
1807
  // ../core/src/observability/status-assembler.ts
1572
1808
  function isMatchingIssueRun(run, issueId, issueIdentifier) {
@@ -6308,6 +6544,8 @@ export {
6308
6544
  isFileMissing,
6309
6545
  parseRecentEvents,
6310
6546
  redactObservabilitySecrets,
6547
+ redactObservabilityDiagnosticsWithStats,
6548
+ redactObservabilityTextWithStats,
6311
6549
  isMatchingIssueRun,
6312
6550
  mapIssueOrchestrationStateToStatus,
6313
6551
  resolveGitHubGraphQLToken,
@@ -106,6 +106,7 @@ export {
106
106
  REPO_RUNTIME_DIR,
107
107
  resolveConfigDir,
108
108
  configFilePath,
109
+ projectConfigPath,
109
110
  daemonPidPath,
110
111
  orchestratorLogPath,
111
112
  httpStatusPath,