clavarium 0.2.142-next.1 → 0.2.144-next.1

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.
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.142-next.1",
3
+ "version": "0.2.144-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.142-next.1",
9
+ "version": "0.2.144-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
13
13
  "@xterm/xterm": "^6.0.0",
14
14
  "clavarium-binder": "0.1.42-next.1",
15
15
  "clavarium-docket": "0.1.1",
16
- "clavarium-parley": "0.17.24-next.1",
16
+ "clavarium-parley": "0.17.25-next.1",
17
17
  "clavarium-tether": "0.1.0-next.34",
18
18
  "mermaid": "11.17.2",
19
19
  "node-pty": "^1.1.0",
@@ -742,9 +742,9 @@
742
742
  }
743
743
  },
744
744
  "node_modules/clavarium-parley": {
745
- "version": "0.17.24-next.1",
746
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.24-next.1.tgz",
747
- "integrity": "sha512-VCMvXbBXRNDZnuhuNcLG5qQGCDZEKrgDguq9/e5RLcbf2ZIRgoLe1ei3qA3pD5o8PCRxQrPpzoyP/EayPOjFvw==",
745
+ "version": "0.17.25-next.1",
746
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.25-next.1.tgz",
747
+ "integrity": "sha512-aqCVLjXxh8NHBxXMNklDtd2yypN7fTPk87KifLMmDhwCaiH+cMgQwNC/Nn67AiYd0XHyk663e2/sP7F+NSfD9g==",
748
748
  "license": "MIT",
749
749
  "bin": {
750
750
  "parley": "bin/parley.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.142-next.1",
3
+ "version": "0.2.144-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
@@ -46,7 +46,7 @@
46
46
  "@xterm/xterm": "^6.0.0",
47
47
  "clavarium-binder": "0.1.42-next.1",
48
48
  "clavarium-docket": "0.1.1",
49
- "clavarium-parley": "0.17.24-next.1",
49
+ "clavarium-parley": "0.17.25-next.1",
50
50
  "clavarium-tether": "0.1.0-next.34",
51
51
  "mermaid": "11.17.2",
52
52
  "node-pty": "^1.1.0",
@@ -83,6 +83,31 @@ export function explain(stderr) {
83
83
  return String(text).trim().split('\n').filter(Boolean).pop()?.slice(0, 300) ?? '';
84
84
  }
85
85
 
86
+ /* What the remote's own hooks said (pre-receive, update: the "remote:" lines of a push), for a
87
+ person and for the agent: colours and control characters out, git's progress lines out, the
88
+ last REMOTE_LINES lines, REMOTE_CHARS characters at most. Text of the remote: data, quoted. */
89
+ export const REMOTE_LINES = 20;
90
+ export const REMOTE_CHARS = 1500;
91
+ export function remoteSaid(stderr) {
92
+ const lines = String(stderr ?? '').split(/\r?\n|\r/)
93
+ .filter((l) => /^remote:/.test(l))
94
+ .map((l) => l.replace(/^remote:\s?/, '').replace(/\x1b\[[0-9;?]*[ -\/]*[@-~]/g, '').replace(/[\x00-\x1f\x7f]/g, '').trimEnd())
95
+ .filter((l) => l.trim() && !/^(Resolving deltas|Counting objects|Compressing objects|Processing changes|Total \d|Enumerating objects|Writing objects)\b/.test(l.trim()));
96
+ /* A very talkative hook: the lines that say what is wrong first (error, refused, must…), in their
97
+ order, then the end of what it said, up to REMOTE_LINES; "[N lines left out]" where lines went. */
98
+ let kept = lines;
99
+ if (lines.length > REMOTE_LINES) {
100
+ const telling = new Set(lines.map((l, i) => (/\b(error|errors|denied|reject|rejected|refused|must|fail|failed|failure|forbidden|invalid|not allowed|violation|required|missing|GH\d{3})\b/i.test(l) ? i : -1)).filter((i) => i >= 0).slice(0, REMOTE_LINES - 5));
101
+ for (let i = lines.length - 1; telling.size < REMOTE_LINES && i >= 0; i -= 1) telling.add(i);
102
+ const picked = [...telling].sort((a, b) => a - b);
103
+ kept = [];
104
+ picked.forEach((i, k) => { const gap = i - (k ? picked[k - 1] + 1 : 0); if (gap > 0) kept.push(`[${gap} line${gap > 1 ? 's' : ''} left out]`); kept.push(lines[i]); });
105
+ }
106
+ let text = kept.join('\n');
107
+ if (text.length > REMOTE_CHARS) text = `…${text.slice(-REMOTE_CHARS)}`;
108
+ return text;
109
+ }
110
+
86
111
  /* An ed25519 key pair in the formats OpenSSH reads, made with Node's own
87
112
  crypto: no program is run and nothing touches the disk. The private key is
88
113
  the unencrypted "openssh-key-v1" container (it is encrypted by the vault). */
@@ -608,6 +608,8 @@ export class GitKeeper {
608
608
  if (['look', 'confirm', 'busy'].includes(error.kind)) return;
609
609
  this.#log(name, { ok: false, branch: branch ?? null, head: head ?? null, what: error.message });
610
610
  if (error.alert) this.#tell(`${name}: sending needs a look`, error.message);
611
+ /* Refused by the remote, sent by hand: what it said is the agent's to act on too. */
612
+ if (error.kind === 'refused' && error.ai) this.#toAgent(name, error.ai);
611
613
  if (error.kind === 'unknown-unreachable' && branch) this.#patch(name, { blocked: { ...(this.#record(name).blocked ?? {}), [branch]: { head, at: this.#now().toISOString() } } });
612
614
  }
613
615
 
@@ -27,7 +27,7 @@
27
27
  * password, which only ever goes back to the https origin it was given for.
28
28
  */
29
29
  import { Refusal } from './conversations.mjs';
30
- import { GitAccess, readAddress, explain } from './gitaccess.mjs';
30
+ import { GitAccess, readAddress, explain, remoteSaid } from './gitaccess.mjs';
31
31
  import { GitRunner, GitFailure, EMPTY_TREE, branchProblem, protocolOf, isId } from './gitrunner.mjs';
32
32
 
33
33
  export { branchProblem };
@@ -653,7 +653,16 @@ export class GitReview {
653
653
  if (line && ours && (flag === '+' || /forced update/.test(summary))) throw new GitFailure(502, 'forced', 'The push was not as reviewed (a forced update): look at the remote.', { alert: true });
654
654
  if (line && !ours && (flag === ' ' || flag === '*' || flag === '+')) throw new GitFailure(502, 'forced', 'The push was not as reviewed (another source): look at the remote.', { alert: true });
655
655
  if (flag === '!' && /stale info|fetch first|non-fast-forward/.test(summary)) throw new GitFailure(409, 'remote-moved', `Not sent: the remote's ${target} moved (the lease was refused). Look again.`, { ai: `origin/${target} moved: pull origin/${target} first` });
656
- if (pushed.code !== 0 || !(flag === ' ' || flag === '*')) throw new GitFailure(502, 'refused', `The remote refused: ${explain(pushed.stderr) || firstLine(summary)}`);
656
+ if (pushed.code !== 0 || !(flag === ' ' || flag === '*')) {
657
+ /* Why, as the remote put it: its verdict on our ref ("[remote rejected] (pre-receive hook
658
+ declined)") rather than git's closing "failed to push some refs", and what its hooks
659
+ said -- to the owner, and to the agent that can fix the commit. */
660
+ const verdict = flag === '!' && summary ? firstLine(summary) : '';
661
+ const hooks = remoteSaid(pushed.stderr);
662
+ const why = verdict || explain(pushed.stderr) || firstLine(summary);
663
+ const said = hooks ? `; it said: "${hooks.split('\n').join(' / ').replace(/"/g, "'")}"` : '';
664
+ throw new GitFailure(502, 'refused', `The remote refused: ${why}${said}`, { detail: hooks, ai: `the remote refused the sending to ${target}: ${why}${said}` });
665
+ }
657
666
  /* (5) The pushed commits enter the reference only as the remote's history. */
658
667
  const after = await this.#refreshLocked(r, { branch: target, head });
659
668
  return sent(after.ok ? {} : { refreshed: false, note: 'Sent; the reference was not refreshed.' });