@xingular/harness 1.3.1-unstable.8 → 1.4.0-unstable

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 (101) hide show
  1. package/CHANGELOG.md +122 -5
  2. package/NOTICE.md +26 -0
  3. package/builtin/skills/plugin-authoring/SKILL.md +20 -1
  4. package/dist/cli.js +2424 -1237
  5. package/dist/sdk/accounts/accounts.d.ts +26 -20
  6. package/dist/sdk/accounts/accounts.js +100 -63
  7. package/dist/sdk/agents/builtin.js +2 -0
  8. package/dist/sdk/commands/registry.d.ts +7 -0
  9. package/dist/sdk/commands/registry.js +1 -0
  10. package/dist/sdk/core/commandBudget.js +7 -2
  11. package/dist/sdk/core/workspaceWriteOperations.d.ts +24 -0
  12. package/dist/sdk/core/workspaceWriteOperations.js +21 -0
  13. package/dist/sdk/plugins/builtin.js +0 -4
  14. package/dist/sdk/plugins/discover.js +80 -4
  15. package/dist/sdk/plugins/install.js +26 -0
  16. package/dist/sdk/plugins/manifest.d.ts +2 -0
  17. package/dist/sdk/plugins/manifest.js +20 -1
  18. package/dist/sdk/prompt/compile.d.ts +4 -1
  19. package/dist/sdk/prompt/compile.js +8 -21
  20. package/dist/sdk/prompt/reporting.d.ts +2 -0
  21. package/dist/sdk/prompt/reporting.js +282 -0
  22. package/dist/sdk/prompt/standard.d.ts +12 -0
  23. package/dist/sdk/prompt/standard.js +53 -2
  24. package/dist/sdk/sessions/checkpoint.d.ts +7 -0
  25. package/dist/sdk/sessions/checkpoint.js +41 -0
  26. package/dist/sdk/sessions/compactionCheckpoint.d.ts +2 -0
  27. package/dist/sdk/sessions/compactionCheckpoint.js +2 -1
  28. package/dist/sdk/sessions/completionCheck.d.ts +49 -0
  29. package/dist/sdk/sessions/completionCheck.js +143 -0
  30. package/dist/sdk/sessions/continuation.js +1 -1
  31. package/dist/sdk/sessions/contracts.d.ts +97 -1
  32. package/dist/sdk/sessions/contracts.js +17 -0
  33. package/dist/sdk/sessions/goal.d.ts +145 -0
  34. package/dist/sdk/sessions/goal.js +405 -0
  35. package/dist/sdk/sessions/goalLoop.d.ts +37 -0
  36. package/dist/sdk/sessions/goalLoop.js +125 -0
  37. package/dist/sdk/sessions/goalPrompts.d.ts +4 -0
  38. package/dist/sdk/sessions/goalPrompts.js +93 -0
  39. package/dist/sdk/sessions/planMode.d.ts +31 -0
  40. package/dist/sdk/sessions/planMode.js +48 -3
  41. package/dist/sdk/sessions/registry.d.ts +6 -1
  42. package/dist/sdk/sessions/registry.js +4 -4
  43. package/dist/sdk/sessions/runStore.js +1 -0
  44. package/dist/sdk/sessions/runner.d.ts +9 -0
  45. package/dist/sdk/sessions/runner.js +65 -13
  46. package/dist/sdk/sessions/sessions.d.ts +10 -0
  47. package/dist/sdk/sessions/sessions.js +87 -10
  48. package/dist/sdk/sessions/stopGate.d.ts +78 -0
  49. package/dist/sdk/sessions/stopGate.js +143 -0
  50. package/dist/sdk/sessions/subagentService.d.ts +2 -0
  51. package/dist/sdk/sessions/subagentService.js +1 -1
  52. package/dist/sdk/sessions/workSlice.d.ts +61 -12
  53. package/dist/sdk/sessions/workSlice.js +102 -33
  54. package/dist/sdk/terminal/controller.d.ts +2 -2
  55. package/dist/sdk/terminal/controller.js +14 -4
  56. package/dist/sdk/terminal/credentialStore.d.ts +4 -0
  57. package/dist/sdk/terminal/credentialStore.js +33 -0
  58. package/dist/sdk/terminal/piExtension.d.ts +2 -1
  59. package/dist/sdk/terminal/piExtension.js +160 -27
  60. package/dist/sdk/terminal/terminals.js +27 -4
  61. package/dist/sdk/terminal/tui/commands.d.ts +2 -0
  62. package/dist/sdk/terminal/tui/commands.js +3 -0
  63. package/dist/sdk/terminal/tui/goalCommand.d.ts +19 -0
  64. package/dist/sdk/terminal/tui/goalCommand.js +83 -0
  65. package/dist/sdk/terminal/tui/planMode.d.ts +1 -1
  66. package/dist/sdk/terminal/tui/planMode.js +1 -1
  67. package/dist/sdk/terminal/tui/runtime.d.ts +3 -0
  68. package/dist/sdk/terminal/tui/runtime.js +21 -4
  69. package/dist/sdk/tools/askUser.js +1 -1
  70. package/dist/sdk/tools/todo.js +2 -1
  71. package/dist/terminal-opentui.js +1740 -627
  72. package/dist/terminal-pi.js +996 -407
  73. package/docs/architecture/02-sessions-and-runs.md +47 -11
  74. package/docs/architecture/04-prompt.md +83 -16
  75. package/docs/architecture/06-plugins-and-capabilities.md +16 -1
  76. package/docs/architecture/07-tools-and-gate.md +7 -2
  77. package/docs/architecture/09-accounts-and-connectors.md +9 -0
  78. package/docs/architecture/10-server-protocol.md +13 -0
  79. package/docs/architecture/11-terminal.md +38 -12
  80. package/docs/architecture/proposals/PROP-0041-bounded-work-slices.md +2 -0
  81. package/docs/decisions/ADR-0008-flexible-reporting-guidance.md +3 -0
  82. package/docs/decisions/ADR-0063-unfinished-work-handoffs.md +2 -0
  83. package/docs/decisions/ADR-0068-scope-and-completion-report.md +60 -0
  84. package/docs/decisions/ADR-0069-stop-gate-and-finish.md +130 -0
  85. package/docs/decisions/ADR-0070-terminal-slice-continuation.md +46 -0
  86. package/docs/decisions/ADR-0071-completion-check.md +104 -0
  87. package/docs/decisions/ADR-0072-codex-prompts-and-goal.md +105 -0
  88. package/docs/decisions/ADR-0073-large-reporting-prompt.md +84 -0
  89. package/docs/parity.md +4 -1
  90. package/docs/releases/1.3.1-unstable.9.md +54 -0
  91. package/docs/releases/1.4.0-unstable.md +18 -0
  92. package/docs/releases/README.md +1 -1
  93. package/docs/study/00-index.md +10 -0
  94. package/docs/study/STUDY-0004-turn-end-controls.md +123 -0
  95. package/docs/study/STUDY-0005-skill-installation-guidance.md +146 -0
  96. package/docs/study/STUDY-0006-reporting-prompts.md +81 -0
  97. package/docs/study/arms/04-skills.md +6 -0
  98. package/docs/terminal-tui.md +17 -7
  99. package/package.json +1 -1
  100. package/dist/sdk/tools/checkpoint.d.ts +0 -27
  101. package/dist/sdk/tools/checkpoint.js +0 -154
package/CHANGELOG.md CHANGED
@@ -2,6 +2,123 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - **A large, content-block reporting prompt (ADR-0073).**
6
+ - The `reporting` section in `src/prompt/reporting.ts` is about 15.8k characters: outcome first,
7
+ required what-changed / how-to-test / what-to-do-next blocks for a change, optional beyond,
8
+ departures, unverified and open-question blocks, five worked examples and an anti-pattern table.
9
+ - Headings are the model's choice; the three fixed headings from ADR-0068 are gone.
10
+ - `REPORTING_BUDGET` rises to 18,000, and the section is never cut.
11
+ - The peer study is `docs/study/STUDY-0006-reporting-prompts.md`.
12
+ - **Skill installation guidance and package skill layouts.**
13
+ - The release-owned `plugin-authoring` skill now says where a skill is installed (a project's
14
+ `.pi/skills` and `.agents/skills`, the user's `~/.agents/skills`, the shared state folder), to
15
+ copy a whole skill folder, and that `.claude/skills` is never read. It also says which installs
16
+ only a person commits, and that `plugin_propose` is not an install route.
17
+ - `plugins.install` refuses a GitHub or GitLab `tree`/`blob` page address with the repository
18
+ address and the skill routes, instead of a raw git error.
19
+ - A package's foreign plugin manifest (`plugin.json`, `.claude-plugin/plugin.json`,
20
+ `.codex-plugin/plugin.json`) may declare `skills`; those folders load as package skills, under
21
+ the package's switch and filter.
22
+
23
+ - **Codex's prompts and `/goal`; the completion check moves behind `/goal` (ADR-0072).**
24
+ - **Ordinary replies.** No model-judged check runs on them. The todo gate stays and says the list
25
+ is progress, not the limit of the work; `TODO_GUIDANCE` now says the request is the scope.
26
+ - **Prompt.** A person's own session reads Codex's autonomy and persistence, when-to-ask,
27
+ steering and compaction, and writing-style rules as separate sections, and a longer reporting
28
+ section: unfinished work says so on the first line, with the reason and the next step.
29
+ `ask_user` is never used to ask permission, and no answer means continue.
30
+ - **Failures from outside the session.** A test or error that does not come from the session's
31
+ work is reported with its command and output, not fixed, unless the person asks. It stays off
32
+ the todo list, and it is a reason to stop that the autonomy rules name.
33
+ - **`/goal <objective>`.** A long run the person starts. Codex's `get_goal` and `update_goal`,
34
+ continuation, round-cap and edit prompts, `blocked` after the same blocker on three turns, and
35
+ brakes for idle, failing and erroring rounds. `/goal edit|pause|resume|clear`, a footer label,
36
+ Esc pauses. Caps: 30 rounds or 8 hours (`--rounds`, `--hours`).
37
+ - **A completion claim is checked** once by the same model at low effort with a fresh context.
38
+ `sessions.run` takes `goal`; `run.json` records `goalMode`.
39
+ - **Fixed.** The check sends a session id, so opencode-go no longer answers 400 `MissingSessionID`.
40
+ - Adapted from OpenAI Codex (Apache-2.0); see `NOTICE.md`.
41
+ - **A completion check replaces `finish` (ADR-0071; the every-reply check is superseded by ADR-0072).**
42
+ - **The check.** When a reply that did work ends with its todo list closed or absent, the run's
43
+ own model, at low effort and with a fresh context, judges the person's request against what the
44
+ reply did: `done`, `continue` (the reply is sent back with the reason and next step), or
45
+ `needs_person`. The request is the goal; there is no `/goal` command.
46
+ - **Shared cap.** It shares the stop gate's cap of three nudges per reply and its no-progress rule.
47
+ - **Usage and failure.** Its request counts in the run's usage, and any failure leaves the reply
48
+ as it was.
49
+ - **`finish` is removed.** A live GPT 6 Luna run used `needs_decision` after 23 seconds to ask
50
+ something the handoff already answered. Only the check can now decide that the person is needed.
51
+ - **Prompt.** The `role` paragraph names which decisions are the agent's own, says a document the
52
+ request points to is the request, and says a question the request or files already answer is not
53
+ a question for the person. Its budget rises from 1,500 to 2,200 characters, so it fits uncut with
54
+ the subagent paragraph.
55
+ - **Kill switches.** `XINGULAR_STOP_GATE=off` and `XINGULAR_COMPLETION_CHECK=off` at launch switch a
56
+ layer off, for experiments.
57
+ - **The model is told it has `edit` and `write`.** Pi's `createEditTool` and `createWriteTool` drop
58
+ the definition's prompt line and guidelines, and Pi lists only tools with a prompt line, so every
59
+ terminal and headless run's system prompt named only `read` and `bash`. Models edited files
60
+ through shell scripts instead: one 2-hour terminal run made 156 script edits (14 failed) and no
61
+ `edit` call. `createWorkspaceFileTools` now restores the prompt line and guidelines, as Pi's own
62
+ `createBashTool` does, for both the terminal and the runner. The stable prefix changes once.
63
+ - **A plan no longer leaks its tools into normal mode.** A terminal plan request narrows the active
64
+ tools, and Pi records the restored normal set only with the next request. A rebuild before then
65
+ (a new runtime, resume, switch, fork or tree navigation) replayed the plan set, so normal work ran
66
+ without `edit`, `write`, browser and connected-app tools. One recorded session implemented a whole
67
+ plan that way. The terminal now marks each plan request in the session and restores the normal
68
+ set after any rebuild.
69
+ - **Terminal replies continue across work slices (ADR-0070).** A terminal reply that reaches its
70
+ 320-call or 60-minute budget after doing work now continues in place as the next slice, with a
71
+ checkpoint and a notice, up to 8 slices, instead of waiting for "continue" and re-sending the
72
+ whole context uncached. Fruitless, blocked, failed, aborted and plan slices still stop.
73
+ `XINGULAR_WORK_SLICE` also accepts key=value pairs such as `maxToolCalls=15,maxSlices=3`.
74
+ - **One copy of each credential: no more `invalid_grant` from terminals.** A terminal's Pi kept the
75
+ account's tokens in `auth.json` under its own lock while the host, its subagents and usage probes
76
+ refreshed the same token in the Keychain under another, and `terminalEnd` copied the file back
77
+ over whatever the Keychain held. OpenAI rotates refresh tokens, so whichever side refreshed second
78
+ failed with `invalid_grant` and the account needed a new sign-in. A terminal now reads and refreshes
79
+ through the host store (`accounts.credentials.*`, INV-ACC-5), holding its lock for the refresh. An
80
+ `auth.json` left by an older terminal is folded in, newest token first.
81
+ - **A stalled terminal reply is recorded as `stalled`.** Pi's abort reports back through
82
+ `terminal.interrupt` like a person's Esc, which closed the run as `user_abort` before the reply
83
+ settled as `stalled`; one silent 15-minute hang was recorded as the person's abort. The interrupt
84
+ now carries the stall. An interrupt also ends a settling reply's wait for its subagents.
85
+
86
+ - **A reply can no longer quietly stop with work open (ADR-0069).**
87
+ - **Stop gate.** In attended top-level runs, terminal included, a reply that ends while its todo
88
+ list has open items is sent back to the model, naming the items, up to three times per reply,
89
+ and never after a nudge that produced no work.
90
+ - **`finish`.** Added here as the one explicit way to stop with work open; removed again by ADR-0071
91
+ above.
92
+ - **Honest stop codes.** Such a reply settles `interrupted` with the new stop codes `needs_person`
93
+ or `unfinished`, never `completed`, with a checkpoint the harness writes from the todo list,
94
+ files and checks.
95
+ - **`checkpoint_write` is removed.** A run used it as a sign-off and stopped with work open. At a
96
+ work-slice budget the harness now writes the checkpoint itself.
97
+ - **One budget per reply.** The work-slice budget now covers the whole reply: Pi's own
98
+ continuations (nudges, delivered subagent results, plan repair) no longer reset it.
99
+ - **Prompt wording.** The texts that read as permission to stop were rewritten: the todo guidance's
100
+ "final update before your final reply", and `## What would make this complete` "when the run
101
+ could be more complete".
102
+ - **Subagents.** `spawn_subagent` now returns the child's tools, and the read-only profiles say up
103
+ front when a brief needs a tool they lack.
104
+ - **Hosts.** Accept the two new stop codes and offer Continue for them.
105
+ - **Restart required.** A live terminal session keeps the code it started with, so restart it to
106
+ get the gate.
107
+ - Do the job the request implies, and report it apart from the request. A standard session's role
108
+ paragraph now sets the scope of the work — the obvious adjacent step, what the work itself exposes,
109
+ the check it needs, inside the working folder and away from what a person must decide (a deploy, a
110
+ secret, remote data, money), without asking first inside those bounds — and the reporting guidance
111
+ requires two headings when they apply: `## Beyond what you asked` and
112
+ `## What would make this complete` (ADR-0068). The reporting budget rises from 2,000 to 2,400
113
+ characters so both fit uncut. All of it is stable-prefix text, so the cached prefix changes once
114
+ per session.
115
+ - Say in the prompt when a reply may end. The standard session's role paragraph, the opening of the
116
+ reporting guidance and the todo guidance now say that an open todo item, a passing check or a
117
+ partial result is not a reason to end the turn, and name the reasons that are: the request is done,
118
+ the work-slice guard hands the reply back, a person's decision is needed, or the person interrupts.
119
+ ADR-0069 below now enforces it in the runner. A sweep of 822 runs in seven days found 207 that ended with work left
120
+ (137 within 30 tool calls, median 17, and 191 with no checkpoint), which is what the wording is
121
+ for. All three texts are in the stable prefix, so this changes the cached prefix once.
5
122
  - Reword the final-reply guidance so the outcome leads and structure follows what the answer needs. The
6
123
  reporting guidance is part of every request's stable prefix, so this changes the cached prefix.
7
124
  - Keep the provider cache working after a compaction (ADR-0067). The compaction checkpoint now arms only
@@ -10,11 +127,11 @@
10
127
  request plus new items, so Codex WebSocket continuation and prefix caching apply. Before, every later
11
128
  turn of a compacted session resent its whole context: one measured session fell from 94–99% to
12
129
  18–24% cache hits after its first compaction.
13
- - Flag a low prompt-cache hit rate in the terminal's composer status bar. `R<percentage>%` now covers the
14
- last 10 model responses instead of the whole session (`recentCacheUsage`, `CACHE_HIT_WINDOW`), and
15
- gets a yellow `⚠` below 70 percent and a red one below 40 percent. Each drop to a worse level posts
16
- one transcript notice. A window of one response, or one with no cache reads or writes, is not judged
17
- (`cacheHitLevel`, `CACHE_HIT_WARNING_PERCENT`, `CACHE_HIT_CRITICAL_PERCENT`).
130
+ - Flag a low prompt-cache hit rate in the terminal's composer status bar. `R<percentage>%` covers the last
131
+ 10 model responses instead of the whole session (`recentCacheUsage`, `CACHE_HIT_WINDOW`), and the rate
132
+ gets a yellow `⚠` below 70 percent and a red one below 40 percent. The warning stays in the status bar;
133
+ no cache-hit notice is added to the transcript. A window of one response, or one with no cache reads or
134
+ writes, is not judged (`cacheHitLevel`, `CACHE_HIT_WARNING_PERCENT`, `CACHE_HIT_CRITICAL_PERCENT`).
18
135
 
19
136
  - Refine a variant from the terminal and keep checkpoints of it (PROP-0052, ADR-0065, ADR-0066).
20
137
  `/refine [what to look at]` replays the latest request typed in this chat from a snapshot of the
package/NOTICE.md CHANGED
@@ -58,3 +58,29 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
58
58
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
59
59
  SOFTWARE.
60
60
  ```
61
+
62
+ ## OpenAI Codex
63
+
64
+ The standard session prompt (`src/prompt/standard.ts`: autonomy and persistence, when to ask the
65
+ person, steering and compaction, writing style), the final-reply rules in `REPORTING_GUIDANCE`
66
+ (`src/prompt/compile.ts`), the `/goal` prompts and tool descriptions (`src/sessions/goalPrompts.ts`,
67
+ `src/sessions/goal.ts`), the goal brakes and status text, and the `/goal` command
68
+ (`src/terminal/tui/goalCommand.ts`) adapt text and design from OpenAI Codex, mainly:
69
+
70
+ - `codex-rs/models-manager/models.json` (`instructions_template` of `gpt-6.1-sol` and `gpt-6-luna`);
71
+ - `codex-rs/ext/goal/templates/goals/{continuation,budget_limit,objective_updated}.md`;
72
+ - `codex-rs/ext/goal/src/{spec,tool,accounting,runtime,api}.rs`;
73
+ - `codex-rs/tui/src/{goal_display,slash_dispatch,goal_menu}.rs`;
74
+ - `codex-rs/collaboration-mode-templates/templates/default.md` (the `ask_user` rule).
75
+
76
+ Upstream: https://github.com/openai/codex (OpenAI Codex, Copyright 2025 OpenAI)
77
+
78
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except
79
+ in compliance with the License. You may obtain a copy of the License at
80
+ https://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in
81
+ writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
82
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Changes from upstream: ported from
83
+ Rust to TypeScript for Pi; text about Codex's own channels and tools (commentary channel,
84
+ `apply_patch`, `functions.exec`, apps, plugins, visualizations) left out; the goal's token budget
85
+ became rounds and hours; `update_plan` became `todo_write`; completing a goal is a claim that the
86
+ harness checks; the model cannot create a goal.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: plugin-authoring
3
- description: Use when designing, building, testing, or packaging a Harness or Pi plugin, extension, skill, or terminal interaction.
3
+ description: Use when designing, building, testing, packaging, or installing a Harness or Pi plugin, extension, skill, or terminal interaction, including from a pasted folder or repository address.
4
4
  ---
5
5
 
6
6
  # Plugin authoring
@@ -12,6 +12,25 @@ description: Use when designing, building, testing, or packaging a Harness or Pi
12
12
  5. For a TUI audit, examine information hierarchy, layout, navigation, keyboard and focus, states, errors, accessibility and narrow and wide terminals. Study source and published screenshots as available; record which claims each source supports. Capture terminal images only with an available, authorized capture mechanism. A PTY text capture is not a screenshot; explicitly report unavailable visual evidence.
13
13
  6. Test registration, behavior, failure and cancellation paths, non-interactive fallback, and trust/permission boundaries. Run relevant checks. Use `plugin_propose` with a name, description and complete text files (omit `package.json`) to submit the package for person-controlled review. It does not install, enable or trust the plugin. Report the proposal ID, evidence and checks actually performed.
14
14
 
15
+ ## Installing an existing skill or plugin
16
+
17
+ A skill is a folder with a `SKILL.md`. Copy the whole folder, never only the `SKILL.md`, into a scope a session reads:
18
+
19
+ | Scope | Folder | Who writes it |
20
+ |---|---|---|
21
+ | This project | `<repo>/.agents/skills/<name>/` or `<repo>/.pi/skills/<name>/` | you, as project files |
22
+ | Every project of this operating-system user | `~/.agents/skills/<name>/` | you, but it is outside the workspace, so the write asks the person |
23
+ | Every account of this harness | `<state>/accounts/_shared/pi/skills/<name>/` | a person, when they want one shared copy |
24
+ | Variant, library, package, Hub | `skills/<name>/SKILL.md` | only a person commits these |
25
+
26
+ - Keep the folder name and the frontmatter `name` equal, and copy `reference/`, `scripts/` and every file the `SKILL.md` links to. Its relative references resolve against the skill folder.
27
+ - For a pasted folder or repository address, clone it into a temporary folder inside the workspace, find `<name>/SKILL.md`, and copy that folder whole. A `tree` or `blob` page address is not a package address: install the repository itself, or copy the skill folder as above. Never write into `.claude/skills`; this harness does not read it.
28
+ - A skill installed this way is available in the next session, not this one; say so.
29
+ - A variant holds `SKILL.md` and flat `scripts/` files only, so a skill with a `reference/` folder stays in the scopes above.
30
+ - `plugin_propose` is for a package you write. Do not propose someone else's skill as a way to install it: a proposal carries text only, is capped at 1 MiB, and becomes a local copy with no update path.
31
+
32
+ When the person asks for a variant, library, Hub or package install, name the exact step (`/skills`, `/components`, `/hub`, `/plugins`) and the source, and leave the commit to them.
33
+
15
34
  ## Terminal example
16
35
 
17
36
  For a small interactive command, prefer a built-in UI over a custom renderer: