@iiiokojiadbi/shift 0.28.0 → 0.30.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/README.md CHANGED
@@ -6,7 +6,7 @@ The agent decides by itself when to **shift**. At a stage boundary it updates it
6
6
  pi install npm:@iiiokojiadbi/shift
7
7
  ```
8
8
 
9
- The extension adds a "Shift" section to the system prompt, the `shift` tool with its companions (`shift_guide`, `shift_status`, `shift_history`, `shift_setup`, `task_open`, `task_track`, `task_archive`, `doc_outline`, `docs_mentioning`), and two commands: `/shift-tasks` lists the open tasks, `/unshift` picks up the last shift in a fresh session. It hints a shift as the history grows.
9
+ The extension adds a "Shift" section to the system prompt, the `shift` tool with its companions (`shift_guide`, `shift_status`, `shift_history`, `shift_setup`, `task_open`, `task_track`, `task_archive`, `doc_outline`, `docs_mentioning`), and three commands: `/shift` asks the agent to shift now, `/shift-tasks` lists the open tasks, `/unshift` picks up the last shift in a fresh session. It hints a shift as the history grows.
10
10
 
11
11
  The records live in the project's `.shift/` folder and stay out of its git unless `commit = true` in `.shift/settings.toml`.
12
12
 
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, or wait — asked for, or forced after
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' && !isCapped) {
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
- const why = isCapped ? `waiting: ${MAX_AUTO_STREAK} shifts in a row without the owner` : 'waiting for the owner'
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, isCapped) }
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,8 +26,7 @@ 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
29
+ export const SHIFT_COMMAND = 'shift'
31
30
 
32
31
  // The board is the state of the work; past this it has turned into a diary.
33
32
  export const BOARD_MAX_LINES = 150
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, streak: 0, note: 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
- // within the same count of runs without the owner; otherwise with the owner's next message.
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
- const { streak } = await loop.read()
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> {
@@ -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. ${MAX_AUTO_STREAK} \`continue\` in a row without the owner — the mod then waits for the owner itself.
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 | shifted (…), waiting: … in a row without the owner | not shifted: <reason> | let go, not settled: <reason>
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>
@@ -18,8 +18,10 @@ import {
18
18
  OWNER,
19
19
  RESUME_COMMAND,
20
20
  SETTINGS,
21
+ SHIFT_COMMAND,
21
22
  TASK_LIST,
22
23
  TASKS,
24
+ TOOL,
23
25
  TRACK_TOOL,
24
26
  } from '../layout'
25
27
  import { frontmatter } from '../markdown'
@@ -225,6 +227,10 @@ export function resumePrompt(letter: string, back: HandedBack): string {
225
227
  // What starts the turn after /unshift when the owner wrote nothing with it: the letter is already in the history.
226
228
  export const RESUME_GO = `<${MOD} note="from the mod after /${RESUME_COMMAND}">Pick up from the shift above: continue from "${NEXT}".</${MOD}>`
227
229
 
230
+ // The owner's /shift: their word to shift now, the first hint or not, with what they typed after the command.
231
+ export const SHIFT_NOW = (words: string) =>
232
+ `<${MOD} note="from the owner's /${SHIFT_COMMAND}">The owner asks you to shift now, whether a hint has come or not. Bring the step in hand to a point the letter can name, keep your records, write the letter and call ${TOOL}; choose after as the work needs.${words === '' ? '' : ` The owner's words: ${words}`}</${MOD}>`
233
+
228
234
  // How the turn ends once a shift is accepted. The owner reads the turn's last message, not the letter or the records:
229
235
  // with `wait` it is the answer they come back to.
230
236
  const TURN_END: Record<ShiftAfter, string> = {
@@ -1,5 +1,5 @@
1
1
  // Generated from core/src by scripts/sync-core.ts — edit the source, not this copy.
2
- import { MAX_AUTO_STREAK, NAMES, TASK_LIST } from '../layout'
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, capped: boolean) =>
16
- `shift ${name} done (${shrank})${capped ? `, ${MAX_AUTO_STREAK} in a row without you` : ''} — waiting for you, the letter goes with your next message`
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`
@@ -36,6 +36,8 @@ export const SETUP_DESCRIPTION =
36
36
 
37
37
  export const TASKS_DESCRIPTION = 'The open tasks and the items of those in progress, read from .shift/; the agent is not asked'
38
38
 
39
+ export const SHIFT_NOW_DESCRIPTION = 'Ask the agent to shift now; words typed after it go to the agent with the ask'
40
+
39
41
  export const RESUME_DESCRIPTION = 'Pick up the work from the last shift: the letter, the board and the tasks in progress go to the agent'
40
42
 
41
43
  export const SETUP_SCHEMA = { type: 'object', properties: {} }
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'; streak: number; prompt: string; row: string } | { after: 'wait'; note: WaitNote; row: string }
129
+ export type Settled = { after: 'continue'; prompt: string; row: string } | { after: 'wait'; note: WaitNote; row: string }
package/index.ts CHANGED
@@ -19,11 +19,13 @@ import {
19
19
  gaugeStatus,
20
20
  letGoGauge,
21
21
  MOD,
22
- ownerSpoke,
23
22
  RESUME_COMMAND,
24
23
  RESUME_DESCRIPTION,
25
24
  resumeShift,
26
25
  SETTINGS,
26
+ SHIFT_COMMAND,
27
+ SHIFT_NOW,
28
+ SHIFT_NOW_DESCRIPTION,
27
29
  SOURCES,
28
30
  sessionDoctrine,
29
31
  sessionFiles,
@@ -91,6 +93,15 @@ export default function shift(pi: ExtensionAPI): void {
91
93
  handler: async (_args, ctx) => ctx.ui.notify(await tasksView(await projectAt(ctx.cwd)), 'info'),
92
94
  })
93
95
 
96
+ pi.registerCommand(SHIFT_COMMAND, {
97
+ description: SHIFT_NOW_DESCRIPTION,
98
+ handler: async (args, ctx) => {
99
+ if (!enabled) return ctx.ui.notify(`${MOD} is off in this project: ${SETTINGS} has enabled = false.`, 'info')
100
+ // Typed mid-run, it waits for the run to end, as Claude Code holds a command until the turn is over.
101
+ pi.sendUserMessage(SHIFT_NOW(args.trim()), ctx.isIdle() ? undefined : { deliverAs: 'followUp' })
102
+ },
103
+ })
104
+
94
105
  pi.registerCommand(RESUME_COMMAND, {
95
106
  description: RESUME_DESCRIPTION,
96
107
  // The owner's words typed with the command go after the letter, as their own message that starts the turn.
@@ -122,11 +133,9 @@ export default function shift(pi: ExtensionAPI): void {
122
133
  loop = { ...loop, note: last?.type === 'custom' ? ((last.data as { note: WaitNote | null } | undefined)?.note ?? null) : null }
123
134
  })
124
135
 
125
- // The owner's own input, idle or typed mid-run, starts the count of shifts without them over; only a message that
126
- // starts a run takes the waiting letter with it.
127
- pi.on('input', async (event, ctx) => {
136
+ // The owner's own input: only a message that starts a run takes the waiting letter with it.
137
+ pi.on('input', async (event, _ctx) => {
128
138
  if (!enabled || event.source === 'extension') return
129
- await ownerSpoke(loopOf(ctx))
130
139
  if (event.streamingBehavior === undefined) ownerTyped = true
131
140
  })
132
141
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iiiokojiadbi/shift",
3
- "version": "0.28.0",
3
+ "version": "0.30.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",