@iiiokojiadbi/shift 0.28.0 → 0.29.0
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/core/flows.ts +4 -12
- package/core/layout.ts +0 -3
- package/core/loop.ts +3 -17
- package/core/texts/doctrine.ts +2 -3
- package/core/texts/rows.ts +3 -3
- package/core/types.ts +1 -1
- package/index.ts +2 -5
- package/package.json +1 -1
package/core/flows.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
INDEX,
|
|
14
14
|
KNOWLEDGE,
|
|
15
15
|
LETTER,
|
|
16
|
-
MAX_AUTO_STREAK,
|
|
17
16
|
NAMES,
|
|
18
17
|
OLD_DIR,
|
|
19
18
|
SETTINGS,
|
|
@@ -351,19 +350,14 @@ export type LetGo = {
|
|
|
351
350
|
messages: readonly { role: string; text: string }[]
|
|
352
351
|
before: number | undefined
|
|
353
352
|
after: number
|
|
354
|
-
// `continue` shifts in a row without the owner before this one.
|
|
355
|
-
streak: number
|
|
356
353
|
}
|
|
357
354
|
|
|
358
|
-
// After the let-go: the summary and the outcome on disk, then continue
|
|
359
|
-
// `MAX_AUTO_STREAK` continues in a row without the owner.
|
|
355
|
+
// After the let-go: the summary and the outcome on disk, then continue or wait, as the agent asked.
|
|
360
356
|
export async function settleShift(project: Project, letGo: LetGo): Promise<Settled> {
|
|
361
357
|
const { store } = project
|
|
362
358
|
const { shift, before, after } = letGo
|
|
363
359
|
const summary = renderSummary(letGo.messages)
|
|
364
360
|
await store.write(`${shift.dir}/${NAMES.summary}`, summary)
|
|
365
|
-
const streak = letGo.streak + 1
|
|
366
|
-
const isCapped = shift.after === 'continue' && streak > MAX_AUTO_STREAK
|
|
367
361
|
const shrank = `${formatK(before ?? 0)} → ${formatK(after)}`
|
|
368
362
|
const outcome = (result: string) =>
|
|
369
363
|
store.write(
|
|
@@ -373,22 +367,20 @@ export async function settleShift(project: Project, letGo: LetGo): Promise<Settl
|
|
|
373
367
|
const back = await handBack(project, shift.dir)
|
|
374
368
|
const name = basename(shift.dir)
|
|
375
369
|
|
|
376
|
-
if (shift.after === 'continue'
|
|
370
|
+
if (shift.after === 'continue') {
|
|
377
371
|
await outcome(OUTCOME.continuing(shrank))
|
|
378
372
|
|
|
379
373
|
return {
|
|
380
374
|
after: 'continue',
|
|
381
|
-
streak,
|
|
382
375
|
prompt: continuePrompt(shift.letter, back),
|
|
383
376
|
row: CONTINUING(name, shrank, shift.dir),
|
|
384
377
|
}
|
|
385
378
|
}
|
|
386
379
|
|
|
387
|
-
|
|
388
|
-
await outcome(OUTCOME.waiting(shrank, why))
|
|
380
|
+
await outcome(OUTCOME.waiting(shrank, 'waiting for the owner'))
|
|
389
381
|
const note = { context: waitContext(shift.letter, back), dir: shift.dir, files: deliveredFiles(back.work) }
|
|
390
382
|
|
|
391
|
-
return { after: 'wait', note, row: WAITING(name, shrank
|
|
383
|
+
return { after: 'wait', note, row: WAITING(name, shrank) }
|
|
392
384
|
}
|
|
393
385
|
|
|
394
386
|
// The fill the stretch started from, if the last shift was this session's: a fresh process counts from there.
|
package/core/layout.ts
CHANGED
|
@@ -26,9 +26,6 @@ export const RESUME_COMMAND = 'unshift'
|
|
|
26
26
|
|
|
27
27
|
export const TASKS_COMMAND = 'shift-tasks'
|
|
28
28
|
|
|
29
|
-
// Consecutive self-continued shifts before the mod stops and waits for the owner.
|
|
30
|
-
export const MAX_AUTO_STREAK = 3
|
|
31
|
-
|
|
32
29
|
// The board is the state of the work; past this it has turned into a diary.
|
|
33
30
|
export const BOARD_MAX_LINES = 150
|
|
34
31
|
|
package/core/loop.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Generated from core/src by scripts/sync-core.ts — edit the source, not this copy.
|
|
2
2
|
import { settleShift, shiftNotMade, shiftUnsettled } from './flows'
|
|
3
3
|
import { type GaugeKeeper, takeHint } from './hint'
|
|
4
|
-
import { MAX_AUTO_STREAK } from './layout'
|
|
5
4
|
import { basename } from './paths'
|
|
6
5
|
import type { Project } from './project'
|
|
7
6
|
import { compactInstructions, FAILURE_NOTE, NOT_MADE_NOTE, UNSETTLED_NOTE } from './texts/prompts'
|
|
@@ -15,8 +14,6 @@ import type { PendingShift, Settled, WaitNote } from './types'
|
|
|
15
14
|
export type LoopState = {
|
|
16
15
|
// The shift accepted in this turn, let go once the turn ends.
|
|
17
16
|
pending: PendingShift | null
|
|
18
|
-
// `continue` shifts in a row without the owner.
|
|
19
|
-
streak: number
|
|
20
17
|
// The letter and the records waiting for the owner's next message.
|
|
21
18
|
note: WaitNote | null
|
|
22
19
|
}
|
|
@@ -44,7 +41,7 @@ export type LetGoHarness = {
|
|
|
44
41
|
afterLetGo?(): Promise<void>
|
|
45
42
|
}
|
|
46
43
|
|
|
47
|
-
export const FRESH_LOOP: LoopState = { pending: null,
|
|
44
|
+
export const FRESH_LOOP: LoopState = { pending: null, note: null }
|
|
48
45
|
|
|
49
46
|
// An accepted shift waits for its turn to end.
|
|
50
47
|
export async function holdShift(loop: Loop, shift: PendingShift): Promise<void> {
|
|
@@ -87,8 +84,6 @@ export async function afterTurn(project: Project, loop: Loop, harness: LetGoHarn
|
|
|
87
84
|
messages: done.messages,
|
|
88
85
|
before: done.before ?? before,
|
|
89
86
|
after: done.after ?? (await harness.fill()) ?? 0,
|
|
90
|
-
// Read now: the owner may have spoken while the history was let go.
|
|
91
|
-
streak: (await loop.read()).streak,
|
|
92
87
|
})
|
|
93
88
|
} catch (error) {
|
|
94
89
|
const why = String(error)
|
|
@@ -102,30 +97,21 @@ export async function afterTurn(project: Project, loop: Loop, harness: LetGoHarn
|
|
|
102
97
|
loop.tell(settled.row, 'info')
|
|
103
98
|
return
|
|
104
99
|
}
|
|
105
|
-
const { streak } = settled
|
|
106
|
-
await loop.update(current => ({ ...current, streak }))
|
|
107
100
|
loop.tell(settled.row, 'info')
|
|
108
101
|
// The shift is settled and written; a turn that does not start is told, not recorded against it.
|
|
109
102
|
await harness.continueWith(settled.prompt).catch((error: unknown) => loop.tell(NOT_CONTINUED(String(error)), 'error'))
|
|
110
103
|
}
|
|
111
104
|
|
|
112
105
|
// A failed shift is told to the agent, who was told it was accepted: at once when it was to continue and may go on,
|
|
113
|
-
//
|
|
106
|
+
// otherwise with the owner's next message.
|
|
114
107
|
async function tellAgent(loop: Loop, harness: LetGoHarness, shift: PendingShift, context: string, goOn: boolean): Promise<void> {
|
|
115
|
-
|
|
116
|
-
if (goOn && shift.after === 'continue' && streak < MAX_AUTO_STREAK) {
|
|
117
|
-
await loop.update(current => ({ ...current, streak: current.streak + 1 }))
|
|
108
|
+
if (goOn && shift.after === 'continue') {
|
|
118
109
|
await harness.continueWith(context).catch((error: unknown) => loop.tell(NOT_CONTINUED(String(error)), 'error'))
|
|
119
110
|
return
|
|
120
111
|
}
|
|
121
112
|
await loop.update(current => ({ ...current, note: { context, dir: shift.dir, files: [FAILURE_NOTE] } }))
|
|
122
113
|
}
|
|
123
114
|
|
|
124
|
-
// The owner spoke: the count of shifts without them starts over.
|
|
125
|
-
export async function ownerSpoke(loop: Loop): Promise<void> {
|
|
126
|
-
await loop.update(state => ({ ...state, streak: 0 }))
|
|
127
|
-
}
|
|
128
|
-
|
|
129
115
|
// The note waiting for the owner's message, if any, and what clears it once it went with that message: a failed
|
|
130
116
|
// delivery keeps it for the next one.
|
|
131
117
|
export async function waitingNote(loop: Loop): Promise<{ context: string; delivered: () => Promise<void> } | null> {
|
package/core/texts/doctrine.ts
CHANGED
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
KNOWLEDGE_MAX_LINES,
|
|
21
21
|
LETTER,
|
|
22
22
|
LETTER_SECTIONS,
|
|
23
|
-
MAX_AUTO_STREAK,
|
|
24
23
|
MOD,
|
|
25
24
|
NAME_RULE,
|
|
26
25
|
NAMES,
|
|
@@ -207,7 +206,7 @@ First the flow of a shift, then the rules of each record it checks.
|
|
|
207
206
|
- \`about\` — one line up to ${ABOUT_MAX} characters: what the stretch did and where you stand. This is the history line you will look the stretch up by, and it comes back after the next shifts: write the work, not whether you continue or wait.
|
|
208
207
|
4. End the turn, no further actions: with \`continue\` — one line; with \`wait\` — your answer to the owner, whole: what you did and found, what you ask them to decide. The owner reads that message, not your letter or records.
|
|
209
208
|
|
|
210
|
-
After the shift, the first message is "Shift done": the board and the tasks in progress, whole, with their notes listed, and the map of knowledge — \`${SHIFT_FILE}\`, \`${OWNER}\`, \`${GLOSSARY}\` and \`${TASK_LIST}\` are read again into the session's own block; then the descriptions of the last ${RECENT_SHIFTS} shifts, an open task unchanged through ${STUCK_SHIFTS} shifts and the documents with remarks, if any; your letter last. Continue from "${NEXT}". With \`wait\` they come together with the owner's next message.
|
|
209
|
+
After the shift, the first message is "Shift done": the board and the tasks in progress, whole, with their notes listed, and the map of knowledge — \`${SHIFT_FILE}\`, \`${OWNER}\`, \`${GLOSSARY}\` and \`${TASK_LIST}\` are read again into the session's own block; then the descriptions of the last ${RECENT_SHIFTS} shifts, an open task unchanged through ${STUCK_SHIFTS} shifts and the documents with remarks, if any; your letter last. Continue from "${NEXT}". With \`wait\` they come together with the owner's next message.
|
|
211
210
|
|
|
212
211
|
## Letter — \`${LETTER}\`
|
|
213
212
|
|
|
@@ -241,7 +240,7 @@ The mod looks at the records around every tool you run. A record you changed —
|
|
|
241
240
|
description: <about from the call>
|
|
242
241
|
at: <ISO time of the shift, UTC>
|
|
243
242
|
after: continue | wait
|
|
244
|
-
result: pending | shifted (<before> → <after>), continuing | shifted (…), waiting for the owner |
|
|
243
|
+
result: pending | shifted (<before> → <after>), continuing | shifted (…), waiting for the owner | not shifted: <reason> | let go, not settled: <reason>
|
|
245
244
|
tokens: <before> → <after>
|
|
246
245
|
summary_chars: <size of summary.md>
|
|
247
246
|
session: <session id>
|
package/core/texts/rows.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated from core/src by scripts/sync-core.ts — edit the source, not this copy.
|
|
2
|
-
import {
|
|
2
|
+
import { NAMES, TASK_LIST } from '../layout'
|
|
3
3
|
|
|
4
4
|
// The owner's rows in the transcript: what became of a shift. Short, one line each.
|
|
5
5
|
|
|
@@ -12,8 +12,8 @@ export const NOT_MADE = (name: string, why: string) => `shift ${name} not made
|
|
|
12
12
|
export const CONTINUING = (name: string, shrank: string, dir: string) =>
|
|
13
13
|
`shift ${name} done (${shrank}), continuing from the letter — ${dir}/${NAMES.letter}`
|
|
14
14
|
|
|
15
|
-
export const WAITING = (name: string, shrank: string
|
|
16
|
-
`shift ${name} done (${shrank})
|
|
15
|
+
export const WAITING = (name: string, shrank: string) =>
|
|
16
|
+
`shift ${name} done (${shrank}) — waiting for you, the letter goes with your next message`
|
|
17
17
|
|
|
18
18
|
export const UNSETTLED = (name: string, why: string) =>
|
|
19
19
|
`shift ${name}: the history was let go, but the message after it failed — ${why}; the letter is in the shift's folder`
|
package/core/types.ts
CHANGED
|
@@ -126,4 +126,4 @@ export type PendingShift = {
|
|
|
126
126
|
export type WaitNote = { context: string; dir: string; files: string[] }
|
|
127
127
|
|
|
128
128
|
// What follows a let-go: the agent goes on from the prompt, or the note waits for the owner; the row tells the owner.
|
|
129
|
-
export type Settled = { after: 'continue';
|
|
129
|
+
export type Settled = { after: 'continue'; prompt: string; row: string } | { after: 'wait'; note: WaitNote; row: string }
|
package/index.ts
CHANGED
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
gaugeStatus,
|
|
20
20
|
letGoGauge,
|
|
21
21
|
MOD,
|
|
22
|
-
ownerSpoke,
|
|
23
22
|
RESUME_COMMAND,
|
|
24
23
|
RESUME_DESCRIPTION,
|
|
25
24
|
resumeShift,
|
|
@@ -122,11 +121,9 @@ export default function shift(pi: ExtensionAPI): void {
|
|
|
122
121
|
loop = { ...loop, note: last?.type === 'custom' ? ((last.data as { note: WaitNote | null } | undefined)?.note ?? null) : null }
|
|
123
122
|
})
|
|
124
123
|
|
|
125
|
-
// The owner's own input
|
|
126
|
-
|
|
127
|
-
pi.on('input', async (event, ctx) => {
|
|
124
|
+
// The owner's own input: only a message that starts a run takes the waiting letter with it.
|
|
125
|
+
pi.on('input', async (event, _ctx) => {
|
|
128
126
|
if (!enabled || event.source === 'extension') return
|
|
129
|
-
await ownerSpoke(loopOf(ctx))
|
|
130
127
|
if (event.streamingBehavior === undefined) ownerTyped = true
|
|
131
128
|
})
|
|
132
129
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iiiokojiadbi/shift",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "The agent decides by itself when to shift: it keeps a work board and task folders, writes a letter to itself, and continues from where it stopped.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|