@qvac/harness 0.2.8 → 0.2.10

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.
Files changed (76) hide show
  1. package/README.md +15 -7
  2. package/dist/harness.bundle +13 -12
  3. package/dist-lib/index.d.ts +2 -1
  4. package/dist-lib/index.js +2 -1
  5. package/dist-lib/lib/capabilities/completion.d.ts +36 -2
  6. package/dist-lib/lib/capabilities/completion.js +150 -27
  7. package/dist-lib/lib/connect.js +3 -1
  8. package/dist-lib/lib/contract-types.d.ts +2 -0
  9. package/dist-lib/lib/docx/index.js +4 -27
  10. package/dist-lib/lib/hooks/built-in/index.d.ts +1 -0
  11. package/dist-lib/lib/hooks/built-in/index.js +1 -0
  12. package/dist-lib/lib/hooks/built-in/sandbox.d.ts +5 -0
  13. package/dist-lib/lib/hooks/built-in/sandbox.js +43 -0
  14. package/dist-lib/lib/hooks/built-in/skill-catalog.js +7 -2
  15. package/dist-lib/lib/hooks/registry.js +2 -1
  16. package/dist-lib/lib/hooks/types.d.ts +1 -0
  17. package/dist-lib/lib/office/index.d.ts +6 -0
  18. package/dist-lib/lib/office/index.js +38 -0
  19. package/dist-lib/lib/office/pptx.d.ts +1 -0
  20. package/dist-lib/lib/office/pptx.js +26 -0
  21. package/dist-lib/lib/office/python.d.ts +7 -0
  22. package/dist-lib/lib/office/python.js +32 -0
  23. package/dist-lib/lib/office/xlsx.d.ts +1 -0
  24. package/dist-lib/lib/office/xlsx.js +26 -0
  25. package/dist-lib/lib/serve.js +1 -0
  26. package/dist-lib/lib/tools/edit-image.js +1 -1
  27. package/dist-lib/lib/tools/generate-image.js +1 -1
  28. package/dist-lib/lib/tools/generate-music.js +1 -1
  29. package/dist-lib/lib/tools/http-request.js +3 -3
  30. package/dist-lib/lib/tools/mcp-call.js +3 -3
  31. package/dist-lib/lib/tools/skill.js +4 -2
  32. package/dist-lib/lib/tools/skills/auth-resolver.d.ts +1 -0
  33. package/dist-lib/lib/tools/skills/auth-resolver.js +59 -29
  34. package/dist-lib/lib/tools/toolsets.d.ts +1 -0
  35. package/dist-lib/lib/tools/toolsets.js +1 -0
  36. package/dist-lib/lib/tools/weather-lookup.js +9 -3
  37. package/dist-lib/lib/tools/web-fetch.js +6 -3
  38. package/dist-lib/lib/tools/web-search.js +5 -2
  39. package/dist-lib/lib/wire.js +28 -0
  40. package/dist-lib/schema/harness.js +7 -3
  41. package/dist-lib/spec/hrpc/messages.js +28 -10
  42. package/dist-lib/spec/hyperschema/index.js +28 -10
  43. package/dist-lib/spec/hyperschema/schema.json +19 -1
  44. package/dist-lib/spec/hyperschema/types.d.ts +4 -2
  45. package/package.json +10 -6
  46. package/.claude/skills/asana/SKILL.md +0 -86
  47. package/.claude/skills/gh-stack/SKILL.md +0 -181
  48. package/.claude/skills/gh-stack/references/commands.md +0 -177
  49. package/.claude/skills/gh-stack/references/stack-design.md +0 -97
  50. package/.claude/skills/gh-stack/references/troubleshooting.md +0 -159
  51. package/.claude/skills/js-house-style/SKILL.md +0 -671
  52. package/.claude/skills/kvcache/SKILL.md +0 -171
  53. package/.claude/skills/pr-create/SKILL.md +0 -180
  54. package/.claude/skills/pr-review/SKILL.md +0 -414
  55. package/CLAUDE.md +0 -39
  56. package/docs/decisions/2026-05-29-kvcache-tool-turns.md +0 -75
  57. package/docs/decisions/2026-06-02-kvcache-tool-turns-reenabled.md +0 -127
  58. package/docs/decisions/2026-06-23-android-cpu-llm-defaults.md +0 -126
  59. package/docs/decisions/2026-07-29-assistant-owned-storage-layout.md +0 -88
  60. package/docs/decisions/2026-08-04-sidecar-orphan-reaping.md +0 -79
  61. package/docs/decisions/2026-08-11-pyodide-worker-thread.md +0 -68
  62. package/docs/decisions/2026-08-17-harness-hook-pipeline.md +0 -84
  63. package/docs/decisions/2026-08-17-harness-outbound-egress-guard.md +0 -176
  64. package/docs/decisions/2026-08-20-chat-prompt-prefix-is-stable.md +0 -95
  65. package/docs/decisions/2026-08-20-kvcache-static-placement.md +0 -109
  66. package/docs/decisions/2026-08-21-vendored-python-wheels.md +0 -85
  67. package/docs/decisions/2026-08-26-exec-is-not-gated-by-skills.md +0 -64
  68. package/docs/decisions/2026-08-27-writable-skills-overlay.md +0 -56
  69. package/docs/decisions/2026-09-01-skill-operation-manifests.md +0 -53
  70. package/docs/decisions/2026-09-01-usage-breakdown-is-measured.md +0 -78
  71. package/docs/decisions/2026-09-03-usage-breakdown-reported-by-the-harness.md +0 -136
  72. package/docs/decisions/2026-09-10-skill-wording-is-measured-offline.md +0 -63
  73. package/docs/decisions/2026-09-16-a-lookup-reports-the-place-it-resolved.md +0 -70
  74. package/docs/decisions/INDEX.md +0 -40
  75. package/docs/decisions/TEMPLATE.md +0 -32
  76. package/docs/kvcache-reference.md +0 -655
@@ -1,12 +1,12 @@
1
1
  // This file is autogenerated by the hyperschema compiler
2
- // Schema Version: 8
2
+ // Schema Version: 10
3
3
  /* eslint-disable camelcase */
4
4
  /* eslint-disable quotes */
5
5
  /* eslint-disable space-before-function-paren */
6
6
 
7
7
  import { c } from 'hyperschema/runtime'
8
8
 
9
- const VERSION = 8
9
+ const VERSION = 10
10
10
 
11
11
  // eslint-disable-next-line no-unused-vars
12
12
  let version = VERSION
@@ -143,7 +143,8 @@ const encoding4 = {
143
143
  (m.imageWidth ? 8192 : 0) |
144
144
  (m.imageHeight ? 16384 : 0) |
145
145
  ((version >= 5 && m.approvalMode) ? 32768 : 0) |
146
- ((version >= 5 && m.disabledToolsets) ? 65536 : 0)
146
+ ((version >= 5 && m.disabledToolsets) ? 65536 : 0) |
147
+ ((version >= 10 && m.sandboxMode) ? 131072 : 0)
147
148
 
148
149
  c.uint.preencode(state, flags)
149
150
 
@@ -183,7 +184,8 @@ const encoding4 = {
183
184
  (m.imageWidth ? 8192 : 0) |
184
185
  (m.imageHeight ? 16384 : 0) |
185
186
  ((version >= 5 && m.approvalMode) ? 32768 : 0) |
186
- ((version >= 5 && m.disabledToolsets) ? 65536 : 0)
187
+ ((version >= 5 && m.disabledToolsets) ? 65536 : 0) |
188
+ ((version >= 10 && m.sandboxMode) ? 131072 : 0)
187
189
 
188
190
  c.uint.encode(state, flags)
189
191
 
@@ -225,7 +227,8 @@ const encoding4 = {
225
227
  imageWidth: (flags & 8192) !== 0 ? c.uint.decode(state) : 0,
226
228
  imageHeight: (flags & 16384) !== 0 ? c.uint.decode(state) : 0,
227
229
  approvalMode: (version >= 5 && (flags & 32768) !== 0) ? encoding59.decode(state) : null,
228
- disabledToolsets: (version >= 5 && (flags & 65536) !== 0) ? encoding4_16.decode(state) : null
230
+ disabledToolsets: (version >= 5 && (flags & 65536) !== 0) ? encoding4_16.decode(state) : null,
231
+ sandboxMode: (version >= 10 && (flags & 131072) !== 0)
229
232
  }
230
233
  }
231
234
  }
@@ -478,7 +481,8 @@ const encoding11 = {
478
481
  ((version >= 5 && m.grantedDirs) ? 2097152 : 0) |
479
482
  ((version >= 5 && m.grantedDrives) ? 4194304 : 0) |
480
483
  ((version >= 5 && m.payload) ? 8388608 : 0) |
481
- ((version >= 5 && m.grantedWriteDirs) ? 16777216 : 0)
484
+ ((version >= 5 && m.grantedWriteDirs) ? 16777216 : 0) |
485
+ ((version >= 9 && m.captureInferenceCalls) ? 33554432 : 0)
482
486
 
483
487
  encoding10.preencode(state, m.type)
484
488
  c.uint.preencode(state, flags)
@@ -533,7 +537,8 @@ const encoding11 = {
533
537
  ((version >= 5 && m.grantedDirs) ? 2097152 : 0) |
534
538
  ((version >= 5 && m.grantedDrives) ? 4194304 : 0) |
535
539
  ((version >= 5 && m.payload) ? 8388608 : 0) |
536
- ((version >= 5 && m.grantedWriteDirs) ? 16777216 : 0)
540
+ ((version >= 5 && m.grantedWriteDirs) ? 16777216 : 0) |
541
+ ((version >= 9 && m.captureInferenceCalls) ? 33554432 : 0)
537
542
 
538
543
  encoding10.encode(state, m.type)
539
544
  c.uint.encode(state, flags)
@@ -592,7 +597,8 @@ const encoding11 = {
592
597
  grantedDirs: (version >= 5 && (flags & 2097152) !== 0) ? encoding11_22.decode(state) : null,
593
598
  grantedDrives: (version >= 5 && (flags & 4194304) !== 0) ? encoding11_23.decode(state) : null,
594
599
  payload: (version >= 5 && (flags & 8388608) !== 0) ? c.json.decode(state) : null,
595
- grantedWriteDirs: (version >= 5 && (flags & 16777216) !== 0) ? encoding11_25.decode(state) : null
600
+ grantedWriteDirs: (version >= 5 && (flags & 16777216) !== 0) ? encoding11_25.decode(state) : null,
601
+ captureInferenceCalls: (version >= 9 && (flags & 33554432) !== 0)
596
602
  }
597
603
  }
598
604
  }
@@ -613,13 +619,15 @@ const encoding12_enum = {
613
619
  "question-ask": 'question-ask',
614
620
  done: 'done',
615
621
  "tool-activity": 'tool-activity',
616
- "drive-ask": 'drive-ask'
622
+ "drive-ask": 'drive-ask',
623
+ "inference-call": 'inference-call',
624
+ "inference-sent": 'inference-sent'
617
625
  }
618
626
 
619
627
  // @harness/completion-event-type enum
620
628
  const encoding12 = {
621
629
  preencode (state, m) {
622
- state.end++ // max enum is 16 so always one byte
630
+ state.end++ // max enum is 18 so always one byte
623
631
  },
624
632
  encode (state, m) {
625
633
  switch (m) {
@@ -671,6 +679,12 @@ const encoding12 = {
671
679
  case 'drive-ask':
672
680
  c.uint.encode(state, 16)
673
681
  break
682
+ case 'inference-call':
683
+ c.uint.encode(state, 17)
684
+ break
685
+ case 'inference-sent':
686
+ c.uint.encode(state, 18)
687
+ break
674
688
  default:
675
689
  throw new Error('Unknown enum')
676
690
  }
@@ -709,6 +723,10 @@ const encoding12 = {
709
723
  return 'tool-activity'
710
724
  case 16:
711
725
  return 'drive-ask'
726
+ case 17:
727
+ return 'inference-call'
728
+ case 18:
729
+ return 'inference-sent'
712
730
  default: return null
713
731
  }
714
732
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 8,
2
+ "version": 10,
3
3
  "schema": [
4
4
  {
5
5
  "name": "empty",
@@ -151,6 +151,11 @@
151
151
  "array": true,
152
152
  "type": "string",
153
153
  "version": 5
154
+ },
155
+ {
156
+ "name": "sandboxMode",
157
+ "type": "bool",
158
+ "version": 10
154
159
  }
155
160
  ]
156
161
  },
@@ -446,6 +451,11 @@
446
451
  "array": true,
447
452
  "type": "string",
448
453
  "version": 5
454
+ },
455
+ {
456
+ "name": "captureInferenceCalls",
457
+ "type": "bool",
458
+ "version": 9
449
459
  }
450
460
  ]
451
461
  },
@@ -517,6 +527,14 @@
517
527
  {
518
528
  "key": "drive-ask",
519
529
  "version": 5
530
+ },
531
+ {
532
+ "key": "inference-call",
533
+ "version": 9
534
+ },
535
+ {
536
+ "key": "inference-sent",
537
+ "version": 9
520
538
  }
521
539
  ],
522
540
  "strings": true
@@ -1,5 +1,5 @@
1
1
  // This file is autogenerated by hyperschema-ts
2
- // Schema version: 8
2
+ // Schema version: 10
3
3
  // Do not edit manually.
4
4
 
5
5
  export interface HarnessEmpty {
@@ -31,6 +31,7 @@ export interface HarnessAgentKnobs {
31
31
  imageHeight?: number
32
32
  approvalMode?: HarnessApprovalMode | null
33
33
  disabledToolsets?: string[] | null
34
+ sandboxMode?: boolean
34
35
  }
35
36
 
36
37
  export type HarnessMessageRole = "system" | "user" | "assistant" | "tool"
@@ -86,9 +87,10 @@ export interface HarnessCompletionFrame {
86
87
  grantedDrives?: HarnessGrantedDrive[] | null
87
88
  payload?: unknown | null
88
89
  grantedWriteDirs?: string[] | null
90
+ captureInferenceCalls?: boolean
89
91
  }
90
92
 
91
- export type HarnessCompletionEventType = "content" | "thinking" | "tool-call" | "tool-result" | "approval-ask" | "metrics" | "error" | "aborted" | "attach-ask" | "fetch-ask" | "progress" | "rag-ask" | "question-ask" | "done" | "tool-activity" | "drive-ask"
93
+ export type HarnessCompletionEventType = "content" | "thinking" | "tool-call" | "tool-result" | "approval-ask" | "metrics" | "error" | "aborted" | "attach-ask" | "fetch-ask" | "progress" | "rag-ask" | "question-ask" | "done" | "tool-activity" | "drive-ask" | "inference-call" | "inference-sent"
92
94
 
93
95
  export interface HarnessCompletionEvent {
94
96
  type: HarnessCompletionEventType
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/harness",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "type": "module",
5
5
  "description": "An AI harness implementing generate(context) via @qvac/sdk. Knows nothing about workbench, hyperdb, or chunks — just inference in, events out.",
6
6
  "exports": {
@@ -12,6 +12,10 @@
12
12
  "types": "./dist-lib/lib/docx/index.d.ts",
13
13
  "default": "./dist-lib/lib/docx/index.js"
14
14
  },
15
+ "./office": {
16
+ "types": "./dist-lib/lib/office/index.d.ts",
17
+ "default": "./dist-lib/lib/office/index.js"
18
+ },
15
19
  "./lib/dns-lookup.ts": {
16
20
  "types": "./dist-lib/lib/dns-lookup.d.ts",
17
21
  "default": "./dist-lib/lib/dns-lookup.js"
@@ -555,9 +559,8 @@
555
559
  },
556
560
  "scripts": {
557
561
  "build:schema": "bare schema/build.ts",
558
- "test": "npm run vendor:wheels && npm run test:node && npm run test:bare && npm run test:addons",
559
- "test:node": "QVAC_NO_SKILL_BIN_PROBE=1 brittle-node test/all.ts | prettytap",
560
- "test:bare": "QVAC_NO_SKILL_BIN_PROBE=1 brittle-bare test/all.ts | prettytap",
562
+ "test": "npm run vendor:wheels && npm run test:bare && npm run test:addons",
563
+ "test:bare": "QVAC_NO_SKILL_BIN_PROBE=1 prettytap -- brittle-bare test/all.ts",
561
564
  "format": "prettier . --write",
562
565
  "lint": "prettier . --check && lunte && tsc --noEmit",
563
566
  "build:bundle": "node scripts/build-bundle.mjs",
@@ -714,7 +717,7 @@
714
717
  "lunte": "^1.8.3",
715
718
  "prettier": "^3.6.2",
716
719
  "prettier-config-holepunch": "^2.0.0",
717
- "prettytap": "^0.1.3",
720
+ "prettytap": "^0.2.0",
718
721
  "terser": "^5.51.2",
719
722
  "typescript": "^7.0.2"
720
723
  },
@@ -724,7 +727,8 @@
724
727
  "localwatch@1.4.3": "patches/localwatch@1.4.3.patch",
725
728
  "hypercore-blob-server@1.15.0": "patches/hypercore-blob-server@1.15.0.patch",
726
729
  "bare-stow@0.1.5": "patches/bare-stow@0.1.5.patch",
727
- "@qvac/inference@0.19.0": "patches/@qvac%2Finference@0.19.0.patch"
730
+ "@qvac/inference@0.19.0": "patches/@qvac%2Finference@0.19.0.patch",
731
+ "brittle@4.1.0": "patches/brittle@4.1.0.patch"
728
732
  },
729
733
  "repository": {
730
734
  "type": "git",
@@ -1,86 +0,0 @@
1
- ---
2
- name: asana
3
- description: Conventions for the QVAC Assistant Asana board when working through the Asana MCP server — what the MCP cannot do and what that silently breaks, the Context field that decides whether a task is visible at all, and the rule against consuming task descriptions. Use before creating, moving, or reading any Asana task for this project.
4
- ---
5
-
6
- # Asana — QVAC Assistant board
7
-
8
- Asana work here goes through the **Asana MCP server**. This skill is not a tool;
9
- it is the handful of things the MCP does not tell you and will not stop you
10
- getting wrong.
11
-
12
- - Workspace `45238840754660` (tether.to)
13
- - Project `1214754188814246` (QVAC Assistant)
14
- - Board: <https://app.asana.com/1/45238840754660/project/1214754188814246>
15
-
16
- ## Do not create tasks through the MCP
17
-
18
- `asana_create_task` takes `resource_subtype` of only `default_task`, `milestone`
19
- or `approval`, and neither it nor `asana_update_task` accepts `custom_type` or
20
- `custom_type_status_option`. This board runs on the **QVAC Basic Task** custom
21
- type (`1214533632534265`), whose status options _are_ the workflow — the project
22
- has one real section and tracks status entirely through the custom type.
23
-
24
- So an MCP-created task is a plain default task that:
25
-
26
- - is not a `QVAC Basic Task`,
27
- - has no status (To Do / In Progress / In Code Review / Blocked /
28
- Completed-Ready for QA / Fully Verified / Closed-Won't Fix), and
29
- - cannot be given one afterwards through the API.
30
-
31
- It lands on the board looking almost right and is undriveable. **Ask the user to
32
- create the task in the Asana UI**, where the custom type is the default, and then
33
- use the MCP to fill fields or comment on it. Do not create it yourself and
34
- promise to "fix the type later" — the API has no route to do that.
35
-
36
- Moving a task's status has the same limitation: the status lives on
37
- `custom_type_status_option`, which the MCP cannot set. Status changes are a UI
38
- action.
39
-
40
- ## Context is mandatory, and the MCP will not warn you
41
-
42
- The project's Dev Board tabs are saved views filtered on the **Context** custom
43
- field. A task with Context unset appears only in "Full List" and "Overview" — it
44
- is invisible on every Dev Board tab and silently slips off the team's radar.
45
-
46
- Whenever you set fields on a task, set Context. Field `1214754188814251`:
47
-
48
- | Value | GID | For |
49
- | -------------- | ------------------ | ------------------------------------------------- |
50
- | `harness` | `1214754188814252` | engine, mesh and sync, storage, build and release |
51
- | `integrations` | `1214754188814253` | assistant runtime, agents, tools, skills |
52
- | `other` | `1214758268571416` | genuinely cross-cutting: org, legal, product docs |
53
-
54
- Surface which one you picked and why, and let the user correct it. Never guess
55
- silently, and never leave it blank to avoid choosing.
56
-
57
- ## Release grouping
58
-
59
- Each Dev Board tab groups by **QVAC Workbench Release** (field
60
- `1214111405360914`) first. A task with none lands in an "Untitled" bucket at the
61
- bottom of every tab. Default to `tbc` (`1214757840453965`) when the release is
62
- undecided.
63
-
64
- **That field is the app's release, not a package version.** `@qvac/harness`,
65
- `@qvac/core` and `@qvac/skills` each ship their own `0.x` line; putting one of
66
- those numbers here files the task against a release that does not exist.
67
-
68
- ## Never consume task descriptions
69
-
70
- Work from task metadata only: GID, name, permalink, completion state, assignee,
71
- memberships, custom fields, custom type and status, timestamps, and comments.
72
-
73
- - `asana_get_task` returns the description by default. Pass an explicit
74
- `opt_fields` list that omits `notes`, `html_notes` and `description`.
75
- - Do not use Asana full-text search as a fallback — it matches descriptions.
76
- Find tasks by the QVAC custom field (`1209150993228635`, text) or by GID.
77
- - If the user wants you to act on a description, ask them to paste the relevant
78
- excerpt rather than fetching it.
79
-
80
- ## Before any mutation
81
-
82
- Show the exact change and wait for a yes. That includes field edits, comments and
83
- completion — this board is shared with the whole team, and a comment cannot be
84
- unsent.
85
-
86
- Never put tokens, secrets or internal-only URLs in a task or comment.
@@ -1,181 +0,0 @@
1
- ---
2
- name: gh-stack
3
- description: >
4
- Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack.
5
- Use for stack creation, viewing, edits, push, submit, sync, rebase, merge, or checkout;
6
- when asked to split or isolate work for review; whenever a user mentions a stack,
7
- branch layers, dependent PRs, or gh stack; or when a stack is checked out.
8
- metadata:
9
- author: github
10
- version: '0.1.0'
11
- ---
12
-
13
- # gh-stack
14
-
15
- `gh stack` is a [GitHub CLI](https://cli.github.com/) extension for stacked branches and pull
16
- requests. A stack is an ordered chain of branches rooted on a trunk, where each branch has one PR
17
- based on the branch below it, so a reviewer sees only that layer's diff.
18
-
19
- `gh stack` prints a stack trunk-first, left to right:
20
-
21
- ```
22
- (main) <- auth <- api <- frontend
23
- ```
24
-
25
- Left is the **bottom**, right is the **top**. `auth` is based on `main` and merges first;
26
- `frontend` merges last. `up` moves toward the top, away from trunk; `down` moves toward it.
27
- Foundational work belongs at the bottom, code that depends on it above. For how to choose the
28
- layers, read `references/stack-design.md`.
29
-
30
- ## Setup
31
-
32
- ```bash
33
- gh extension install github/gh-stack
34
- git config rerere.enabled true # remember conflict resolutions
35
- git config remote.pushDefault origin # required if the repo has more than one remote
36
- ```
37
-
38
- ## Non-interactive use
39
-
40
- `gh stack` branches on whether **stdout is a TTY**. Piped, most commands error cleanly or print
41
- static text; under a PTY the same commands open a prompt or a full-screen TUI and block forever.
42
- Agent harnesses differ, so always pass the flags below instead of relying on that detection.
43
-
44
- **Multiple remotes:** never run `push`, `submit`, `sync`, `rebase`, or `link` without
45
- `--remote <name>` unless `remote.pushDefault` is configured. `checkout` and `trunk` have no
46
- `--remote` flag and require the config.
47
-
48
- | Always run | Never run bare | Why |
49
- | ----------------------------------------- | ------------------- | --------------------------------------------- |
50
- | `gh stack view --json` | `gh stack view` | opens a TUI under a PTY |
51
- | `gh stack submit --auto` | `gh stack submit` | prompts for a title per new PR |
52
- | `gh stack merge <target> --yes` | `gh pr merge` | `gh pr merge` cannot merge a stack |
53
- | `gh stack init <branch>...` | `gh stack init` | prompts for branch names |
54
- | `gh stack add <branch>` | `gh stack add` | prompts for a name, and fails even when piped |
55
- | `gh stack checkout <target>` | `gh stack checkout` | opens a selection menu |
56
- | `gh stack up` / `down` / `top` / `bottom` | `gh stack switch` | `switch` is menu-only |
57
- | — | `gh stack modify` | TUI-only, no non-interactive path |
58
-
59
- - `view --short` is safe in both modes, but it is formatted for humans. Use `--json` to parse.
60
- - **`checkout <pr>` when a different local stack already covers those branches** cannot be forced.
61
- Run `gh stack unstack --local` first (this keeps the stack on GitHub), then retry.
62
-
63
- ## Branch placement
64
-
65
- - **Starting multi-part work:** create the stack before writing files. Do not implement every
66
- concern on trunk and split it later. Put one dependent concern in each layer, bottom to top.
67
- - **Editing an existing stack:** check out the layer that owns the change before editing. Never
68
- commit a lower layer's concern on the current top branch. Run `gh stack view --json`; if
69
- ownership is unclear, inspect `git log --all -- <path>`. Then check out the owner, edit, commit,
70
- rebase upstack, and return to top.
71
-
72
- ```bash
73
- gh stack down # or: gh stack checkout api
74
- git add ... && git commit -m "Add get-user endpoint"
75
- gh stack rebase --upstack # replay every branch above onto the change
76
- gh stack top # return to where you were
77
- gh stack push
78
- ```
79
-
80
- ## Core loop
81
-
82
- ```bash
83
- gh stack init auth # create the stack and check out its branch
84
- git add ... && git commit -m "Add auth middleware"
85
- gh stack add api # next layer, branched from the current one
86
- git add ... && git commit -m "Add API routes"
87
- gh stack submit --auto # push every branch and open draft PRs
88
- gh stack view --json # confirm
89
- ```
90
-
91
- Add `--open` to `submit` to create PRs ready for review instead of drafts. Branch names are
92
- verbatim — `gh stack add refactor/foo` creates `refactor/foo`.
93
-
94
- ## Staying in sync
95
-
96
- ```bash
97
- gh stack sync # fetch, reconcile with GitHub, rebase, push, refresh PR state
98
- gh stack sync --prune # also delete local branches for merged PRs
99
- ```
100
-
101
- Pruning never happens without `--prune` when non-interactive. If the local and remote stacks have
102
- diverged, `sync` prints both chains, makes no changes, and exits 0 with `Sync aborted` — see
103
- `references/troubleshooting.md`.
104
-
105
- ## Merging
106
-
107
- Scope the merge with an argument:
108
-
109
- ```bash
110
- gh stack merge 42 --yes # PR #42 plus every unmerged PR below it
111
- gh stack merge 7 --yes # every unmerged PR in stack #7
112
- gh stack merge 42 --yes --squash # or --merge, --rebase, --merge-method <method>
113
- ```
114
-
115
- Pass a PR number to merge that PR and every unmerged PR below it, or a stack number to merge every
116
- unmerged PR in that stack. The operation is all-or-nothing: if any PR in that set cannot merge,
117
- none do.
118
-
119
- Without a method flag the last-used method is reused. If the base branch uses a merge queue, the
120
- stack is queued instead and the queue picks the method, ignoring any flag you passed with a
121
- warning; queued PRs may land in separate groups.
122
-
123
- ## Reading state
124
-
125
- `gh stack view --json` writes JSON to **stdout**. Status messages go to **stderr** — do not parse
126
- them, branch on exit codes instead.
127
-
128
- ```
129
- trunk string
130
- currentBranch string
131
- branches[] name, head, base, isCurrent, isMerged, isQueued, needsRebase
132
- branches[].pr number, url, state ("OPEN" | "MERGED" | "QUEUED"); absent when no PR exists
133
- ```
134
-
135
- `base` is the saved SHA of the parent branch that this branch was last known to contain. It may be
136
- older than the parent's current tip. `needsRebase` is true when the current parent tip is no longer
137
- an ancestor of the branch.
138
-
139
- ## Exit codes
140
-
141
- | Code | Meaning | Recovery |
142
- | ---- | -------------------------- | ---------------------------------------------------------- |
143
- | 0 | Success | — |
144
- | 1 | Generic error | Read stderr |
145
- | 2 | Not in a stack | `gh stack init`, or `gh stack checkout <target>` |
146
- | 3 | Rebase conflict | Follow the Exit 3 recovery below |
147
- | 4 | GitHub API failure | Check `gh auth status`, retry |
148
- | 5 | Invalid arguments | Fix the invocation; see `<command> --help` |
149
- | 6 | Disambiguation required | Branch is in several stacks; check out a non-shared branch |
150
- | 7 | Rebase already in progress | `gh stack rebase --continue` or `--abort` |
151
- | 8 | Stack file locked | Another `gh stack` process is writing; retry after ~5s |
152
- | 9 | Stacked PRs unavailable | Not enabled on the repository; tell the user |
153
- | 10 | Modify recovery required | `gh stack modify --abort` |
154
-
155
- **Exit 3 recovery:**
156
-
157
- - After `gh stack rebase`: resolve the files, run `git add`, then
158
- `gh stack rebase --continue`; use `gh stack rebase --abort` to restore the stack.
159
- - After `gh stack sync`: the stack has already been restored. Run `gh stack rebase` to recreate the
160
- conflict, then resolve and continue as above.
161
-
162
- ## Constraints
163
-
164
- - Stacks are strictly linear: one parent, at most one child. Use separate stacks for parallel work.
165
- - There is no non-interactive reorder or removal. Errors may suggest `gh stack modify`, but it is
166
- TUI-only — restructure with `unstack` then `init` instead.
167
- - PR titles and bodies are auto-generated. Use `gh pr edit` afterwards to change them.
168
-
169
- ## More detail
170
-
171
- `gh stack <command> --help` is authoritative for flags and arguments. Note that
172
- `gh stack help <command>` does **not** work — it prints the top-level help.
173
-
174
- Open the reference whose trigger matches the task; no need to preload all three.
175
-
176
- - `references/stack-design.md` — read before creating a stack, when deciding how many layers to
177
- use, what belongs in each one, or whether work belongs in a new stack.
178
- - `references/commands.md` — read when a command fails unexpectedly or you need its preconditions,
179
- side effects, atomicity, or ordering guarantees.
180
- - `references/troubleshooting.md` — read on a rebase conflict, after a squash-merge, on local and
181
- remote divergence, when restructuring a stack, or when driving stacks from another tool.