@iiiokojiadbi/shift 0.38.1 → 0.38.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 (2) hide show
  1. package/core/sizes.ts +31 -27
  2. package/package.json +1 -1
package/core/sizes.ts CHANGED
@@ -21,28 +21,21 @@ import { sessionDoctrine } from './tools'
21
21
  export async function sizeReport(project: Project, counter?: (text: string) => number): Promise<string> {
22
22
  if (!project.settings.enabled) return 'Shift is disabled in this project.'
23
23
  const count = counter ?? ((text: string) => Math.ceil(text.length / 4))
24
- const lines = [
25
- counter ? 'Text tokens (o200k_base).' : 'Estimated text tokens (4 characters per token).',
26
- 'Totals include message framing written by Shift. Detail and saved-letter rows are not additive.',
27
- '',
28
- '| Delivery | Entity | Tokens |',
29
- '|---|---|---:|',
30
- ]
31
- const row = (group: string, label: string, tokens: number) =>
32
- lines.push(`| ${group} | ${label.replaceAll('|', '\\|').replace(/[\r\n]/g, ' ')} | ${tokens} |`)
24
+ const sessionRows: string[] = []
25
+ const continueRows: string[] = []
26
+ const row = (label: string, tokens: number) => `${String(tokens).padStart(7)} ${label.replace(/[\r\n]/g, ' ')}`
33
27
  const files = await sessionFiles(project, { refresh: false })
34
28
  const doctrine = sessionDoctrine(project.settings).doctrine
35
- row('Session', 'Doctrine', count(doctrine))
29
+ sessionRows.push(row('Doctrine', count(doctrine)))
36
30
  for (const file of files) {
37
- row('Session', file.path, count(fileBlock(file.path, file.text)))
31
+ sessionRows.push(row(file.path, count(fileBlock(file.path, file.text))))
38
32
  if (file.path === project.settings.files.shift) {
39
33
  const parts = file.text.split('\n')
40
34
  const { start, end } = mapBounds(parts)
41
- if (end >= 0) row('Included above', 'Documentation map', count(parts.slice(start, end + 1).join('\n')))
35
+ if (end >= 0) sessionRows.push(row(' of which: documentation map', count(parts.slice(start, end + 1).join('\n'))))
42
36
  }
43
37
  }
44
38
  const session = count([doctrine, renderSessionFiles(files)].filter(Boolean).join('\n\n'))
45
- row('Total', 'Session', session)
46
39
  const folders = (await shiftNames(project)).reverse()
47
40
  const saved: { name: string; letter: string }[] = []
48
41
  for (const name of folders) {
@@ -53,25 +46,36 @@ export async function sizeReport(project: Project, counter?: (text: string) => n
53
46
  const dir = `${project.root}/${SHIFTS}/${saved[0]?.name ?? '<next-shift>'}`
54
47
  const back = await handBack(project, dir)
55
48
  if (back.work) {
56
- row('Continue', BOARD, count(back.work.board))
49
+ continueRows.push(row(BOARD, count(back.work.board)))
57
50
  for (const task of inProgress(back.work)) {
58
51
  const folder = `${TASKS}/${task.name}`
59
- row('Continue', `${folder}/${NAMES.task}`, count(task.task ?? 'missing'))
60
- row('Continue', `${folder}/${NAMES.track}`, count(trackPreview(task.track ?? 'missing')))
61
- if (task.notes.length) row('Continue', `${folder}/notes (descriptions)`, count(notesList(task.name, task.notes)))
52
+ continueRows.push(row(`${folder}/${NAMES.task}`, count(task.task ?? 'missing')))
53
+ continueRows.push(row(`${folder}/${NAMES.track}`, count(trackPreview(task.track ?? 'missing'))))
54
+ if (task.notes.length) continueRows.push(row(`${folder}/notes (descriptions)`, count(notesList(task.name, task.notes))))
62
55
  }
63
- row('Continue', 'Knowledge index', count(knowledgeMap(back.work.knowledge)))
56
+ continueRows.push(row('Knowledge index', count(knowledgeMap(back.work.knowledge))))
64
57
  }
65
- row('Continue', 'Recent shifts', count(renderRecent(back.recent)))
66
- if (back.stuck.length) row('Continue', 'Unchanged tasks', count(renderStuck(back.stuck)))
67
- if (back.remarks) row('Continue', 'Document remarks', count(back.remarks))
58
+ continueRows.push(row('Recent shifts', count(renderRecent(back.recent))))
59
+ if (back.stuck.length) continueRows.push(row('Unchanged tasks', count(renderStuck(back.stuck))))
60
+ if (back.remarks) continueRows.push(row('Document remarks', count(back.remarks)))
68
61
  const draft = await project.store.read(`${project.root}/${LETTER}`)
69
62
  const letter = draft ?? saved[0]?.letter ?? ''
70
- row('Continue', draft !== null ? 'Working letter' : saved.length ? 'Latest saved letter' : 'Letter (missing)', count(letter))
63
+ continueRows.push(row(draft !== null ? 'Working letter' : saved.length ? 'Latest saved letter' : 'Letter (missing)', count(letter)))
71
64
  const continuation = count(continuePrompt(letter, back))
72
- row('Total', 'Continue message', continuation)
73
- row('Total', 'Session + continue', session + continuation)
74
- for (const entry of saved) row('Saved letter', `${SHIFTS}/${entry.name}/${NAMES.letter}`, count(entry.letter))
75
- if (!saved.length) lines.push('', 'No saved letters.')
76
- return lines.join('\n')
65
+ return [
66
+ counter ? 'Text tokens (o200k_base).' : 'Estimated text tokens (4 characters per token).',
67
+ row('Session + continue', session + continuation),
68
+ '',
69
+ row('Session', session),
70
+ ...sessionRows,
71
+ '',
72
+ row('Continue message', continuation),
73
+ ...continueRows,
74
+ '',
75
+ 'Totals include message framing.',
76
+ '',
77
+ ...(saved.length
78
+ ? [`Saved letters in ${SHIFTS}/ (outside total)`, ...saved.map(entry => row(entry.name, count(entry.letter)))]
79
+ : ['No saved letters.']),
80
+ ].join('\n')
77
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iiiokojiadbi/shift",
3
- "version": "0.38.1",
3
+ "version": "0.38.2",
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",