@crouton-kit/humanloop 0.3.17 → 0.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +0 -8
- package/dist/api.js +1 -7
- package/dist/cli.js +1 -1
- package/dist/editor/review.js +75 -16
- package/dist/inbox/deck-factories.d.ts +0 -6
- package/dist/inbox/deck-factories.js +0 -16
- package/dist/inbox/deck-schema.d.ts +0 -1
- package/dist/inbox/deck-schema.js +1 -1
- package/dist/inbox/tui.js +0 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -12,14 +12,6 @@ export interface AskOpts {
|
|
|
12
12
|
* on completion, `<dir>/response.json`.
|
|
13
13
|
*/
|
|
14
14
|
export declare function ask(deck: Deck, opts?: AskOpts): Promise<ResolutionEnvelope>;
|
|
15
|
-
export interface ApproveOpts {
|
|
16
|
-
subtitle?: string;
|
|
17
|
-
body?: string;
|
|
18
|
-
dir?: string;
|
|
19
|
-
sessionId?: string;
|
|
20
|
-
}
|
|
21
|
-
/** Sugar: a single `kind:'validation'` Yes/No interaction. */
|
|
22
|
-
export declare function approve(title: string, opts?: ApproveOpts): Promise<boolean>;
|
|
23
15
|
/** Sugar: a single `kind:'notify'` acknowledgement. */
|
|
24
16
|
export declare function notify(title: string, body?: string): Promise<void>;
|
|
25
17
|
export interface InboxOpts {
|
package/dist/api.js
CHANGED
|
@@ -6,7 +6,7 @@ import { scanInbox } from './inbox/scan.js';
|
|
|
6
6
|
import { pickFromInbox } from './inbox/tui.js';
|
|
7
7
|
import { deckPath, atomicWriteJson, readJson, stampCanvasNode } from './inbox/convention.js';
|
|
8
8
|
import { getTerminalSize } from './tui/terminal.js';
|
|
9
|
-
import {
|
|
9
|
+
import { notifyDeck } from './inbox/deck-factories.js';
|
|
10
10
|
const RESPONSE_SCHEMA_ID = 'humanloop.response/v2';
|
|
11
11
|
function managedDir() {
|
|
12
12
|
return mkdtempSync(join(tmpdir(), 'hl-ix-'));
|
|
@@ -78,12 +78,6 @@ export async function ask(deck, opts = {}) {
|
|
|
78
78
|
completedAt,
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
/** Sugar: a single `kind:'validation'` Yes/No interaction. */
|
|
82
|
-
export async function approve(title, opts = {}) {
|
|
83
|
-
const deck = approveDeck(title, { subtitle: opts.subtitle, body: opts.body });
|
|
84
|
-
const env = await ask(deck, { dir: opts.dir, sessionId: opts.sessionId });
|
|
85
|
-
return env.responses[0]?.selectedOptionId === 'yes';
|
|
86
|
-
}
|
|
87
81
|
/** Sugar: a single `kind:'notify'` acknowledgement. */
|
|
88
82
|
export async function notify(title, body) {
|
|
89
83
|
const deck = notifyDeck(title, body !== undefined ? { body } : {});
|
package/dist/cli.js
CHANGED
|
@@ -217,7 +217,7 @@ const REQUEST_SCHEMA = {
|
|
|
217
217
|
},
|
|
218
218
|
allowFreetext: { type: 'boolean' },
|
|
219
219
|
freetextLabel: { type: 'string' },
|
|
220
|
-
kind: { type: 'string', enum: ['notify', '
|
|
220
|
+
kind: { type: 'string', enum: ['notify', 'decision', 'context', 'error'] },
|
|
221
221
|
},
|
|
222
222
|
},
|
|
223
223
|
},
|
package/dist/editor/review.js
CHANGED
|
@@ -115,20 +115,25 @@ export function reviewVimscript() {
|
|
|
115
115
|
` endif`,
|
|
116
116
|
` call setreg('z', l:sz, l:szt)`,
|
|
117
117
|
` let l:label = l:l1 == l:l2 ? ('line ' . l:l1) : ('lines ' . l:l1 . '-' . l:l2)`,
|
|
118
|
-
`
|
|
119
|
-
`
|
|
120
|
-
|
|
118
|
+
` call s:OpenInput('Comment on ' . l:label, '', function('s:CommentSave', [l:l1, l:l2, l:quote, l:cs, l:ce, a:mode]))`,
|
|
119
|
+
`endfunction`,
|
|
120
|
+
``,
|
|
121
|
+
`" Persist a comment once the input buffer is submitted. Bound args carry the`,
|
|
122
|
+
`" anchor (line range, quote, col span, mode) captured before the prompt`,
|
|
123
|
+
`" opened; a:txt is the (possibly multi-line) comment body.`,
|
|
124
|
+
`function! s:CommentSave(l1, l2, quote, cs, ce, mode, txt) abort`,
|
|
125
|
+
` if empty(trim(a:txt))`,
|
|
121
126
|
` echohl WarningMsg | echo 'Comment cancelled' | echohl NONE`,
|
|
122
127
|
` return`,
|
|
123
128
|
` endif`,
|
|
124
129
|
` let s:idseq += 1`,
|
|
125
|
-
` let l:item = {'id': 'c' . localtime() . s:idseq, 'line':
|
|
126
|
-
` if a:mode ==# 'v' && !empty(
|
|
127
|
-
` let l:item['quote'] =
|
|
130
|
+
` let l:item = {'id': 'c' . localtime() . s:idseq, 'line': a:l1, 'endLine': a:l2, 'lineText': join(getline(a:l1, a:l2), "\\n"), 'comment': a:txt, 'createdAt': strftime('%Y-%m-%dT%H:%M:%S')}`,
|
|
131
|
+
` if a:mode ==# 'v' && !empty(a:quote)`,
|
|
132
|
+
` let l:item['quote'] = a:quote`,
|
|
128
133
|
` endif`,
|
|
129
|
-
` if
|
|
130
|
-
` let l:item['colStart'] =
|
|
131
|
-
` let l:item['colEnd'] =
|
|
134
|
+
` if a:cs >= 0 && a:ce > a:cs`,
|
|
135
|
+
` let l:item['colStart'] = a:cs`,
|
|
136
|
+
` let l:item['colEnd'] = a:ce`,
|
|
132
137
|
` endif`,
|
|
133
138
|
` call add(s:comments, l:item)`,
|
|
134
139
|
` call s:Save()`,
|
|
@@ -136,6 +141,58 @@ export function reviewVimscript() {
|
|
|
136
141
|
` echo 'Saved — ' . len(s:comments) . ' comment' . (len(s:comments)==1?'':'s')`,
|
|
137
142
|
`endfunction`,
|
|
138
143
|
``,
|
|
144
|
+
`" Multi-line comment entry. Vim's input() is single-line: a long comment`,
|
|
145
|
+
`" overflows the cmdline and Vim re-echoes the prompt on every wrapped row,`,
|
|
146
|
+
`" cascading it down the screen. So comments are typed in a real scratch`,
|
|
147
|
+
`" buffer that wraps naturally and accepts newlines. a:Cb is invoked with the`,
|
|
148
|
+
`" buffer text on submit; cancel (or empty submit) just closes.`,
|
|
149
|
+
`function! s:OpenInput(title, default, Cb) abort`,
|
|
150
|
+
` let l:rw = win_getid()`,
|
|
151
|
+
` botright 8new`,
|
|
152
|
+
` let b:hl_cb = a:Cb`,
|
|
153
|
+
` let b:hl_rw = l:rw`,
|
|
154
|
+
` let b:hl_done = 0`,
|
|
155
|
+
` setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted`,
|
|
156
|
+
` setlocal nonumber winfixheight wrap linebreak signcolumn=no`,
|
|
157
|
+
` if !empty(a:default)`,
|
|
158
|
+
` call setline(1, split(a:default, "\\n", 1))`,
|
|
159
|
+
` endif`,
|
|
160
|
+
` let &l:statusline = ' ' . a:title . ' Ctrl-S / <Space>s submit · Ctrl-C / q cancel '`,
|
|
161
|
+
` nnoremap <buffer> <silent> <C-s> :call <SID>InputSubmit()<CR>`,
|
|
162
|
+
` inoremap <buffer> <silent> <C-s> <Esc>:call <SID>InputSubmit()<CR>`,
|
|
163
|
+
` nnoremap <buffer> <silent> <Space>s :call <SID>InputSubmit()<CR>`,
|
|
164
|
+
` nnoremap <buffer> <silent> <C-c> :call <SID>InputCancel()<CR>`,
|
|
165
|
+
` inoremap <buffer> <silent> <C-c> <Esc>:call <SID>InputCancel()<CR>`,
|
|
166
|
+
` nnoremap <buffer> <silent> q :call <SID>InputCancel()<CR>`,
|
|
167
|
+
` if !empty(a:default)`,
|
|
168
|
+
` call cursor(line('$'), 1)`,
|
|
169
|
+
` startinsert!`,
|
|
170
|
+
` else`,
|
|
171
|
+
` startinsert`,
|
|
172
|
+
` endif`,
|
|
173
|
+
`endfunction`,
|
|
174
|
+
``,
|
|
175
|
+
`function! s:InputSubmit() abort`,
|
|
176
|
+
` if get(b:, 'hl_done', 0) | return | endif`,
|
|
177
|
+
` let b:hl_done = 1`,
|
|
178
|
+
` let l:txt = join(getline(1, '$'), "\\n")`,
|
|
179
|
+
` let l:Cb = b:hl_cb`,
|
|
180
|
+
` let l:rw = b:hl_rw`,
|
|
181
|
+
` close!`,
|
|
182
|
+
` call win_gotoid(l:rw)`,
|
|
183
|
+
` call l:Cb(l:txt)`,
|
|
184
|
+
`endfunction`,
|
|
185
|
+
``,
|
|
186
|
+
`function! s:InputCancel() abort`,
|
|
187
|
+
` if get(b:, 'hl_done', 0) | return | endif`,
|
|
188
|
+
` let b:hl_done = 1`,
|
|
189
|
+
` let l:rw = b:hl_rw`,
|
|
190
|
+
` close!`,
|
|
191
|
+
` call win_gotoid(l:rw)`,
|
|
192
|
+
` redraw`,
|
|
193
|
+
` echohl WarningMsg | echo 'Cancelled' | echohl NONE`,
|
|
194
|
+
`endfunction`,
|
|
195
|
+
``,
|
|
139
196
|
`function! s:Undo() abort`,
|
|
140
197
|
` if empty(s:comments)`,
|
|
141
198
|
` echohl WarningMsg | echo 'No comments to undo' | echohl NONE`,
|
|
@@ -163,7 +220,7 @@ export function reviewVimscript() {
|
|
|
163
220
|
` let l:ln = get(l:c,'line',0)`,
|
|
164
221
|
` let l:end = get(l:c,'endLine',l:ln)`,
|
|
165
222
|
` let l:loc = l:ln == l:end ? ('L' . l:ln) : ('L' . l:ln . '-' . l:end)`,
|
|
166
|
-
` call add(l:lines, (l:idx+1) . '. [' . l:loc . '] ' . get(l:c,'comment',''))`,
|
|
223
|
+
` call add(l:lines, (l:idx+1) . '. [' . l:loc . '] ' . substitute(get(l:c,'comment',''), "\\n", ' / ', 'g'))`,
|
|
167
224
|
` call add(l:map, l:idx)`,
|
|
168
225
|
` if !empty(get(l:c,'quote',''))`,
|
|
169
226
|
` call add(l:lines, ' > ' . substitute(get(l:c,'quote',''), "\\n", ' / ', 'g'))`,
|
|
@@ -211,12 +268,14 @@ export function reviewVimscript() {
|
|
|
211
268
|
` echohl WarningMsg | echo 'No comment on this line' | echohl NONE | return`,
|
|
212
269
|
` endif`,
|
|
213
270
|
` let l:cur = get(s:comments[l:idx], 'comment', '')`,
|
|
214
|
-
`
|
|
215
|
-
`
|
|
216
|
-
|
|
271
|
+
` call s:OpenInput('Edit comment', l:cur, function('s:ListEditSave', [l:idx]))`,
|
|
272
|
+
`endfunction`,
|
|
273
|
+
``,
|
|
274
|
+
`function! s:ListEditSave(idx, txt) abort`,
|
|
275
|
+
` if empty(trim(a:txt))`,
|
|
217
276
|
` echohl WarningMsg | echo 'Edit cancelled — comment unchanged' | echohl NONE | return`,
|
|
218
277
|
` endif`,
|
|
219
|
-
` let s:comments[
|
|
278
|
+
` let s:comments[a:idx]['comment'] = a:txt`,
|
|
220
279
|
` call s:Save()`,
|
|
221
280
|
` call s:RenderList()`,
|
|
222
281
|
` echo 'Updated comment'`,
|
|
@@ -419,7 +478,7 @@ export function formatFeedbackSummary(result, feedbackJsonPath) {
|
|
|
419
478
|
const lines = original.split('\n');
|
|
420
479
|
out.push(` ${i + 1}. ${rangeLabel(c)}`);
|
|
421
480
|
lines.forEach((ln, k) => out.push(k === 0 ? ` text: ${ln}` : ` ${ln}`));
|
|
422
|
-
out.push(` comment: ${
|
|
481
|
+
c.comment.split('\n').forEach((ln, k) => out.push(k === 0 ? ` comment: ${ln}` : ` ${ln}`));
|
|
423
482
|
out.push('');
|
|
424
483
|
});
|
|
425
484
|
}
|
|
@@ -438,7 +497,7 @@ export function formatFeedbackSummary(result, feedbackJsonPath) {
|
|
|
438
497
|
const lines = original.split('\n');
|
|
439
498
|
out.push(` ${i + 1}. ${rangeLabel(c)}`);
|
|
440
499
|
lines.forEach((ln, k) => out.push(k === 0 ? ` text: ${ln}` : ` ${ln}`));
|
|
441
|
-
out.push(` comment: ${
|
|
500
|
+
c.comment.split('\n').forEach((ln, k) => out.push(k === 0 ? ` comment: ${ln}` : ` ${ln}`));
|
|
442
501
|
out.push('');
|
|
443
502
|
});
|
|
444
503
|
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import type { Deck } from '../types.js';
|
|
2
|
-
export interface ApproveDeckOpts {
|
|
3
|
-
subtitle?: string;
|
|
4
|
-
body?: string;
|
|
5
|
-
}
|
|
6
|
-
/** Build a validated Yes/No validation deck. id: 'approve', kind: 'validation'. */
|
|
7
|
-
export declare function approveDeck(title: string, opts?: ApproveDeckOpts): Deck;
|
|
8
2
|
export interface NotifyDeckOpts {
|
|
9
3
|
body?: string;
|
|
10
4
|
}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
import { validateDeck } from './deck-schema.js';
|
|
2
|
-
/** Build a validated Yes/No validation deck. id: 'approve', kind: 'validation'. */
|
|
3
|
-
export function approveDeck(title, opts = {}) {
|
|
4
|
-
return validateDeck({
|
|
5
|
-
interactions: [{
|
|
6
|
-
id: 'approve',
|
|
7
|
-
title,
|
|
8
|
-
...(opts.subtitle !== undefined ? { subtitle: opts.subtitle } : {}),
|
|
9
|
-
...(opts.body !== undefined ? { body: opts.body } : {}),
|
|
10
|
-
kind: 'validation',
|
|
11
|
-
options: [
|
|
12
|
-
{ id: 'yes', label: 'Yes' },
|
|
13
|
-
{ id: 'no', label: 'No' },
|
|
14
|
-
],
|
|
15
|
-
}],
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
2
|
/** Build a validated single-option notify deck. id: 'notify', kind: 'notify'. */
|
|
19
3
|
export function notifyDeck(title, opts = {}) {
|
|
20
4
|
return validateDeck({
|
|
@@ -29,7 +29,7 @@ const interactionSchema = z.object({
|
|
|
29
29
|
multiSelect: z.boolean().optional(),
|
|
30
30
|
allowFreetext: z.boolean().optional(),
|
|
31
31
|
freetextLabel: z.string().optional(),
|
|
32
|
-
kind: z.enum(['notify', '
|
|
32
|
+
kind: z.enum(['notify', 'decision', 'context', 'error']).optional(),
|
|
33
33
|
preAnswered: preAnswerSchema.optional(),
|
|
34
34
|
});
|
|
35
35
|
const deckSourceSchema = z.object({
|
package/dist/inbox/tui.js
CHANGED
|
@@ -23,14 +23,12 @@ function ansiColor(text, color) {
|
|
|
23
23
|
// ── Row model (ported verbatim from sisyphus cross-session-inbox.ts:8-21) ────
|
|
24
24
|
export const KIND_ICON = {
|
|
25
25
|
notify: '✉',
|
|
26
|
-
validation: '✓',
|
|
27
26
|
decision: '◆',
|
|
28
27
|
context: '✎',
|
|
29
28
|
error: '⚠',
|
|
30
29
|
};
|
|
31
30
|
export const KIND_COLOR = {
|
|
32
31
|
notify: 'gray',
|
|
33
|
-
validation: 'cyan',
|
|
34
32
|
decision: 'cyan',
|
|
35
33
|
context: 'cyan',
|
|
36
34
|
error: 'red',
|
package/dist/index.d.ts
CHANGED
|
@@ -3,13 +3,13 @@ export { defaultGenerateVisual } from './visuals/generate.js';
|
|
|
3
3
|
export { launchReview } from './editor/review.js';
|
|
4
4
|
export { launchReview as review } from './editor/review.js';
|
|
5
5
|
export type { ReviewOptions } from './editor/review.js';
|
|
6
|
-
export { ask,
|
|
6
|
+
export { ask, notify, inbox } from './api.js';
|
|
7
7
|
export { display } from './surfaces/display.js';
|
|
8
8
|
export { scanInbox } from './inbox/scan.js';
|
|
9
9
|
export { renderMarkdown, checkMarkdown, ensureRenderer, isRendererReady, } from './render/termrender.js';
|
|
10
10
|
export { parseDeck, validateDeck, deckSchema } from './inbox/deck-schema.js';
|
|
11
|
-
export {
|
|
12
|
-
export type {
|
|
11
|
+
export { notifyDeck } from './inbox/deck-factories.js';
|
|
12
|
+
export type { NotifyDeckOpts } from './inbox/deck-factories.js';
|
|
13
13
|
export { deckPath, responsePath, progressPath, visualsDir, interactionState, isResolved, isClaimed, atomicWriteJson, readJson, writeResponse, writeProgress, clearProgress, } from './inbox/convention.js';
|
|
14
14
|
export type { InteractionState } from './inbox/convention.js';
|
|
15
15
|
export type { Interaction, InteractionOption, InteractionResponse, InteractionKind, Deck, DeckSource, MountedPanel, MountedPanelOpts, GenerateVisual, VisualBlock, FeedbackComment, FeedbackResult, ResolutionEnvelope, InboxItem, DisplayOpts, } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { defaultGenerateVisual } from './visuals/generate.js';
|
|
|
3
3
|
export { launchReview } from './editor/review.js';
|
|
4
4
|
export { launchReview as review } from './editor/review.js';
|
|
5
5
|
// Interaction-layer surface (SDK).
|
|
6
|
-
export { ask,
|
|
6
|
+
export { ask, notify, inbox } from './api.js';
|
|
7
7
|
export { display } from './surfaces/display.js';
|
|
8
8
|
export { scanInbox } from './inbox/scan.js';
|
|
9
9
|
// Renderer binding — the sole org-wide termrender caller. Consumers
|
|
@@ -13,6 +13,6 @@ export { renderMarkdown, checkMarkdown, ensureRenderer, isRendererReady, } from
|
|
|
13
13
|
export { parseDeck, validateDeck, deckSchema } from './inbox/deck-schema.js';
|
|
14
14
|
// Deck factories — pure builders for common deck shapes (sugar for SDK consumers
|
|
15
15
|
// who want validated Yes/No or notify decks without inline construction).
|
|
16
|
-
export {
|
|
16
|
+
export { notifyDeck } from './inbox/deck-factories.js';
|
|
17
17
|
// Interaction-directory convention helpers (§B) — names humanloop owns.
|
|
18
18
|
export { deckPath, responsePath, progressPath, visualsDir, interactionState, isResolved, isClaimed, atomicWriteJson, readJson, writeResponse, writeProgress, clearProgress, } from './inbox/convention.js';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Key } from './tui/terminal.js';
|
|
2
|
-
export type InteractionKind = 'notify' | '
|
|
2
|
+
export type InteractionKind = 'notify' | 'decision' | 'context' | 'error' | 'review';
|
|
3
3
|
export interface InteractionOption {
|
|
4
4
|
id: string;
|
|
5
5
|
label: string;
|