@xingular/harness 1.3.1-unstable.0 → 1.3.1-unstable.2

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 (116) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/README.md +16 -12
  3. package/builtin/skills/plugin-authoring/SKILL.md +34 -0
  4. package/dist/cli.js +2334 -1715
  5. package/dist/sdk/agents/profiles.d.ts +13 -4
  6. package/dist/sdk/agents/profiles.js +59 -7
  7. package/dist/sdk/annotations/bridge.d.ts +2 -0
  8. package/dist/sdk/annotations/bridge.js +4 -0
  9. package/dist/sdk/annotations/capture.d.ts +44 -2
  10. package/dist/sdk/annotations/capture.js +104 -3
  11. package/dist/sdk/annotations/delivery.d.ts +24 -17
  12. package/dist/sdk/annotations/delivery.js +82 -49
  13. package/dist/sdk/annotations/inspect.js +7 -6
  14. package/dist/sdk/annotations/pageScript.js +4 -4
  15. package/dist/sdk/annotations/part.d.ts +0 -2
  16. package/dist/sdk/annotations/part.js +4 -33
  17. package/dist/sdk/annotations/queue.d.ts +2 -2
  18. package/dist/sdk/annotations/queue.js +12 -7
  19. package/dist/sdk/annotations/serverMethods.js +11 -7
  20. package/dist/sdk/annotations/store.d.ts +13 -21
  21. package/dist/sdk/annotations/store.js +47 -37
  22. package/dist/sdk/commands/list.js +2 -0
  23. package/dist/sdk/core/links.d.ts +51 -0
  24. package/dist/sdk/core/links.js +155 -0
  25. package/dist/sdk/harness.d.ts +5 -0
  26. package/dist/sdk/harness.js +11 -6
  27. package/dist/sdk/index.d.ts +1 -0
  28. package/dist/sdk/index.js +1 -0
  29. package/dist/sdk/plugins/builtin.js +11 -6
  30. package/dist/sdk/plugins/builtinRegistry.d.ts +3 -1
  31. package/dist/sdk/plugins/builtinRegistry.js +9 -3
  32. package/dist/sdk/plugins/discover.d.ts +7 -1
  33. package/dist/sdk/plugins/discover.js +41 -2
  34. package/dist/sdk/plugins/identity.js +1 -1
  35. package/dist/sdk/plugins/inventory.js +1 -1
  36. package/dist/sdk/plugins/manifest.d.ts +2 -0
  37. package/dist/sdk/plugins/manifest.js +21 -4
  38. package/dist/sdk/plugins/plugins.d.ts +2 -0
  39. package/dist/sdk/plugins/plugins.js +1 -0
  40. package/dist/sdk/plugins/proposals.d.ts +17 -0
  41. package/dist/sdk/plugins/proposals.js +147 -0
  42. package/dist/sdk/plugins/types.d.ts +1 -1
  43. package/dist/sdk/plugins/types.js +1 -1
  44. package/dist/sdk/prompt/compile.d.ts +11 -2
  45. package/dist/sdk/prompt/compile.js +32 -4
  46. package/dist/sdk/prompt/standard.d.ts +1 -1
  47. package/dist/sdk/prompt/standard.js +1 -1
  48. package/dist/sdk/server/methods.js +10 -0
  49. package/dist/sdk/sessions/sessionState.d.ts +13 -0
  50. package/dist/sdk/sessions/sessionState.js +31 -0
  51. package/dist/sdk/sessions/sessions.d.ts +7 -0
  52. package/dist/sdk/sessions/sessions.js +45 -5
  53. package/dist/sdk/sessions/subagentService.js +3 -3
  54. package/dist/sdk/terminal/opentui/theme.d.ts +2 -0
  55. package/dist/sdk/terminal/opentui/theme.js +1 -0
  56. package/dist/sdk/terminal/piExtension.js +71 -2
  57. package/dist/sdk/terminal/terminals.d.ts +9 -0
  58. package/dist/sdk/terminal/terminals.js +46 -14
  59. package/dist/sdk/terminal/tui/annotateCommand.d.ts +5 -1
  60. package/dist/sdk/terminal/tui/annotateCommand.js +21 -7
  61. package/dist/sdk/terminal/tui/annotateSend.d.ts +30 -0
  62. package/dist/sdk/terminal/tui/annotateSend.js +40 -0
  63. package/dist/sdk/terminal/tui/commandPages.d.ts +1 -1
  64. package/dist/sdk/terminal/tui/commandPages.js +2 -7
  65. package/dist/sdk/terminal/tui/commands.js +4 -2
  66. package/dist/sdk/terminal/tui/dialogs.js +1 -0
  67. package/dist/sdk/terminal/tui/keybindings.d.ts +1 -1
  68. package/dist/sdk/terminal/tui/keybindings.js +1 -1
  69. package/dist/sdk/terminal/tui/pageOverlay.d.ts +3 -0
  70. package/dist/sdk/terminal/tui/pageOverlay.js +12 -1
  71. package/dist/sdk/terminal/tui/pages/agentsPage.js +5 -2
  72. package/dist/sdk/terminal/tui/pages/annotatePage.d.ts +70 -16
  73. package/dist/sdk/terminal/tui/pages/annotatePage.js +349 -115
  74. package/dist/sdk/terminal/tui/pages/pluginsPage.d.ts +6 -0
  75. package/dist/sdk/terminal/tui/pages/pluginsPage.js +99 -1
  76. package/dist/sdk/terminal/tui/pages/usagePage.d.ts +4 -2
  77. package/dist/sdk/terminal/tui/pages/usagePage.js +39 -12
  78. package/dist/sdk/terminal/tui/pluginCommands.d.ts +1 -1
  79. package/dist/sdk/terminal/tui/pluginCommands.js +13 -3
  80. package/dist/sdk/tools/defaultSkills.d.ts +4 -0
  81. package/dist/sdk/tools/defaultSkills.js +20 -0
  82. package/dist/sdk/tools/definitions.d.ts +3 -1
  83. package/dist/sdk/tools/definitions.js +17 -1
  84. package/dist/sdk/tools/dispatch.js +12 -0
  85. package/dist/sdk/tools/harnessTools.js +1 -1
  86. package/dist/sdk/tools/sessionName.d.ts +7 -0
  87. package/dist/sdk/tools/sessionName.js +53 -8
  88. package/dist/sdk/world/world.d.ts +0 -2
  89. package/dist/terminal-opentui.js +2019 -1269
  90. package/dist/terminal-pi.js +106 -7
  91. package/docs/README.md +3 -0
  92. package/docs/architecture/02-sessions-and-runs.md +11 -5
  93. package/docs/architecture/03-variants.md +1 -3
  94. package/docs/architecture/04-prompt.md +16 -7
  95. package/docs/architecture/06-plugins-and-capabilities.md +36 -4
  96. package/docs/architecture/07-tools-and-gate.md +20 -5
  97. package/docs/architecture/10-server-protocol.md +52 -7
  98. package/docs/architecture/11-terminal.md +50 -19
  99. package/docs/architecture/12-storage.md +1 -0
  100. package/docs/architecture/13-world-tools.md +8 -6
  101. package/docs/architecture/README.md +3 -1
  102. package/docs/architecture/proposals/PROP-0018-annotation-queue-and-app-targets.md +6 -2
  103. package/docs/architecture/proposals/PROP-0048-simple-annotate.md +85 -0
  104. package/docs/architecture/proposals/README.md +1 -0
  105. package/docs/decisions/ADR-0044-annotations-pending-or-sent.md +24 -0
  106. package/docs/decisions/ADR-0045-default-plugin-authoring-skill.md +9 -0
  107. package/docs/decisions/ADR-0046-hash-bound-plugin-proposals.md +20 -0
  108. package/docs/decisions/ADR-0047-links-open-with-the-os-handler.md +47 -0
  109. package/docs/parity.md +7 -4
  110. package/docs/releases/1.3.1-unstable.1.md +8 -0
  111. package/docs/releases/1.3.1-unstable.2.md +11 -0
  112. package/docs/releases/README.md +7 -4
  113. package/docs/terminal-tui.md +62 -23
  114. package/package.json +1 -1
  115. package/dist/sdk/terminal/tui/pages/notesPage.d.ts +0 -75
  116. package/dist/sdk/terminal/tui/pages/notesPage.js +0 -201
@@ -11,7 +11,8 @@ import { FilterList } from "../list.js";
11
11
  const SECTIONS = [
12
12
  { id: 'plugins', title: 'Plugins' },
13
13
  { id: 'trust', title: 'Trust' },
14
- { id: 'packages', title: 'Packages' }
14
+ { id: 'packages', title: 'Packages' },
15
+ { id: 'proposals', title: 'Proposals' }
15
16
  ];
16
17
  const SETTINGS_ROW = 'settings:';
17
18
  const PACKAGE_ROW = 'package:';
@@ -21,10 +22,17 @@ const settingValueText = (setting) => isSwitch(setting)
21
22
  ? setting.value === 1 ? 'on' : 'off'
22
23
  : `${setting.value.toLocaleString('en-US')}${setting.value === setting.default ? ' · default' : ''}`;
23
24
  const settingsOf = (plugin) => plugin.settings ?? [];
25
+ // Never execute or silently hide terminal controls in code being reviewed.
26
+ const reviewText = (line) => line.replace(/[\x00-\x1f\x7f-\x9f\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, char => `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`);
24
27
  export class PluginsPage {
25
28
  options;
26
29
  presentation = 'fullscreen';
27
30
  plugins;
31
+ proposals = [];
32
+ proposalError;
33
+ preview;
34
+ previewOffset = 0;
35
+ previewRows = 1;
28
36
  section = 'plugins';
29
37
  projectId = null;
30
38
  hubManagedIds = new Set();
@@ -63,6 +71,8 @@ export class PluginsPage {
63
71
  }
64
72
  activeTab() { return this.settingsPlugin() ? 'settings' : this.section; }
65
73
  hint() {
74
+ if (this.preview)
75
+ return this.preview.status === 'pending' ? '↑↓ scroll · PgUp/PgDn page · Enter decide · Esc back' : '↑↓ scroll · PgUp/PgDn page · Esc back';
66
76
  if (this.settingsPlugin())
67
77
  return this.settingsList.query ? 'Enter change · Esc clear' : 'Enter change · Esc back';
68
78
  return this.list.query ? 'Enter actions · Esc clear' : 'Enter actions · type to search';
@@ -76,6 +86,14 @@ export class PluginsPage {
76
86
  this.projectId = (await call('plugins.session').catch(() => ({ projectId: null }))).projectId;
77
87
  this.plugins = await call('plugins.list');
78
88
  this.error = undefined;
89
+ try {
90
+ this.proposals = await call('plugins.proposals.list');
91
+ this.proposalError = undefined;
92
+ }
93
+ catch (error) {
94
+ this.proposals = [];
95
+ this.proposalError = error instanceof Error ? error.message : String(error);
96
+ }
79
97
  this.hubManagedIds = new Set();
80
98
  try {
81
99
  const overview = await call('hub.list');
@@ -105,6 +123,12 @@ export class PluginsPage {
105
123
  }
106
124
  /** Switch, trust, settings and package actions stay grouped under their owning plugin. */
107
125
  rows() {
126
+ if (this.section === 'proposals')
127
+ return this.proposals.map(proposal => ({
128
+ id: `proposal:${proposal.id}`, label: safeText(proposal.name), detail: proposal.status,
129
+ tone: proposal.status === 'pending' ? 'warning' : 'muted',
130
+ searchText: `${proposal.name} ${proposal.description} ${proposal.status}`
131
+ }));
108
132
  if (this.section === 'packages')
109
133
  return [
110
134
  ...(this.plugins ?? []).filter(plugin => plugin.install).map(plugin => {
@@ -152,6 +176,24 @@ export class PluginsPage {
152
176
  };
153
177
  }
154
178
  async open(id) {
179
+ if (this.section === 'proposals' && id.startsWith('proposal:')) {
180
+ if (this.busy)
181
+ return;
182
+ this.busy = true;
183
+ try {
184
+ this.preview = await this.options.call('plugins.proposals.preview', { id: id.slice('proposal:'.length) });
185
+ this.previewOffset = 0;
186
+ this.pointerLayout = undefined;
187
+ }
188
+ catch (error) {
189
+ this.options.ui.notify(error instanceof Error ? error.message : String(error), 'error');
190
+ }
191
+ finally {
192
+ this.busy = false;
193
+ this.options.changed();
194
+ }
195
+ return;
196
+ }
155
197
  if (id.startsWith(SETTINGS_ROW)) {
156
198
  this.settingsFor = id.slice(SETTINGS_ROW.length);
157
199
  this.saved = false;
@@ -183,6 +225,36 @@ export class PluginsPage {
183
225
  }
184
226
  await this.reload();
185
227
  }
228
+ async decideProposal() {
229
+ const preview = this.preview;
230
+ if (!preview || preview.status !== 'pending' || this.busy)
231
+ return;
232
+ this.busy = true;
233
+ try {
234
+ const action = await this.options.ui.select(`Proposal ${safeText(preview.name)} · ${preview.hash}`, ['Accept proposal', 'Reject proposal', BACK]);
235
+ if (action !== 'Accept proposal' && action !== 'Reject proposal')
236
+ return;
237
+ const accept = action === 'Accept proposal';
238
+ if (!await this.options.ui.confirm(action + '?', accept ? 'Install this reviewed proposal switched off and untrusted? Review and trust code separately.' : 'Reject this reviewed proposal?'))
239
+ return;
240
+ await this.options.call(accept ? 'plugins.proposals.accept' : 'plugins.proposals.reject', { id: preview.id, hash: preview.hash });
241
+ this.preview = undefined;
242
+ if (accept)
243
+ this.restart = true;
244
+ this.options.ui.notify(accept ? 'Accepted switched off and untrusted. Changes apply after restart.' : 'Proposal rejected.', 'info');
245
+ await this.reload();
246
+ }
247
+ catch (error) {
248
+ this.preview = undefined;
249
+ this.options.ui.notify(error instanceof Error ? error.message : String(error), 'error');
250
+ await this.reload();
251
+ }
252
+ finally {
253
+ this.busy = false;
254
+ if (!this.disposed)
255
+ this.options.changed();
256
+ }
257
+ }
186
258
  async installPackage() {
187
259
  if (this.busy)
188
260
  return;
@@ -296,6 +368,8 @@ export class PluginsPage {
296
368
  }
297
369
  }
298
370
  handleMouse(event) {
371
+ if (this.preview)
372
+ return { handled: true, render: false };
299
373
  const layout = this.pointerLayout;
300
374
  if (!layout)
301
375
  return undefined;
@@ -304,6 +378,20 @@ export class PluginsPage {
304
378
  return layout.list.handleMouse({ ...event, y: event.y - layout.top });
305
379
  }
306
380
  handleInput(data) {
381
+ if (this.preview) {
382
+ if (matchesKey(data, 'escape'))
383
+ this.preview = undefined;
384
+ else if (matchesKey(data, 'enter'))
385
+ void this.decideProposal();
386
+ else if (matchesKey(data, 'home'))
387
+ this.previewOffset = 0;
388
+ else if (matchesKey(data, 'end'))
389
+ this.previewOffset = Number.MAX_SAFE_INTEGER;
390
+ else
391
+ this.previewOffset = Math.max(0, this.previewOffset + (matchesKey(data, 'down') ? 1 : matchesKey(data, 'up') ? -1 : matchesKey(data, 'pageDown') ? this.previewRows : matchesKey(data, 'pageUp') ? -this.previewRows : 0));
392
+ this.options.changed();
393
+ return true;
394
+ }
307
395
  if (this.settingsPlugin()) {
308
396
  if (matchesKey(data, 'tab') || matchesKey(data, 'shift+tab'))
309
397
  return true;
@@ -365,6 +453,16 @@ export class PluginsPage {
365
453
  const theme = this.options.theme();
366
454
  if (width < 1 || rows < 1)
367
455
  return [];
456
+ if (this.preview) {
457
+ const proposal = this.preview;
458
+ const text = [`Name: ${proposal.name}`, `Description: ${proposal.description}`, `Status: ${proposal.status}`, `SHA-256: ${proposal.hash}`, '', '--- package.json ---', proposal.manifest, ...Object.entries(proposal.files).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).flatMap(([path, content]) => ['', `--- ${path} ---`, content])].join('\n');
459
+ const content = text.split('\n').flatMap(line => wrapTextWithAnsi(reviewText(line), width));
460
+ this.previewRows = Math.max(1, rows - 1);
461
+ this.previewOffset = Math.min(this.previewOffset, Math.max(0, content.length - this.previewRows));
462
+ return [theme.bold(`Proposal preview · ${this.previewOffset + 1}/${Math.max(1, content.length)}`), ...content.slice(this.previewOffset, this.previewOffset + this.previewRows)].slice(0, rows).map(line => truncateToWidth(line, width, ''));
463
+ }
464
+ if (this.section === 'proposals' && this.proposalError)
465
+ return [theme.fg('error', `Could not read proposals: ${safeText(this.proposalError)}`)];
368
466
  if (!this.plugins) {
369
467
  this.pointerLayout = undefined;
370
468
  return [theme.fg(this.error ? 'error' : 'dim', this.error ? `Could not read plugins: ${this.error}` : 'Reading plugins…')];
@@ -2,7 +2,7 @@ import type { Theme } from '@earendil-works/pi-coding-agent';
2
2
  import type { UsagePeriod } from "../../../usage/types.js";
3
3
  import type { TabInfo } from "../chrome.js";
4
4
  import type { TerminalPage } from "../page.js";
5
- type UsageTab = 'analysis' | 'limits';
5
+ type UsageTab = 'analysis' | 'limits' | 'accounts';
6
6
  interface UsagePageOptions {
7
7
  theme(): Theme;
8
8
  call(method: string, params?: Record<string, unknown>): Promise<unknown>;
@@ -12,7 +12,7 @@ interface UsagePageOptions {
12
12
  }
13
13
  export declare class UsagePage implements TerminalPage {
14
14
  private readonly options;
15
- presentation: "centered";
15
+ presentation: "fullscreen";
16
16
  focused: boolean;
17
17
  private tab;
18
18
  private period;
@@ -20,7 +20,9 @@ export declare class UsagePage implements TerminalPage {
20
20
  private summary?;
21
21
  private limitsSummary?;
22
22
  private limits?;
23
+ private allLimits?;
23
24
  private busy;
25
+ private reloadPending;
24
26
  private error?;
25
27
  private refreshLimits;
26
28
  private offset;
@@ -118,7 +118,7 @@ function spread(left, right, width) {
118
118
  }
119
119
  export class UsagePage {
120
120
  options;
121
- presentation = 'centered';
121
+ presentation = 'fullscreen';
122
122
  focused = false;
123
123
  tab;
124
124
  period = '7d';
@@ -126,7 +126,9 @@ export class UsagePage {
126
126
  summary;
127
127
  limitsSummary;
128
128
  limits;
129
+ allLimits;
129
130
  busy = false;
131
+ reloadPending = false;
130
132
  error;
131
133
  refreshLimits;
132
134
  offset = 0;
@@ -140,17 +142,19 @@ export class UsagePage {
140
142
  this.refreshLimits = this.tab === 'limits';
141
143
  }
142
144
  tabs() {
143
- return [{ id: 'analysis', title: 'Analysis' }, { id: 'limits', title: 'Limits' }];
145
+ return [{ id: 'analysis', title: 'Analysis' }, { id: 'limits', title: 'Limits' }, { id: 'accounts', title: 'All accounts' }];
144
146
  }
145
147
  activeTab() {
146
148
  return this.tab;
147
149
  }
148
150
  selectTab(id) {
149
- if ((id === 'analysis' || id === 'limits') && id !== this.tab) {
151
+ if ((id === 'analysis' || id === 'limits' || id === 'accounts') && id !== this.tab) {
150
152
  this.tab = id;
151
153
  this.offset = 0;
152
154
  this.options.changed();
153
- if (id === 'limits' && !this.limits) {
155
+ if (id === 'accounts')
156
+ void this.load();
157
+ else if (id === 'limits' && !this.limits) {
154
158
  this.refreshLimits = true;
155
159
  void this.load();
156
160
  }
@@ -162,19 +166,23 @@ export class UsagePage {
162
166
  }
163
167
  hint() {
164
168
  return this.tab === 'analysis'
165
- ? '↑/↓ scroll · PgUp/PgDn page · 1 today 2 7d 3 30d 0 all · c account s session p project a all accounts · r refresh · Tab limits · Esc close'
166
- : '↑/↓ scroll · PgUp/PgDn page · r read provider limits · Tab analysis · Esc close';
169
+ ? '↑/↓ scroll · PgUp/PgDn page · 1 today 2 7d 3 30d 0 all · c account s session p project a all accounts · r refresh'
170
+ : '↑/↓ scroll · PgUp/PgDn page · r read provider limits';
167
171
  }
168
172
  activate() {
169
- if (!this.summary && !this.limits)
173
+ if (!this.summary && !this.limits && !this.allLimits)
170
174
  void this.load();
171
175
  }
172
176
  dispose() {
173
177
  this.disposed = true;
174
178
  }
175
179
  async load() {
176
- if (this.busy || this.disposed)
180
+ if (this.disposed)
181
+ return;
182
+ if (this.busy) {
183
+ this.reloadPending = true;
177
184
  return;
185
+ }
178
186
  this.busy = true;
179
187
  this.error = undefined;
180
188
  this.options.changed();
@@ -186,6 +194,14 @@ export class UsagePage {
186
194
  timezoneOffsetMinutes: -new Date().getTimezoneOffset()
187
195
  });
188
196
  }
197
+ else if (this.tab === 'accounts') {
198
+ if (!this.allLimits) {
199
+ this.allLimits = await this.options.call('terminal.usage.allLimits', { refresh: false });
200
+ if (!this.disposed)
201
+ this.options.changed();
202
+ }
203
+ this.allLimits = await this.options.call('terminal.usage.allLimits', { refresh: true });
204
+ }
189
205
  else {
190
206
  // The provider's windows and this app's own ledger answer different questions; show both.
191
207
  const [limits, summary] = await Promise.all([
@@ -207,12 +223,23 @@ export class UsagePage {
207
223
  }
208
224
  finally {
209
225
  this.busy = false;
210
- if (!this.disposed)
226
+ if (!this.disposed) {
211
227
  this.options.changed();
228
+ if (this.reloadPending) {
229
+ this.reloadPending = false;
230
+ void this.load();
231
+ }
232
+ }
212
233
  }
213
234
  }
214
235
  handleInput(data) {
215
236
  const page = Math.max(1, this.scrollRows - 1);
237
+ if (matchesKey(data, 'tab') || matchesKey(data, 'shift+tab')) {
238
+ const tabs = ['analysis', 'limits', 'accounts'];
239
+ const direction = matchesKey(data, 'shift+tab') ? -1 : 1;
240
+ this.selectTab(tabs[(tabs.indexOf(this.tab) + direction + tabs.length) % tabs.length]);
241
+ return true;
242
+ }
216
243
  if (matchesKey(data, 'up'))
217
244
  this.offset = Math.max(0, this.offset - 1);
218
245
  else if (matchesKey(data, 'down'))
@@ -298,7 +325,7 @@ export class UsagePage {
298
325
  return { header, body };
299
326
  }
300
327
  limitsContent(width, theme) {
301
- const report = this.limits;
328
+ const report = this.tab === 'accounts' ? this.allLimits : this.limits;
302
329
  const header = [];
303
330
  if (!report) {
304
331
  header.push(theme.fg(this.error ? 'error' : 'dim', this.error ?? (this.busy ? 'Reading provider limits…' : 'No limit readings yet.')));
@@ -318,7 +345,7 @@ export class UsagePage {
318
345
  }
319
346
  for (const provider of account.providers) {
320
347
  body.push('');
321
- const source = provider.source === 'provider' ? '' : provider.source;
348
+ const source = this.tab === 'accounts' ? `cached · ${provider.source}` : provider.source === 'provider' ? '' : provider.source;
322
349
  const meta = [source, ago(provider.observedAt)].filter(Boolean).join(' · ');
323
350
  const tone = provider.source === 'unavailable' ? 'warning' : 'muted';
324
351
  body.push(...wrapTextWithAnsi(theme.fg(tone, ` ${provider.provider}${meta ? ` · ${meta}` : ''}${provider.reason ? ` · ${oneLine(provider.reason)}` : ''}`), width));
@@ -348,7 +375,7 @@ export class UsagePage {
348
375
  }
349
376
  if (!report.accounts.length)
350
377
  body.push(theme.fg('dim', 'No accounts.'));
351
- const local = this.limitsSummary?.totals;
378
+ const local = this.tab === 'limits' ? this.limitsSummary?.totals : undefined;
352
379
  if (local) {
353
380
  if (body.length)
354
381
  body.push('');
@@ -6,7 +6,7 @@ type PageOptions = {
6
6
  runId?: string;
7
7
  url?: string;
8
8
  annotate?: AnnotateStart;
9
- usageTab?: 'analysis' | 'limit';
9
+ usageTab?: 'analysis' | 'limit' | 'accounts';
10
10
  usagePeriod?: 'today' | '7d' | '30d' | 'all';
11
11
  };
12
12
  type OpenPage = (id: CommandPageId, options?: PageOptions) => Promise<void>;
@@ -1,16 +1,25 @@
1
1
  import { BUILTIN_PLUGIN_REGISTRY } from "../../plugins/builtin.js";
2
2
  import { parseAnnotate } from "./annotateCommand.js";
3
+ import { sendUnsent } from "./annotateSend.js";
3
4
  /** Terminal adapters for commands declared by Harness-owned feature plugins. */
4
5
  export function createBuiltinPluginCommandHandlers(host, openPage) {
5
6
  const handlers = new Map([
6
- ['annotations:notes', async () => openPage('notes')],
7
- ['annotations:annotate', async (argument) => {
7
+ ['annotations:open', async (argument) => {
8
8
  const start = parseAnnotate(argument);
9
9
  if (typeof start === 'string')
10
10
  host.ui.notify(start, 'error');
11
11
  else
12
12
  await openPage('annotate', { annotate: start });
13
13
  }],
14
+ // The All annotations tab; no capture window opens until the person asks for one.
15
+ ['annotations:notes', async () => openPage('notes')],
16
+ ['annotations:submit', async (argument) => {
17
+ host.ui.notify(await sendUnsent(host.control, host.ui, { prompt: argument.trim() }), 'info');
18
+ }],
19
+ ['annotations:clear', async () => {
20
+ const { notes } = await host.control('terminal.annotations.clear');
21
+ host.ui.notify(notes.length ? `Resolved ${notes.length} unsent annotation${notes.length === 1 ? '' : 's'}; the agent can no longer read ${notes.length === 1 ? 'it' : 'them'}. Reopen from /annotate:notes.` : 'No unsent annotations to clear.', 'info');
22
+ }],
14
23
  ['usage:analysis', async (argument) => {
15
24
  const period = argument.trim().toLowerCase();
16
25
  if (period && !['today', '7d', '30d', 'all'].includes(period)) {
@@ -19,7 +28,8 @@ export function createBuiltinPluginCommandHandlers(host, openPage) {
19
28
  }
20
29
  await openPage('usage', { usageTab: 'analysis', ...(period ? { usagePeriod: period } : {}) });
21
30
  }],
22
- ['usage:limit', async () => openPage('usage', { usageTab: 'limit' })]
31
+ ['usage:limit', async () => openPage('usage', { usageTab: 'limit' })],
32
+ ['usage:accounts', async () => openPage('usage', { usageTab: 'accounts' })]
23
33
  ]);
24
34
  const commands = BUILTIN_PLUGIN_REGISTRY.commands();
25
35
  for (const command of commands) {
@@ -0,0 +1,4 @@
1
+ /** Locate release-owned resources from source, the SDK, or a bundled executable. */
2
+ export declare function defaultSkillPath(): string;
3
+ /** Variant skills win on a name collision, without modifying a pinned variant. */
4
+ export declare function defaultSkillPaths(variantDir: string | null | undefined): string[];
@@ -0,0 +1,20 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ /** Locate release-owned resources from source, the SDK, or a bundled executable. */
5
+ export function defaultSkillPath() {
6
+ let dir = dirname(fileURLToPath(import.meta.url));
7
+ for (;;) {
8
+ const path = join(dir, 'builtin', 'skills', 'plugin-authoring', 'SKILL.md');
9
+ if (existsSync(path))
10
+ return path;
11
+ const parent = dirname(dir);
12
+ if (parent === dir)
13
+ throw new Error('The bundled plugin-authoring skill is missing.');
14
+ dir = parent;
15
+ }
16
+ }
17
+ /** Variant skills win on a name collision, without modifying a pinned variant. */
18
+ export function defaultSkillPaths(variantDir) {
19
+ return variantDir && existsSync(join(variantDir, 'skills', 'plugin-authoring', 'SKILL.md')) ? [] : [defaultSkillPath()];
20
+ }
@@ -1,4 +1,4 @@
1
- export type HarnessCall = 'recall.search' | 'recall.read' | 'trajectory.search' | 'trajectory.read' | 'wiki.search' | 'wiki.read' | 'wiki.list' | 'wiki.write' | 'skill.load';
1
+ export type HarnessCall = 'recall.search' | 'recall.read' | 'trajectory.search' | 'trajectory.read' | 'wiki.search' | 'wiki.read' | 'wiki.list' | 'wiki.write' | 'skill.load' | 'plugin.propose';
2
2
  /** A JSON Schema object, kept loose so TypeBox, MCP, and the CLI can all use it. */
3
3
  export type JsonSchema = {
4
4
  type: string;
@@ -23,6 +23,8 @@ export declare const WIKI_WRITE = "wiki_write";
23
23
  export declare const WIKI_WRITE_TOOLS: HarnessToolDefinition[];
24
24
  /** Skills: load one of this agent's skills from its harness. */
25
25
  export declare const SKILL_TOOLS: HarnessToolDefinition[];
26
+ /** Propose a package for a person to review; this never installs or enables it. */
27
+ export declare const PLUGIN_PROPOSAL_TOOLS: HarnessToolDefinition[];
26
28
  /** Every harness tool. */
27
29
  export declare const HARNESS_TOOLS: HarnessToolDefinition[];
28
30
  /** The harness tools every session has; `wiki_write` is added only when the caller switches it on. */
@@ -110,8 +110,24 @@ export const SKILL_TOOLS = [
110
110
  parameters: { type: 'object', properties: { name: text('The skill name, as your instructions write it') } }
111
111
  }
112
112
  ];
113
+ /** Propose a package for a person to review; this never installs or enables it. */
114
+ export const PLUGIN_PROPOSAL_TOOLS = [{
115
+ name: 'plugin_propose',
116
+ call: 'plugin.propose',
117
+ label: 'Propose a plugin',
118
+ description: 'Propose a plugin for a person to review. This does not install, enable, or trust it. Use the plugin-authoring skill first. Provide text files as a map from relative paths to their complete contents.',
119
+ parameters: {
120
+ type: 'object',
121
+ properties: {
122
+ name: text('Lowercase plugin package name, using letters, numbers, hyphens or underscores'),
123
+ description: text('A short description of the plugin'),
124
+ files: { type: 'object', additionalProperties: { type: 'string' }, description: 'Relative file paths and complete UTF-8 text contents; omit package.json' }
125
+ },
126
+ required: ['name', 'description', 'files']
127
+ }
128
+ }];
113
129
  /** Every harness tool. */
114
- export const HARNESS_TOOLS = [...RECALL_TOOLS, ...TRAJECTORY_TOOLS, ...WIKI_READ_TOOLS, ...WIKI_WRITE_TOOLS, ...SKILL_TOOLS];
130
+ export const HARNESS_TOOLS = [...RECALL_TOOLS, ...TRAJECTORY_TOOLS, ...WIKI_READ_TOOLS, ...WIKI_WRITE_TOOLS, ...SKILL_TOOLS, ...PLUGIN_PROPOSAL_TOOLS];
115
131
  /** The harness tools every session has; `wiki_write` is added only when the caller switches it on. */
116
132
  export const DEFAULT_TOOL_NAMES = HARNESS_TOOLS.filter((tool) => tool.name !== WIKI_WRITE).map((tool) => tool.name);
117
133
  export const describeTool = (tool, productName) => tool.description.replaceAll('{product}', productName);
@@ -7,6 +7,8 @@ import { HarnessError, invalid } from "../core/errors.js";
7
7
  import * as recall from "../history/recall.js";
8
8
  import * as trajectory from "../history/trajectory.js";
9
9
  import * as notes from "../wiki/notes.js";
10
+ import * as proposals from "../plugins/proposals.js";
11
+ import { defaultSkillPaths } from "./defaultSkills.js";
10
12
  function str(params, key) {
11
13
  const value = params[key];
12
14
  return typeof value === 'string' ? value : '';
@@ -45,6 +47,10 @@ export function dispatch(env, context, call, params, options = {}) {
45
47
  env.bus?.emit({ type: 'wiki.changed' });
46
48
  return `Saved ${note.path}.`;
47
49
  }
50
+ case 'plugin.propose': {
51
+ const proposal = proposals.create(env.root, params.name, params.description, params.files);
52
+ return `Proposed ${proposal.name} (${proposal.id}). A person can review it in the plugin manager; it is not installed or enabled.`;
53
+ }
48
54
  case 'skill.load':
49
55
  return loadSkill(options.variantDir ?? null, str(params, 'name'));
50
56
  default:
@@ -54,6 +60,10 @@ export function dispatch(env, context, call, params, options = {}) {
54
60
  /** A skill's text from the run's variant, or the list of its skills. */
55
61
  export function loadSkill(variantDir, name) {
56
62
  const skills = variantDir && existsSync(join(variantDir, 'skills')) ? readdirSync(join(variantDir, 'skills'), { withFileTypes: true }).filter((entry) => entry.isDirectory() && existsSync(join(variantDir, 'skills', entry.name, 'SKILL.md'))).map((entry) => entry.name).sort() : [];
63
+ const defaults = defaultSkillPaths(variantDir);
64
+ if (defaults.length)
65
+ skills.push('plugin-authoring');
66
+ skills.sort();
57
67
  const wanted = name.trim().replace(/^skills\//, '').replace(/`/g, '');
58
68
  if (!wanted)
59
69
  return skills.length ? `Your skills: ${skills.join(', ')}. Load one with skill_load and its name.` : 'You have no skills.';
@@ -61,6 +71,8 @@ export function loadSkill(variantDir, name) {
61
71
  throw invalid('A skill name is lowercase letters, digits, _ or -.');
62
72
  if (!skills.includes(wanted))
63
73
  return `There is no skill named ${wanted}.${skills.length ? ` Your skills: ${skills.join(', ')}.` : ''}`;
74
+ if (wanted === 'plugin-authoring' && defaults.length)
75
+ return readFileSync(defaults[0], 'utf8');
64
76
  const dir = join(variantDir, 'skills', wanted);
65
77
  const helpers = existsSync(join(dir, 'scripts')) ? readdirSync(join(dir, 'scripts')) : [];
66
78
  return `${readFileSync(join(dir, 'SKILL.md'), 'utf8')}${helpers.length ? `\n\n(This skill's helpers are in ${join(dir, 'scripts')}: ${helpers.join(', ')}.)` : ''}`;
@@ -6,7 +6,7 @@ export function harnessTools(env, context, options = {}) {
6
6
  label: tool.label,
7
7
  description: describeTool(tool, env.productName),
8
8
  parameters: (Type) => Type.Unsafe(tool.parameters),
9
- readOnly: tool.name !== 'wiki_write',
9
+ readOnly: tool.name !== 'wiki_write' && tool.name !== 'plugin_propose',
10
10
  execute: async (input) => {
11
11
  try {
12
12
  return dispatch(env, context, tool.call, input, { variantDir: options.variantDir }) || 'Nothing found.';
@@ -6,4 +6,11 @@ export interface NamedSession {
6
6
  readonly sessionName?: string;
7
7
  setSessionName(name: string): void;
8
8
  }
9
+ /** The one name validation every caller uses: a short, single-line, control-free sentence. */
10
+ export declare function normalizeSessionName(value: unknown): string;
11
+ /**
12
+ * A provisional name for a substantive first request. It is deliberately mechanical: the model
13
+ * can still revise it with session_name. Greetings and short conversational replies stay unnamed.
14
+ */
15
+ export declare function deriveSessionName(text: string): string | null;
9
16
  export declare function sessionNameTool(current: () => NamedSession | undefined): ToolSpec;
@@ -5,6 +5,58 @@ export const SESSION_NAME = 'session_name';
5
5
  /** The trigger the prompt and the tool description share, so naming guidance cannot drift. */
6
6
  export const SESSION_GUIDANCE = 'If the request needs tools or changes state — not a greeting, thanks, or a short conversational reply — call session_name once before your first other tool call, naming the work from the request. ' +
7
7
  'Use one short imperative sentence of at most six words. Revise the name only when the overall objective changes; keep the current name when it does not.';
8
+ /** The one name validation every caller uses: a short, single-line, control-free sentence. */
9
+ export function normalizeSessionName(value) {
10
+ if (typeof value !== 'string')
11
+ throw invalid('Send name as a short sentence of at most six words.');
12
+ if (/[\x00-\x08\x0e-\x1f\x7f-\x9f]/u.test(value)) {
13
+ throw invalid('Session names cannot contain terminal escapes or control characters.');
14
+ }
15
+ const name = value.replace(/\s+/gu, ' ').trim();
16
+ if (!name || name.split(' ').length > 6)
17
+ throw invalid('Use a non-empty session name of at most six words.');
18
+ return name;
19
+ }
20
+ const CONVERSATIONAL = /^(?:hi|hello|hey|yo|thanks|thank you|ok|okay|sure|great|nice|cool|sounds good|got it|good morning|good afternoon|good evening|how are you|what'?s up)[.!?]*$/iu;
21
+ const LEADING = /^(?:please|can you|could you|would you|i want you to|i'd like you to|help me|let'?s|go ahead and)[,\s]+/iu;
22
+ /**
23
+ * A provisional name for a substantive first request. It is deliberately mechanical: the model
24
+ * can still revise it with session_name. Greetings and short conversational replies stay unnamed.
25
+ */
26
+ export function deriveSessionName(text) {
27
+ if (typeof text !== 'string')
28
+ return null;
29
+ const input = text.trim();
30
+ if (!input || input.startsWith('!') || input.startsWith('```') || /^https?:\/\//iu.test(input))
31
+ return null;
32
+ if (CONVERSATIONAL.test(input))
33
+ return null;
34
+ if (/^continue\b/iu.test(input))
35
+ return 'Continue previous work';
36
+ const sentence = input.split(/[.!?](?:\s|$)/u)[0] ?? input;
37
+ const cleaned = sentence
38
+ .replace(/```[\s\S]*?```/gu, ' ')
39
+ .replace(/[`*_~#>]/gu, ' ')
40
+ .replace(/[:;,]+/gu, ' ')
41
+ .replace(LEADING, '')
42
+ .replace(/\s+/gu, ' ')
43
+ .trim();
44
+ if (!/[a-z]/iu.test(cleaned))
45
+ return null;
46
+ const words = cleaned.split(' ').filter(Boolean).slice(0, 6);
47
+ if (!words.length)
48
+ return null;
49
+ const name = words.join(' ').replace(/^[\p{P}\p{S}]+/u, '').replace(/[\p{P}\p{S}]+$/u, '').trim();
50
+ if (!name)
51
+ return null;
52
+ const capitalized = name[0].toUpperCase() + name.slice(1);
53
+ try {
54
+ return normalizeSessionName(capitalized);
55
+ }
56
+ catch {
57
+ return null;
58
+ }
59
+ }
8
60
  export function sessionNameTool(current) {
9
61
  return {
10
62
  name: SESSION_NAME,
@@ -14,14 +66,7 @@ export function sessionNameTool(current) {
14
66
  parameters: Type => Type.Object({ name: Type.String({ description: 'One short sentence describing the objective, at most six words' }) }),
15
67
  planModeSafe: () => true,
16
68
  execute: async (input) => {
17
- if (typeof input.name !== 'string')
18
- throw invalid('Send name as a short sentence of at most six words.');
19
- if (/[\x00-\x08\x0e-\x1f\x7f-\x9f]/u.test(input.name)) {
20
- throw invalid('Session names cannot contain terminal escapes or control characters.');
21
- }
22
- const name = input.name.replace(/\s+/gu, ' ').trim();
23
- if (!name || name.split(' ').length > 6)
24
- throw invalid('Use a non-empty session name of at most six words.');
69
+ const name = normalizeSessionName(input.name);
25
70
  const session = current();
26
71
  if (!session)
27
72
  throw invalid('The native session is unavailable; try naming it again once it is ready.');
@@ -27,8 +27,6 @@ export interface WorldOptions {
27
27
  request?: WebRequest;
28
28
  /** Replaces the browser's launcher and address check in tests. */
29
29
  browser?: Omit<BrowserPartOptions, 'stateDir'> | false;
30
- /** Told when the agent marks a page note fixed, so front ends refresh (PROP-0018). */
31
- notesChanged?: (sessionId: string | null, ids: string[]) => void;
32
30
  }
33
31
  /** A family of world tools, switched as one plugin. */
34
32
  export interface WorldPart {