@litfamily/litgravity 0.1.0 → 0.1.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.
- package/CHANGELOG.md +32 -0
- package/README.md +72 -17
- package/README_ko-KR.md +72 -17
- package/package.json +1 -1
- package/plugin/hooks/lib/lanes.mjs +65 -0
- package/plugin/hooks/lib/motion.mjs +34 -5
- package/plugin/hooks/lib/reentry.mjs +7 -0
- package/plugin/hooks/lib/rewind/brief.mjs +332 -0
- package/plugin/hooks/lib/rewind/collect.mjs +328 -0
- package/plugin/hooks/lib/rewind/gauge.mjs +55 -0
- package/plugin/hooks/lib/rewind/next-step.mjs +77 -0
- package/plugin/hooks/lib/rewind/redact.mjs +60 -0
- package/plugin/hooks/lib/rewind/transcripts.mjs +211 -0
- package/plugin/hooks/lib/routes.mjs +79 -5
- package/plugin/hooks/lib/workflow-stack.mjs +213 -0
- package/plugin/hooks/post-tool-use.mjs +37 -1
- package/plugin/hooks/pre-invocation.mjs +91 -2
- package/plugin/hooks/session-start.mjs +26 -3
- package/plugin/hooks/stop.mjs +22 -2
- package/plugin/hud/looks.mjs +29 -0
- package/plugin/hud/render.mjs +234 -12
- package/plugin/plugin.json +1 -1
- package/plugin/skills/frontend-ui-ux/SKILL.md +12 -1
- package/plugin/skills/frontend-ui-ux/kit/components.css +417 -0
- package/plugin/skills/frontend-ui-ux/kit/fonts.json +22 -0
- package/plugin/skills/frontend-ui-ux/kit/layouts/landing.html +164 -0
- package/plugin/skills/frontend-ui-ux/kit/layouts/settings.html +114 -0
- package/plugin/skills/frontend-ui-ux/kit/layouts/workspace.html +115 -0
- package/plugin/skills/frontend-ui-ux/kit/styles/computational-brutalism.json +227 -0
- package/plugin/skills/frontend-ui-ux/kit/styles/field-notes.json +205 -0
- package/plugin/skills/frontend-ui-ux/kit/styles/graphite.json +200 -0
- package/plugin/skills/frontend-ui-ux/kit/styles/meadow.json +199 -0
- package/plugin/skills/frontend-ui-ux/kit/styles/neo-brutalism.json +222 -0
- package/plugin/skills/frontend-ui-ux/kit/ui.js +226 -0
- package/plugin/skills/frontend-ui-ux/references/house-styles.md +234 -0
- package/plugin/skills/frontend-ui-ux/scripts/design-lock.mjs +400 -0
- package/plugin/skills/frontend-ui-ux/scripts/interface-probe-lock.mjs +196 -0
- package/plugin/skills/frontend-ui-ux/scripts/interface-probe-page.mjs +30 -9
- package/plugin/skills/frontend-ui-ux/scripts/interface-probe-rules.mjs +20 -8
- package/plugin/skills/frontend-ui-ux/scripts/interface-probe.mjs +42 -9
- package/plugin/skills/frontend-ui-ux/scripts/pixel-art.mjs +60 -0
- package/plugin/skills/lit-adhd/SKILL.md +157 -0
- package/plugin/skills/lit-adhd/references/card-examples.md +101 -0
- package/plugin/skills/lit-adhd/references/status-taxonomy.md +32 -0
- package/plugin/skills/lit-adhd/scripts/rewind.mjs +5 -0
- package/plugin/skills/lit-diagram-drawer/SKILL.md +5 -3
- package/plugin/skills/lit-diagram-drawer/references/drawing-rules.md +1 -1
- package/plugin/skills/lit-diagram-drawer/references/style-guide.md +21 -12
- package/plugin/skills/lit-diagram-drawer/references/type-architecture.md +3 -3
- package/plugin/skills/lit-diagram-drawer/references/type-dependency.md +1 -1
- package/plugin/skills/lit-diagram-drawer/references/type-tree.md +3 -3
- package/plugin/skills/lit-diagram-drawer/references/type-wardley.md +1 -1
- package/plugin/skills/lit-diagram-drawer/scripts/diagram-craft-rules.mjs +1 -2
- package/plugin/skills/lit-diagram-drawer/scripts/visual-quality.mjs +1 -2
- package/plugin/skills/lit-docx/SKILL.md +3 -3
- package/plugin/skills/lit-handoff/SKILL.md +1 -0
- package/plugin/skills/lit-hijack/SKILL.md +263 -0
- package/plugin/skills/lit-hijack/references/capture-and-provenance.md +100 -0
- package/plugin/skills/lit-hijack/references/clean-room-build.md +75 -0
- package/plugin/skills/lit-hijack/references/distil-and-licence.md +67 -0
- package/plugin/skills/lit-hijack/references/gap-and-port-design.md +100 -0
- package/plugin/skills/lit-hijack/references/parity-and-report.md +85 -0
- package/plugin/skills/lit-hijack/scripts/hijack.mjs +953 -0
- package/plugin/skills/lit-plan/SKILL.md +1 -1
- package/plugin/skills/lit-pptx/SKILL.md +8 -8
- package/plugin/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Bold.ttf +0 -0
- package/plugin/skills/lit-pptx/fonts/jetbrains-mono/JetBrainsMono-Regular.ttf +0 -0
- package/plugin/skills/lit-pptx/fonts/jetbrains-mono/OFL.txt +93 -0
- package/plugin/skills/lit-pptx/fonts/provenance.json +32 -1
- package/plugin/skills/lit-pptx/references/agents/analyst.md +34 -56
- package/plugin/skills/lit-pptx/references/agents/antithesis.md +49 -67
- package/plugin/skills/lit-pptx/references/agents/architect.md +38 -51
- package/plugin/skills/lit-pptx/references/agents/critic.md +25 -41
- package/plugin/skills/lit-pptx/references/agents/synthesizer.md +37 -46
- package/plugin/skills/lit-pptx/references/agents/thesis.md +29 -49
- package/plugin/skills/lit-pptx/references/anti-slop-checklist.md +119 -145
- package/plugin/skills/lit-pptx/references/authoring-guide.md +187 -278
- package/plugin/skills/lit-pptx/references/consensus-protocol.md +99 -97
- package/plugin/skills/lit-pptx/references/data-display-cookbook.md +36 -137
- package/plugin/skills/lit-pptx/references/density-and-fill.md +147 -216
- package/plugin/skills/lit-pptx/references/design-system-azure.md +56 -85
- package/plugin/skills/lit-pptx/references/direction-step.md +134 -176
- package/plugin/skills/lit-pptx/references/examples/01-pitch-signal-ko.md +114 -115
- package/plugin/skills/lit-pptx/references/examples/02-pitch-studio-ko.md +66 -66
- package/plugin/skills/lit-pptx/references/examples/03-business-review-ledger-ko.md +63 -63
- package/plugin/skills/lit-pptx/references/examples/04-business-review-night-en.md +96 -96
- package/plugin/skills/lit-pptx/references/examples/05-research-talk-paper-en.md +81 -81
- package/plugin/skills/lit-pptx/references/examples/06-lecture-chalk-ko.md +103 -103
- package/plugin/skills/lit-pptx/references/examples/07-data-review-night-en.md +100 -98
- package/plugin/skills/lit-pptx/references/examples/08-image-led-atlas-ko.md +76 -76
- package/plugin/skills/lit-pptx/references/examples/09-briefing-gazette-ko.md +96 -96
- package/plugin/skills/lit-pptx/references/examples/10-status-update-ledger-ko.md +80 -80
- package/plugin/skills/lit-pptx/references/examples/11-portfolio-studio-en.md +72 -72
- package/plugin/skills/lit-pptx/references/examples/12-research-tutorial-chalk-en.md +95 -95
- package/plugin/skills/lit-pptx/references/examples/13-engineering-review-computational-brutalism-ko.md +173 -0
- package/plugin/skills/lit-pptx/references/examples/14-launch-pitch-neo-brutalism-ko.md +154 -0
- package/plugin/skills/lit-pptx/references/examples/15-design-lecture-bauhaus-ko.md +139 -0
- package/plugin/skills/lit-pptx/references/examples/16-community-programme-riso-ko.md +158 -0
- package/plugin/skills/lit-pptx/references/examples/17-public-data-briefing-newsroom-ko.md +179 -0
- package/plugin/skills/lit-pptx/references/interview-protocol.md +83 -102
- package/plugin/skills/lit-pptx/references/layout-families.md +161 -265
- package/plugin/skills/lit-pptx/references/stages/autopilot.md +30 -70
- package/plugin/skills/lit-pptx/references/stages/interview.md +36 -68
- package/plugin/skills/lit-pptx/references/stages/plan.md +26 -67
- package/plugin/skills/lit-pptx/references/title-treatments.md +93 -145
- package/plugin/skills/lit-pptx/references/tonalities/atlas.md +95 -108
- package/plugin/skills/lit-pptx/references/tonalities/bauhaus.md +140 -0
- package/plugin/skills/lit-pptx/references/tonalities/chalk.md +107 -122
- package/plugin/skills/lit-pptx/references/tonalities/computational-brutalism.md +150 -0
- package/plugin/skills/lit-pptx/references/tonalities/gazette.md +87 -111
- package/plugin/skills/lit-pptx/references/tonalities/ledger.md +96 -125
- package/plugin/skills/lit-pptx/references/tonalities/neo-brutalism.md +161 -0
- package/plugin/skills/lit-pptx/references/tonalities/newsroom.md +144 -0
- package/plugin/skills/lit-pptx/references/tonalities/night.md +104 -131
- package/plugin/skills/lit-pptx/references/tonalities/paper.md +114 -130
- package/plugin/skills/lit-pptx/references/tonalities/riso.md +137 -0
- package/plugin/skills/lit-pptx/references/tonalities/signal.md +96 -103
- package/plugin/skills/lit-pptx/references/tonalities/studio.md +81 -112
- package/plugin/skills/lit-pptx/scripts/compile-deck.js +4 -6
- package/plugin/skills/lit-pptx/scripts/craft_extras.py +135 -91
- package/plugin/skills/lit-pptx/scripts/deck_craft.py +1 -1
- package/plugin/skills/lit-pptx/scripts/embed_fonts.py +13 -1
- package/plugin/skills/lit-pptx/scripts/layout_inventory.py +1 -1
- package/plugin/skills/lit-pptx/scripts/learn_template.py +1 -1
- package/plugin/skills/lit-pptx/scripts/lib/grid-resolver.js +101 -110
- package/plugin/skills/lit-pptx/scripts/lib/layout-resolver.js +9 -15
- package/plugin/skills/lit-pptx/scripts/lib/render-pack.js +370 -563
- package/plugin/skills/lit-pptx/scripts/lib/slide-grid.js +104 -0
- package/plugin/skills/lit-pptx/scripts/lib/template-registry.js +57 -6
- package/plugin/skills/lit-pptx/scripts/qa_deck.py +6 -6
- package/plugin/skills/lit-pptx/scripts/render_pages.py +31 -0
- package/plugin/skills/lit-pptx/scripts/validate_pptx.py +1 -1
- package/plugin/skills/lit-pptx/specs/markdown-slide-spec-v1.md +167 -191
- package/plugin/skills/lit-pptx/specs/markdown-slide-spec-v2.md +117 -166
- package/plugin/skills/lit-pptx/specs/template-enrollment-contract.md +307 -330
- package/plugin/skills/lit-pptx/templates/tonalities/atlas/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/bauhaus/pack.yaml +98 -0
- package/plugin/skills/lit-pptx/templates/tonalities/chalk/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/computational-brutalism/pack.yaml +99 -0
- package/plugin/skills/lit-pptx/templates/tonalities/gazette/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/ledger/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/neo-brutalism/pack.yaml +107 -0
- package/plugin/skills/lit-pptx/templates/tonalities/newsroom/pack.yaml +99 -0
- package/plugin/skills/lit-pptx/templates/tonalities/night/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/paper/pack.yaml +1 -1
- package/plugin/skills/lit-pptx/templates/tonalities/riso/pack.yaml +99 -0
- package/plugin/skills/lit-pptx/templates/tonalities/signal/pack.yaml +2 -2
- package/plugin/skills/lit-pptx/templates/tonalities/studio/pack.yaml +1 -1
- package/plugin/skills/lit-schematic/SKILL.md +114 -0
- package/plugin/skills/lit-schematic/examples/iso-heat-exchanger/build.mjs +38 -0
- package/plugin/skills/lit-schematic/examples/iso-heat-exchanger/scene.mjs +133 -0
- package/plugin/skills/lit-schematic/examples/journal-adsorption-rig/build.mjs +87 -0
- package/plugin/skills/lit-schematic/examples/pid-dosing-skid/build.mjs +85 -0
- package/plugin/skills/lit-schematic/references/cutaway-outputs.md +70 -0
- package/plugin/skills/lit-schematic/references/isometric-craft.md +101 -0
- package/plugin/skills/lit-schematic/references/journal-figures.md +72 -0
- package/plugin/skills/lit-schematic/references/kit-api.md +134 -0
- package/plugin/skills/lit-schematic/references/pfd-and-layout.md +53 -0
- package/plugin/skills/lit-schematic/references/pid-drafting.md +103 -0
- package/plugin/skills/lit-schematic/references/pid-symbols.md +163 -0
- package/plugin/skills/lit-schematic/references/verification.md +100 -0
- package/plugin/skills/lit-schematic/scripts/doctor.mjs +57 -0
- package/plugin/skills/lit-schematic/scripts/lib/figure.mjs +81 -0
- package/plugin/skills/lit-schematic/scripts/lib/fonts.mjs +27 -0
- package/plugin/skills/lit-schematic/scripts/lib/geom.mjs +113 -0
- package/plugin/skills/lit-schematic/scripts/lib/interactive.mjs +292 -0
- package/plugin/skills/lit-schematic/scripts/lib/isa.mjs +115 -0
- package/plugin/skills/lit-schematic/scripts/lib/iso.mjs +719 -0
- package/plugin/skills/lit-schematic/scripts/lib/legend-sheet.mjs +162 -0
- package/plugin/skills/lit-schematic/scripts/lib/pid.mjs +937 -0
- package/plugin/skills/lit-schematic/scripts/lib/png.mjs +132 -0
- package/plugin/skills/lit-schematic/scripts/lib/qa-core.mjs +658 -0
- package/plugin/skills/lit-schematic/scripts/lib/route.mjs +218 -0
- package/plugin/skills/lit-schematic/scripts/lib/sheet.mjs +890 -0
- package/plugin/skills/lit-schematic/scripts/lib/svg.mjs +82 -0
- package/plugin/skills/lit-schematic/scripts/lib/theme.mjs +115 -0
- package/plugin/skills/lit-schematic/scripts/motion.mjs +129 -0
- package/plugin/skills/lit-schematic/scripts/qa.mjs +92 -0
- package/plugin/skills/lit-schematic/scripts/render.mjs +233 -0
- package/plugin/skills/lit-schematic/scripts/scaffold.mjs +60 -0
- package/plugin/skills/lit-scientific-visualization/SKILL.md +17 -6
- package/plugin/skills/lit-typographic-motion/SKILL.md +58 -48
- package/plugin/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +13 -2
- package/plugin/skills/lit-typographic-motion/engine/blender/runner.py +218 -0
- package/plugin/skills/lit-typographic-motion/engine/core/presets.mjs +1 -1
- package/plugin/skills/lit-typographic-motion/engine/node/analysis.mjs +65 -1
- package/plugin/skills/lit-typographic-motion/engine/node/assets.mjs +298 -0
- package/plugin/skills/lit-typographic-motion/engine/node/blender.mjs +143 -0
- package/plugin/skills/lit-typographic-motion/engine/node/board.mjs +136 -0
- package/plugin/skills/lit-typographic-motion/engine/node/brief.mjs +7 -1
- package/plugin/skills/lit-typographic-motion/engine/node/chrome.mjs +9 -12
- package/plugin/skills/lit-typographic-motion/engine/node/cover-assets.mjs +5 -3
- package/plugin/skills/lit-typographic-motion/engine/node/cover-capture.mjs +7 -6
- package/plugin/skills/lit-typographic-motion/engine/node/cover-treatment.mjs +37 -4
- package/plugin/skills/lit-typographic-motion/engine/node/cover.mjs +19 -8
- package/plugin/skills/lit-typographic-motion/engine/node/done.mjs +45 -6
- package/plugin/skills/lit-typographic-motion/engine/node/frame-worker.mjs +7 -5
- package/plugin/skills/lit-typographic-motion/engine/node/gallery.mjs +121 -0
- package/plugin/skills/lit-typographic-motion/engine/node/host.mjs +34 -0
- package/plugin/skills/lit-typographic-motion/engine/node/house.mjs +44 -0
- package/plugin/skills/lit-typographic-motion/engine/node/look.mjs +34 -20
- package/plugin/skills/lit-typographic-motion/engine/node/pipeline.mjs +19 -9
- package/plugin/skills/lit-typographic-motion/engine/node/scaffold.mjs +210 -0
- package/plugin/skills/lit-typographic-motion/engine/node/score.mjs +639 -0
- package/plugin/skills/lit-typographic-motion/engine/node/sound-cli.mjs +21 -4
- package/plugin/skills/lit-typographic-motion/engine/node/sound.mjs +127 -29
- package/plugin/skills/lit-typographic-motion/engine/node/stage-capture.mjs +7 -6
- package/plugin/skills/lit-typographic-motion/engine/node/stage-gate.mjs +59 -5
- package/plugin/skills/lit-typographic-motion/engine/node/stage-qa.mjs +141 -9
- package/plugin/skills/lit-typographic-motion/engine/node/stage-serve.mjs +28 -5
- package/plugin/skills/lit-typographic-motion/engine/node/stage.mjs +82 -14
- package/plugin/skills/lit-typographic-motion/engine/node/styles.mjs +213 -0
- package/plugin/skills/lit-typographic-motion/engine/node/treatment.mjs +311 -10
- package/plugin/skills/lit-typographic-motion/engine/stage/cover-init.js +14 -2
- package/plugin/skills/lit-typographic-motion/engine/stage/init.js +11 -1
- package/plugin/skills/lit-typographic-motion/engine/stage/qa.js +6 -1
- package/plugin/skills/lit-typographic-motion/engine/stage/stage-kit.js +83 -0
- package/plugin/skills/lit-typographic-motion/engine/vendor/three/LICENSE +21 -0
- package/plugin/skills/lit-typographic-motion/engine/vendor/three/addons/environments/RoomEnvironment.js +144 -0
- package/plugin/skills/lit-typographic-motion/engine/vendor/three/addons/geometries/RoundedBoxGeometry.js +155 -0
- package/plugin/skills/lit-typographic-motion/engine/vendor/three/three.module.js +54571 -0
- package/plugin/skills/lit-typographic-motion/recipes/hero-3d/expected.json +69 -0
- package/plugin/skills/lit-typographic-motion/recipes/hero-3d/index.html +139 -0
- package/plugin/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +6 -4
- package/plugin/skills/lit-typographic-motion/recipes/painted-light/expected.json +4 -2
- package/plugin/skills/lit-typographic-motion/recipes/weight-tide/expected.json +7 -5
- package/plugin/skills/lit-typographic-motion/references/cover.md +394 -443
- package/plugin/skills/lit-typographic-motion/references/craft-loop.md +57 -87
- package/plugin/skills/lit-typographic-motion/references/depth.md +122 -0
- package/plugin/skills/lit-typographic-motion/references/look.md +94 -129
- package/plugin/skills/lit-typographic-motion/references/runtime.md +58 -91
- package/plugin/skills/lit-typographic-motion/references/sound.md +130 -99
- package/plugin/skills/lit-typographic-motion/references/stage.md +190 -215
- package/plugin/skills/lit-typographic-motion/references/studio.md +245 -0
- package/plugin/skills/lit-typographic-motion/references/style-bibles.md +108 -97
- package/plugin/skills/lit-typographic-motion/references/treatment.md +191 -143
- package/plugin/skills/lit-typographic-motion/scripts/motion-doctor.mjs +17 -5
- package/plugin/skills/lit-typographic-motion/scripts/motion.mjs +47 -7
- package/plugin/skills/lit-typographic-motion/styles/paper.json +41 -0
- package/plugin/skills/lit-typographic-motion/styles/swiss-signal.json +41 -0
- package/plugin/skills/lit-typographic-motion/styles/terminalcore.json +42 -0
- package/plugin/skills/lit-typographic-motion/styles/tidal.json +41 -0
- package/plugin/skills/litresearch/SKILL.md +1 -0
- package/plugin/skills/readme-studio/SKILL.md +2 -0
- package/plugin/skills/readme-studio/templates/hyperframes-cover/package-lock.json +3 -3
- package/plugin/skills/readme-studio/templates/remotion-cover/package-lock.json +3 -3
- package/plugin/skills/review-work/SKILL.md +1 -1
- package/plugin/skills/start-work/SKILL.md +1 -1
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
// The lit-adhd brief, drawn by code from the collector's data so the model only copies it and a
|
|
2
|
+
// tired reader finds every part in the same place each time. Markdown, because agy's chat pane
|
|
3
|
+
// renders headings, bold, quotes, tables and code blocks: a headline, a card per live session grouped
|
|
4
|
+
// by folder and branch, a table of ended sessions, the roadmap timeline and one boxed next step.
|
|
5
|
+
// Every string in `data` is already redacted and clipped; this file adds layout and words, never a
|
|
6
|
+
// number the data does not hold, and never a question-mark gauge.
|
|
7
|
+
|
|
8
|
+
import { basename } from 'node:path';
|
|
9
|
+
|
|
10
|
+
import { clipToWidth, displayWidth } from './gauge.mjs';
|
|
11
|
+
|
|
12
|
+
const WORDS = {
|
|
13
|
+
en: {
|
|
14
|
+
sessions: (n) => `${n} ${n === 1 ? 'session' : 'sessions'}`,
|
|
15
|
+
waiting: (n) => `${n} ${n === 1 ? 'waits' : 'wait'} on you`,
|
|
16
|
+
active: (n) => `${n} active`,
|
|
17
|
+
next: 'next',
|
|
18
|
+
window: (since, trees) => `last ${since} · ${trees} ${trees === 1 ? 'folder' : 'folders'} read`,
|
|
19
|
+
badge: { 'waiting-on-user': '🟠 **WAITING ON YOU**', active: '🟢 **ACTIVE**', ended: '⚪ ended', unknown: '⚫ unknown' },
|
|
20
|
+
reason: { 'asked the user': 'it asked you something', 'paused workflow': 'a paused route' },
|
|
21
|
+
ago: (text) => `${text} ago`,
|
|
22
|
+
justNow: 'just now',
|
|
23
|
+
self: 'this conversation',
|
|
24
|
+
worked: (d) => `${d} of work`,
|
|
25
|
+
lastAsk: (text) => `last ask: “${text}”`,
|
|
26
|
+
done: 'Done',
|
|
27
|
+
nextLabel: 'Next',
|
|
28
|
+
noneDone: 'no file writes or commits on record',
|
|
29
|
+
toolsUsed: (list) => `no writes yet; used ${list}`,
|
|
30
|
+
files: 'wrote',
|
|
31
|
+
commits: (n) => `${n} ${n === 1 ? 'commit' : 'commits'}`,
|
|
32
|
+
answer: (q) => (q ? `answer: “${q}”` : 'answer its question'),
|
|
33
|
+
resume: (skill, stage) => `resume ${skill} at ${stage} (\`lit continue\`)`,
|
|
34
|
+
doing: (what) => `now: ${what}`,
|
|
35
|
+
working: 'working',
|
|
36
|
+
nothing: 'nothing open',
|
|
37
|
+
endedTitle: (n) => `Ended · ${n}`,
|
|
38
|
+
endedHead: ['id', 'where', 'goal', 'ago', 'done'],
|
|
39
|
+
moreEnded: (n) => `…and ${n} more ended`,
|
|
40
|
+
roadmap: 'Roadmap',
|
|
41
|
+
now: 'now',
|
|
42
|
+
later: 'later',
|
|
43
|
+
plansOmitted: (n) => `…${n} more open ${n === 1 ? 'plan' : 'plans'}`,
|
|
44
|
+
noRoadmap: 'no open plan, goal or commit in this window',
|
|
45
|
+
recommended: 'RECOMMENDED NEXT STEP',
|
|
46
|
+
type: 'type',
|
|
47
|
+
step: {
|
|
48
|
+
'resume-frame': ({ skill, stage }) => `Resume ${skill} at ${stage}`,
|
|
49
|
+
'continue-work': ({ plan }) => `Keep going on ${plan}`,
|
|
50
|
+
'start-plan': ({ plan }) => `Start ${plan} with start-work`,
|
|
51
|
+
},
|
|
52
|
+
suggest: {
|
|
53
|
+
answer: ({ id8, where, question }) => `Answer ${id8} in ${where}${question ? `: “${question}”` : ''}`,
|
|
54
|
+
resume: ({ id8, skill, stage, where }) => `Resume ${skill} at ${stage} in ${id8} (${where})`,
|
|
55
|
+
plan: ({ plan, item }) => `Next in ${plan}: ${item}`,
|
|
56
|
+
check: ({ id8, goal, where, doing }) => `Check on ${id8} in ${where} (${goal})${doing ? `, now ${doing}` : ''}`,
|
|
57
|
+
pickUp: ({ id8, goal, where }) => `Pick up ${id8} in ${where}: ${goal}`,
|
|
58
|
+
start: () => 'No conversation or plan in this window: say what to start',
|
|
59
|
+
},
|
|
60
|
+
goLine: (say) => `Type **\`${say}\`** to continue.`,
|
|
61
|
+
noGo: 'Nothing runs on its own here: open that conversation, or say what to do.',
|
|
62
|
+
unknownSources: (list) => `Not read: ${list}.`,
|
|
63
|
+
older: 'Older conversations were not read (read budget used up).',
|
|
64
|
+
noSessions: 'No agy conversation of this workspace in this window.',
|
|
65
|
+
units: { d: 'd', h: 'h', m: 'm' },
|
|
66
|
+
},
|
|
67
|
+
ko: {
|
|
68
|
+
sessions: (n) => `세션 ${n}개`,
|
|
69
|
+
waiting: (n) => `나를 기다리는 것 ${n}`,
|
|
70
|
+
active: (n) => `진행 중 ${n}`,
|
|
71
|
+
next: '다음',
|
|
72
|
+
window: (since, trees) => `최근 ${since} · 폴더 ${trees}곳 읽음`,
|
|
73
|
+
badge: { 'waiting-on-user': '🟠 **나를 기다림**', active: '🟢 **진행 중**', ended: '⚪ 끝남', unknown: '⚫ 알 수 없음' },
|
|
74
|
+
reason: { 'asked the user': '질문하고 기다림', 'paused workflow': '멈춘 라우트' },
|
|
75
|
+
ago: (text) => `${text} 전`,
|
|
76
|
+
justNow: '방금',
|
|
77
|
+
self: '이 대화',
|
|
78
|
+
worked: (d) => `${d} 작업`,
|
|
79
|
+
lastAsk: (text) => `마지막 요청: “${text}”`,
|
|
80
|
+
done: '한 일',
|
|
81
|
+
nextLabel: '다음',
|
|
82
|
+
noneDone: '기록된 파일 쓰기·커밋 없음',
|
|
83
|
+
toolsUsed: (list) => `아직 쓰기 없음, 쓴 도구 ${list}`,
|
|
84
|
+
files: '씀',
|
|
85
|
+
commits: (n) => `커밋 ${n}개`,
|
|
86
|
+
answer: (q) => (q ? `답하기: “${q}”` : '질문에 답하기'),
|
|
87
|
+
resume: (skill, stage) => `${skill}(${stage}) 이어가기 (\`lit continue\`)`,
|
|
88
|
+
doing: (what) => `지금: ${what}`,
|
|
89
|
+
working: '작업 중',
|
|
90
|
+
nothing: '열린 일 없음',
|
|
91
|
+
endedTitle: (n) => `끝난 세션 · ${n}`,
|
|
92
|
+
endedHead: ['id', '위치', '목표', '경과', '한 일'],
|
|
93
|
+
moreEnded: (n) => `…끝난 세션 ${n}개 더`,
|
|
94
|
+
roadmap: '로드맵',
|
|
95
|
+
now: '지금',
|
|
96
|
+
later: '나중',
|
|
97
|
+
plansOmitted: (n) => `…열린 계획 ${n}개 더`,
|
|
98
|
+
noRoadmap: '이 기간에 열린 계획·목표·커밋 없음',
|
|
99
|
+
recommended: '추천 다음 단계',
|
|
100
|
+
type: '입력',
|
|
101
|
+
step: {
|
|
102
|
+
'resume-frame': ({ skill, stage }) => `${skill}(${stage}) 이어가기`,
|
|
103
|
+
'continue-work': ({ plan }) => `${plan} 계속 진행`,
|
|
104
|
+
'start-plan': ({ plan }) => `${plan}을 start-work로 시작`,
|
|
105
|
+
},
|
|
106
|
+
suggest: {
|
|
107
|
+
answer: ({ id8, where, question }) => `${where}의 ${id8}에 답하기${question ? `: “${question}”` : ''}`,
|
|
108
|
+
resume: ({ id8, skill, stage, where }) => `${where}의 ${id8}에서 ${skill}(${stage}) 이어가기`,
|
|
109
|
+
plan: ({ plan, item }) => `${plan} 다음 항목: ${item}`,
|
|
110
|
+
check: ({ id8, goal, where, doing }) => `${where}의 ${id8} 확인 (${goal})${doing ? `, 지금 ${doing}` : ''}`,
|
|
111
|
+
pickUp: ({ id8, goal, where }) => `${where}의 ${id8} 이어받기: ${goal}`,
|
|
112
|
+
start: () => '이 기간에 대화·계획이 없습니다. 시작할 일을 말해 주세요',
|
|
113
|
+
},
|
|
114
|
+
goLine: (say) => `**\`${say}\`** 라고 입력하면 이어갑니다.`,
|
|
115
|
+
noGo: '저절로 실행되는 단계는 아닙니다. 그 대화를 열거나 할 일을 말해 주세요.',
|
|
116
|
+
unknownSources: (list) => `읽지 못함: ${list}.`,
|
|
117
|
+
older: '오래된 대화는 읽지 않았습니다(읽기 예산 소진).',
|
|
118
|
+
noSessions: '이 기간에 이 작업 공간의 agy 대화가 없습니다.',
|
|
119
|
+
units: { d: '일', h: '시간', m: '분' },
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const bare = (text) => String(text ?? '').replace(/\s+/gu, ' ').trim();
|
|
124
|
+
// Inline text from the records: no HTML, no code ticks, no table or emphasis syntax.
|
|
125
|
+
const plain = (text) => bare(text).replace(/[<>`]/gu, (ch) => ({ '<': '‹', '>': '›', '`': "'" }[ch])).replace(/[*_|[\]\\]/gu, (ch) => `\\${ch}`);
|
|
126
|
+
const code = (text) => `\`${bare(text).replace(/`/gu, "'")}\``;
|
|
127
|
+
const placeOf = (session) => (session.worktree && session.worktree !== 'unknown' ? basename(String(session.worktree)) : 'unknown');
|
|
128
|
+
const goalOf = (session) => (session.title && session.title !== 'unknown' ? session.title : session.asked?.[0] ?? 'unknown');
|
|
129
|
+
|
|
130
|
+
// The largest unit only, so a table cell never wraps: `14h`, `3d`, `20m`.
|
|
131
|
+
const age = (iso, now, w) => {
|
|
132
|
+
const ms = now - Date.parse(iso);
|
|
133
|
+
if (!Number.isFinite(ms)) return null;
|
|
134
|
+
const minutes = Math.floor(ms / 60_000);
|
|
135
|
+
if (minutes < 1) return w.justNow;
|
|
136
|
+
if (minutes < 60) return `${minutes}${w.units.m}`;
|
|
137
|
+
if (minutes < 48 * 60) return `${Math.floor(minutes / 60)}${w.units.h}`;
|
|
138
|
+
return `${Math.floor(minutes / 1440)}${w.units.d}`;
|
|
139
|
+
};
|
|
140
|
+
const span = (session, w) => {
|
|
141
|
+
const ms = Date.parse(session.last) - Date.parse(session.started);
|
|
142
|
+
if (!Number.isFinite(ms) || ms <= 0) return null;
|
|
143
|
+
const minutes = Math.max(1, Math.round(ms / 60_000));
|
|
144
|
+
return minutes >= 60 ? `${Math.floor(minutes / 60)}${w.units.h} ${minutes % 60}${w.units.m}` : `${minutes}${w.units.m}`;
|
|
145
|
+
};
|
|
146
|
+
const stamp = (iso) => (typeof iso === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/u.test(iso) ? `${iso.slice(5, 10)} ${iso.slice(11, 16)}` : '·');
|
|
147
|
+
|
|
148
|
+
// The last question a conversation asked, from its last model words.
|
|
149
|
+
const lastQuestion = (result, escape = plain) => {
|
|
150
|
+
const found = [...String(result ?? '').matchAll(/[^.!?。?\n]{4,}[??]/gu)].at(-1)?.[0];
|
|
151
|
+
return found ? escape(clipToWidth(bare(found), 90)) : null;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// What the last tool call was about: `run_command`, `write_file “app.mjs”`. Never a command line.
|
|
155
|
+
const actionOf = (session, escape = plain) => {
|
|
156
|
+
const action = session.lastAction;
|
|
157
|
+
if (!action?.tool) return null;
|
|
158
|
+
const tool = escape === plain ? code(action.tool) : escape(action.tool);
|
|
159
|
+
return action.target ? `${tool} “${escape(clipToWidth(bare(action.target), 50))}”` : tool;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const framesOf = (session, data) => (data.workflows ?? []).filter((f) => f.id8 === session.id8);
|
|
163
|
+
|
|
164
|
+
const progressLine = (session, w) => {
|
|
165
|
+
const progress = session.progress;
|
|
166
|
+
if (progress?.gauge) {
|
|
167
|
+
const rest = (progress.remaining ?? []).slice(0, 2).map(plain).join(', ');
|
|
168
|
+
return `📊 ${code(progress.gauge)}${rest ? ` → ${rest}` : ''}`;
|
|
169
|
+
}
|
|
170
|
+
const facts = [span(session, w) ? w.worked(span(session, w)) : null, session.asked?.at(-1) && session.asked.at(-1) !== 'unknown' ? w.lastAsk(plain(clipToWidth(session.asked.at(-1), 70))) : null].filter(Boolean);
|
|
171
|
+
return facts.length ? `⏳ ${facts.join(' · ')}` : null;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const doneLine = (session, w) => {
|
|
175
|
+
const files = (session.done?.files ?? []).slice(0, 3).map((file) => code(basename(String(file))));
|
|
176
|
+
const commits = (session.done?.commits ?? []).slice(0, 2).map(({ hash, subject }) => `${code(hash)} ${plain(clipToWidth(subject, 60))}`);
|
|
177
|
+
const parts = [files.length ? `${w.files} ${files.join(', ')}` : null, commits.length ? `${w.commits(session.done.commits.length)}: ${commits.join('; ')}` : null].filter(Boolean);
|
|
178
|
+
if (parts.length) return parts.join(' · ');
|
|
179
|
+
// The transcript is read head and tail only, so tools are named, never counted.
|
|
180
|
+
const tools = Object.entries(session.done?.tools ?? {}).sort((a, b) => b[1] - a[1]).slice(0, 3).map(([name]) => code(name));
|
|
181
|
+
return tools.length ? w.toolsUsed(tools.join(', ')) : w.noneDone;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const nextOf = (session, data, w) => {
|
|
185
|
+
if (session.status === 'waiting-on-user') {
|
|
186
|
+
const paused = framesOf(session, data).find((f) => f.status === 'paused');
|
|
187
|
+
if (paused) return w.resume(plain(paused.skill), plain(paused.stage));
|
|
188
|
+
return w.answer(lastQuestion(session.result));
|
|
189
|
+
}
|
|
190
|
+
if (session.status === 'active') {
|
|
191
|
+
// A route that recorded no stage says what its last tool call was instead of `unknown`.
|
|
192
|
+
const top = framesOf(session, data).at(-1);
|
|
193
|
+
const stage = top && top.stage !== 'unknown' ? `${plain(top.skill)} · ${plain(top.stage)}` : null;
|
|
194
|
+
const doing = actionOf(session);
|
|
195
|
+
return stage ?? (doing ? w.doing(doing) : w.working);
|
|
196
|
+
}
|
|
197
|
+
return w.nothing;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const sessionCard = (session, data, now, w) => {
|
|
201
|
+
const head = [w.badge[session.status] ?? w.badge.unknown];
|
|
202
|
+
if (session.waitingReason && w.reason[session.waitingReason]) head.push(w.reason[session.waitingReason]);
|
|
203
|
+
head.push(code(session.id8));
|
|
204
|
+
const skill = framesOf(session, data).at(-1)?.skill;
|
|
205
|
+
if (skill) head.push(code(skill));
|
|
206
|
+
const when = age(session.last, now, w);
|
|
207
|
+
if (when) head.push(when === w.justNow ? when : w.ago(when));
|
|
208
|
+
if (session.self) head.push(`**${w.self}**`);
|
|
209
|
+
const lines = [head.join(' · '), `**${plain(clipToWidth(goalOf(session), 80))}**`];
|
|
210
|
+
const progress = progressLine(session, w);
|
|
211
|
+
if (progress) lines.push(progress);
|
|
212
|
+
lines.push(`✅ ${w.done}: ${doneLine(session, w)}`, `▶ ${w.nextLabel}: ${nextOf(session, data, w)}`);
|
|
213
|
+
return lines.map((line) => `> ${line}`).join(' \n');
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// Ended conversations are history: one table row each, newest first, at most eight.
|
|
217
|
+
const ENDED_ROWS = 8;
|
|
218
|
+
const endedTable = (sessions, now, w) => {
|
|
219
|
+
const cell = (text) => plain(text) || '·';
|
|
220
|
+
const rows = sessions.slice(0, ENDED_ROWS).map((session) => {
|
|
221
|
+
const commits = session.done?.commits?.length ?? 0;
|
|
222
|
+
const files = session.done?.files?.length ?? 0;
|
|
223
|
+
const done = commits ? w.commits(commits) : files ? `${w.files} ${files}` : '·';
|
|
224
|
+
return `| ${code(session.id8)} | ${cell(clipToWidth(placeOf(session), 20))} | ${cell(clipToWidth(goalOf(session), 40))} | ${cell(age(session.last, now, w) ?? '·')} | ${cell(done)} |`;
|
|
225
|
+
});
|
|
226
|
+
const more = sessions.length > ENDED_ROWS ? ['', `*${w.moreEnded(sessions.length - ENDED_ROWS)}*`] : [];
|
|
227
|
+
return [`| ${w.endedHead.join(' | ')} |`, `|${w.endedHead.map(() => '---').join('|')}|`, ...rows, ...more];
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
// When nothing can run on `go`, the box still recommends one step from what was read: a conversation
|
|
231
|
+
// that waits on the user, a paused route, an open plan item (a live conversation's folder first), the
|
|
232
|
+
// newest other active conversation, the newest ended one. It is shown, never recorded for `go`.
|
|
233
|
+
const suggestion = (data, w) => {
|
|
234
|
+
const sessions = data.sessions ?? [];
|
|
235
|
+
const where = (session) => bare(placeOf(session));
|
|
236
|
+
const goal = (session) => clipToWidth(bare(goalOf(session)), 50);
|
|
237
|
+
const waiting = sessions.find((s) => s.status === 'waiting-on-user' && !s.self);
|
|
238
|
+
if (waiting) return w.suggest.answer({ id8: waiting.id8, where: where(waiting), question: lastQuestion(waiting.result, bare) });
|
|
239
|
+
const paused = (data.workflows ?? []).find((f) => f.status === 'paused');
|
|
240
|
+
if (paused) {
|
|
241
|
+
const owner = sessions.find((s) => s.id8 === paused.id8);
|
|
242
|
+
return w.suggest.resume({ id8: paused.id8, skill: paused.skill, stage: paused.stage, where: owner ? where(owner) : 'unknown' });
|
|
243
|
+
}
|
|
244
|
+
const live = new Set(sessions.filter((s) => s.status !== 'ended').map((s) => s.worktree));
|
|
245
|
+
const open = (data.roadmap?.plans ?? []).filter((p) => p.current);
|
|
246
|
+
const plan = open.find((p) => live.has(p.worktree)) ?? open.find((p) => p.local) ?? open[0];
|
|
247
|
+
if (plan) return w.suggest.plan({ plan: plan.local ? plan.plan : `${basename(String(plan.worktree))}/${plan.plan}`, item: clipToWidth(bare(plan.current), 60) });
|
|
248
|
+
const active = sessions.find((s) => s.status === 'active' && !s.self);
|
|
249
|
+
if (active) return w.suggest.check({ id8: active.id8, goal: goal(active), where: where(active), doing: actionOf(active, bare) });
|
|
250
|
+
const ended = sessions.find((s) => s.status === 'ended' && !s.self);
|
|
251
|
+
if (ended) return w.suggest.pickUp({ id8: ended.id8, goal: goal(ended), where: where(ended) });
|
|
252
|
+
return w.suggest.start();
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const ROADMAP_COMMITS = 5;
|
|
256
|
+
const roadmapLines = (data, w) => {
|
|
257
|
+
const lines = [];
|
|
258
|
+
for (const commit of (data.commits ?? []).slice(0, ROADMAP_COMMITS).reverse()) {
|
|
259
|
+
lines.push(`- ✓ ${stamp(commit.at)} · ${code(commit.branch)} ${plain(clipToWidth(commit.subject, 70))}`);
|
|
260
|
+
}
|
|
261
|
+
for (const plan of data.roadmap?.plans ?? []) {
|
|
262
|
+
if (!plan.current) continue;
|
|
263
|
+
const where = plan.local ? '' : `${code(basename(String(plan.worktree)))} `;
|
|
264
|
+
const gauge = plan.progress?.gauge ? ` ${code(plan.progress.gauge)}` : '';
|
|
265
|
+
lines.push(`- ▶ ${w.now} · ${where}${code(plan.plan)}${gauge} → ${plain(plan.current)}`);
|
|
266
|
+
for (const item of (plan.progress?.remaining ?? []).slice(1, 3)) lines.push(` - ○ ${w.later} · ${plain(item)}`);
|
|
267
|
+
}
|
|
268
|
+
if (data.roadmap?.plansOmitted) lines.push(`- *${w.plansOmitted(data.roadmap.plansOmitted)}*`);
|
|
269
|
+
for (const goal of data.roadmap?.litgoal ?? []) {
|
|
270
|
+
const gauge = goal.progress?.gauge ? ` ${code(goal.progress.gauge)}` : '';
|
|
271
|
+
lines.push(`- ${goal.status === 'complete' ? '✓' : '▶'} litgoal${gauge} ${plain(clipToWidth(goal.objective, 70))}`);
|
|
272
|
+
}
|
|
273
|
+
return lines.length ? lines : [`- ${w.noRoadmap}`];
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// Wraps the step at word breaks to the box, three lines at most, the last one clipped.
|
|
277
|
+
const wrap = (text, width, max = 3) => {
|
|
278
|
+
const out = [''];
|
|
279
|
+
for (const word of bare(text).split(' ')) {
|
|
280
|
+
const joined = out.at(-1) ? `${out.at(-1)} ${word}` : word;
|
|
281
|
+
if (displayWidth(joined) <= width || !out.at(-1)) out[out.length - 1] = joined;
|
|
282
|
+
else out.push(word);
|
|
283
|
+
}
|
|
284
|
+
const kept = out.slice(0, max);
|
|
285
|
+
if (out.length > max) kept[max - 1] = `${kept[max - 1]} ${out.slice(max).join(' ')}`;
|
|
286
|
+
return kept.map((line) => clipToWidth(line, width));
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// Open on the right: agy's chat font draws Hangul narrower than two cells, so a right edge would wander.
|
|
290
|
+
const box = (title, body) => {
|
|
291
|
+
const inner = Math.max(displayWidth(title) + 4, ...body.map(displayWidth)) + 2;
|
|
292
|
+
return ['```text', `╭─ ${title} ${'─'.repeat(Math.max(1, inner - displayWidth(title) - 3))}`, ...body.map((line) => `│ ${line}`), `╰${'─'.repeat(inner)}`, '```'].join('\n');
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export const renderBrief = (data, { lang = 'en', width = 72, now = Date.parse(data.generatedAt) || Date.now() } = {}) => {
|
|
296
|
+
const w = WORDS[lang] ?? WORDS.en;
|
|
297
|
+
const sessions = data.sessions ?? [];
|
|
298
|
+
const summary = data.summary ?? { sessions: sessions.length, waitingOnUser: 0, active: 0 };
|
|
299
|
+
const runs = data.next?.kind && data.next.kind !== 'none';
|
|
300
|
+
const step = runs ? w.step[data.next.kind](Object.fromEntries(Object.entries(data.next.target ?? {}).map(([k, v]) => [k, bare(v)]))) : bare(suggestion(data, w));
|
|
301
|
+
const out = [`## 🧭 ${[w.sessions(summary.sessions), w.waiting(summary.waitingOnUser), w.active(summary.active)].join(' · ')} · ${w.next}: ${plain(step)}`];
|
|
302
|
+
out.push(`*${w.window(data.scope?.since ?? '7d', (data.scope?.worktrees ?? []).length || 1)}*`);
|
|
303
|
+
if (!sessions.length) out.push('', w.noSessions);
|
|
304
|
+
|
|
305
|
+
const live = sessions.filter((s) => s.status !== 'ended');
|
|
306
|
+
const ended = sessions.filter((s) => s.status === 'ended');
|
|
307
|
+
const groups = new Map();
|
|
308
|
+
for (const session of live) {
|
|
309
|
+
const key = `${session.worktree}\u0000${session.branch ?? ''}`;
|
|
310
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
311
|
+
groups.get(key).push(session);
|
|
312
|
+
}
|
|
313
|
+
for (const list of groups.values()) {
|
|
314
|
+
const first = list[0];
|
|
315
|
+
out.push('', `### 🌿 ${code(first.branch ?? 'no branch')} · ${plain(placeOf(first))}`);
|
|
316
|
+
for (const session of list) out.push('', sessionCard(session, data, now, w));
|
|
317
|
+
}
|
|
318
|
+
if (ended.length) out.push('', `### ⚪ ${w.endedTitle(ended.length)}`, '', ...endedTable(ended, now, w));
|
|
319
|
+
const roadGauge = data.roadmap?.progress?.gauge ? ` ${code(data.roadmap.progress.gauge)}` : '';
|
|
320
|
+
out.push('', `### 🗺️ ${w.roadmap}${roadGauge}`, '', ...roadmapLines(data, w));
|
|
321
|
+
|
|
322
|
+
const body = wrap(step, width - 4);
|
|
323
|
+
if (runs && data.next.command) body.push(clipToWidth(data.next.command, width - 4));
|
|
324
|
+
if (runs && data.next.say) body.push(`${w.type}: ${data.next.say}`);
|
|
325
|
+
out.push('', box(w.recommended, body));
|
|
326
|
+
out.push('', runs && data.next.say ? w.goLine(data.next.say) : w.noGo);
|
|
327
|
+
|
|
328
|
+
const unread = Object.entries(data.sources ?? {}).filter(([, v]) => v === 'unknown').map(([k]) => k);
|
|
329
|
+
const tail = [unread.length ? w.unknownSources(unread.join(', ')) : null, data.budget?.exhausted ? w.older : null].filter(Boolean);
|
|
330
|
+
if (tail.length) out.push('', `*${tail.join(' ')}*`);
|
|
331
|
+
return `${out.join('\n')}\n`;
|
|
332
|
+
};
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
// The lit-adhd record collector. Reads what is on disk for the workspace (agy transcripts, plans,
|
|
2
|
+
// litgoal, handoff headings, git log, workflow stacks) and returns one redacted, capped JSON brief.
|
|
3
|
+
// A source that is not there reads `unknown`; nothing is inferred.
|
|
4
|
+
|
|
5
|
+
import { execFileSync } from 'node:child_process';
|
|
6
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, readdirSync, statSync } from 'node:fs';
|
|
7
|
+
import { homedir } from 'node:os';
|
|
8
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
9
|
+
|
|
10
|
+
import { planRows } from '../continuation.mjs';
|
|
11
|
+
import { sessionPath, stateRoot } from '../common.mjs';
|
|
12
|
+
import { aggregateProgress, clipToWidth, progressOf } from './gauge.mjs';
|
|
13
|
+
import { renderBrief } from './brief.mjs';
|
|
14
|
+
import { chooseNextStep, writeNextStep } from './next-step.mjs';
|
|
15
|
+
import { makeRedactor } from './redact.mjs';
|
|
16
|
+
import { findTranscripts, makeBudget, readTranscriptLines, sessionRecord } from './transcripts.mjs';
|
|
17
|
+
|
|
18
|
+
const SMALL_FILE_BYTES = 1024 * 1024;
|
|
19
|
+
const GIT_TIMEOUT_MS = 5000;
|
|
20
|
+
const DEFAULT_SINCE = '7d';
|
|
21
|
+
const DEFAULT_MAX = 12;
|
|
22
|
+
const NAME_MAX = 90;
|
|
23
|
+
const PLAN_LIMIT = 8;
|
|
24
|
+
|
|
25
|
+
export const parseSince = (text) => {
|
|
26
|
+
const match = /^(\d{1,4})([dhm])$/u.exec(String(text ?? ''));
|
|
27
|
+
if (!match) return null;
|
|
28
|
+
return Number(match[1]) * { d: 86_400_000, h: 3_600_000, m: 60_000 }[match[2]];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const readSmallFile = (path, budget) => {
|
|
32
|
+
let fd;
|
|
33
|
+
try {
|
|
34
|
+
if (!lstatSync(path).isFile()) return null;
|
|
35
|
+
fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
36
|
+
const { size } = fstatSync(fd);
|
|
37
|
+
const length = Math.min(size, SMALL_FILE_BYTES, budget.limit - budget.used);
|
|
38
|
+
if (length < size) budget.exhausted = budget.exhausted || length < Math.min(size, SMALL_FILE_BYTES);
|
|
39
|
+
const buffer = Buffer.alloc(Math.max(0, length));
|
|
40
|
+
const read = length > 0 ? readSync(fd, buffer, 0, length, 0) : 0;
|
|
41
|
+
budget.used += read;
|
|
42
|
+
return buffer.subarray(0, read).toString('utf8');
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
} finally {
|
|
46
|
+
if (fd !== undefined) closeSync(fd);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const readJson = (path, budget) => {
|
|
51
|
+
const text = readSmallFile(path, budget);
|
|
52
|
+
if (text === null) return null;
|
|
53
|
+
try { return JSON.parse(text); } catch { return null; }
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const entries = (directory) => {
|
|
57
|
+
try { return readdirSync(directory, { withFileTypes: true }); } catch { return null; }
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const defaultExec = (file, args, options) => execFileSync(file, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], ...options });
|
|
61
|
+
|
|
62
|
+
const worktreesOf = (cwd, exec) => {
|
|
63
|
+
try {
|
|
64
|
+
const out = exec('git', ['worktree', 'list', '--porcelain'], { cwd, timeout: GIT_TIMEOUT_MS });
|
|
65
|
+
const paths = out.split('\n').filter((l) => l.startsWith('worktree ')).map((l) => l.slice(9).trim()).filter(Boolean);
|
|
66
|
+
return paths.length ? paths : null;
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// A plan scaffold nobody filled in: a row still holding a `<placeholder>`, or every row the same.
|
|
73
|
+
const isTemplate = (rows) => rows.some((r) => /<[^<>]{1,40}>/u.test(r.title)) || (rows.length > 1 && new Set(rows.map((r) => r.title.trim())).size === 1);
|
|
74
|
+
|
|
75
|
+
const plansIn = (root, budget, redact, local) => {
|
|
76
|
+
const list = entries(join(root, 'plans'));
|
|
77
|
+
if (!list) return null;
|
|
78
|
+
// A name with a control character could carry its own lines into the brief or the `go` note; skip it.
|
|
79
|
+
return list.filter((e) => e.isFile() && e.name.endsWith('.md') && !/[\p{Cc}\p{Cf}]/u.test(e.name)).sort((a, b) => a.name.localeCompare(b.name)).flatMap((e) => {
|
|
80
|
+
const text = readSmallFile(join(root, 'plans', e.name), budget);
|
|
81
|
+
if (text === null) return [];
|
|
82
|
+
const rows = planRows(text);
|
|
83
|
+
if (!rows.length || isTemplate(rows)) return [];
|
|
84
|
+
const open = rows.filter((r) => !r.done);
|
|
85
|
+
const done = rows.length - open.length;
|
|
86
|
+
let mtime = null;
|
|
87
|
+
try { mtime = statSync(join(root, 'plans', e.name)).mtimeMs; } catch { /* skip */ }
|
|
88
|
+
return [{
|
|
89
|
+
worktree: redact(root), plan: `plans/${e.name}`, local,
|
|
90
|
+
rows: rows.map((r) => ({ checked: r.done, title: clipToWidth(redact(r.title), NAME_MAX) })),
|
|
91
|
+
current: open.length ? clipToWidth(redact(open[0].title), NAME_MAX) : null,
|
|
92
|
+
finished: open.length === 0,
|
|
93
|
+
mtime,
|
|
94
|
+
progress: progressOf(done, rows.length, open.map((r) => clipToWidth(redact(r.title), NAME_MAX))),
|
|
95
|
+
}];
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const litgoalOf = (root, budget, redact) => {
|
|
100
|
+
const goals = readJson(join(root, '.litgravity', 'goals', 'active.json'), budget);
|
|
101
|
+
if (!goals || !Array.isArray(goals.criteria)) return null;
|
|
102
|
+
const passed = goals.criteria.filter((c) => c?.status === 'pass');
|
|
103
|
+
const remaining = goals.criteria.filter((c) => c?.status !== 'pass').map((c) => clipToWidth(redact(String(c?.text ?? c?.id ?? 'unknown')), NAME_MAX));
|
|
104
|
+
return {
|
|
105
|
+
worktree: redact(root), status: typeof goals.status === 'string' ? goals.status : 'unknown',
|
|
106
|
+
objective: clipToWidth(redact(String(goals.objective ?? 'unknown').split('\n')[0]), 120),
|
|
107
|
+
progress: progressOf(passed.length, goals.criteria.length, remaining),
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const handoffsOf = (root, budget, redact) => (entries(root) ?? [])
|
|
112
|
+
.filter((e) => e.isFile() && /^HANDOFF.*\.md$/u.test(e.name))
|
|
113
|
+
.map((e) => {
|
|
114
|
+
const text = readSmallFile(join(root, e.name), budget) ?? '';
|
|
115
|
+
const headings = text.split('\n').slice(0, 40).filter((l) => /^#{1,3} /u.test(l)).map((l) => clipToWidth(redact(l), 100));
|
|
116
|
+
return { worktree: redact(root), file: e.name, headings };
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const branchOf = (root, exec) => {
|
|
120
|
+
try {
|
|
121
|
+
return exec('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: root, timeout: GIT_TIMEOUT_MS }).trim() || null;
|
|
122
|
+
} catch {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const commitsOf = (root, sinceMs, now, exec, redact) => {
|
|
128
|
+
try {
|
|
129
|
+
const since = new Date(now - sinceMs).toISOString();
|
|
130
|
+
const branch = exec('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: root, timeout: GIT_TIMEOUT_MS }).trim();
|
|
131
|
+
const out = exec('git', ['log', `--since=${since}`, '--max-count=20', '--format=%H%x09%cI%x09%s'], { cwd: root, timeout: GIT_TIMEOUT_MS });
|
|
132
|
+
return out.split('\n').filter(Boolean).map((line) => {
|
|
133
|
+
const [hash, at, ...subject] = line.split('\t');
|
|
134
|
+
return { worktree: redact(root), branch: redact(branch), hash: hash.slice(0, 7), at, atMs: Date.parse(at), subject: clipToWidth(redact(subject.join('\t')), 100) };
|
|
135
|
+
});
|
|
136
|
+
} catch {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const stacksOf = (stateDir, budget, redact) => {
|
|
142
|
+
if (!stateDir) return null;
|
|
143
|
+
const list = entries(stateDir);
|
|
144
|
+
if (!list) return null;
|
|
145
|
+
return list.filter((e) => e.isFile() && e.name.endsWith('.stack.json')).flatMap((e) => {
|
|
146
|
+
const stack = readJson(join(stateDir, e.name), budget);
|
|
147
|
+
if (!stack || !Array.isArray(stack.frames)) return [];
|
|
148
|
+
return stack.frames.slice(0, 3).map((frame) => ({
|
|
149
|
+
sessionId: typeof stack.sessionId === 'string' ? stack.sessionId : null,
|
|
150
|
+
id8: typeof stack.sessionId === 'string' ? stack.sessionId.slice(0, 8) : 'unknown',
|
|
151
|
+
skill: typeof frame.skill === 'string' ? redact(frame.skill) : 'unknown',
|
|
152
|
+
stage: typeof frame.stage === 'string' ? redact(frame.stage) : 'unknown',
|
|
153
|
+
role: frame.role === 'spine' ? 'spine' : 'side',
|
|
154
|
+
status: frame.status === 'paused' ? 'paused' : 'active',
|
|
155
|
+
at: typeof frame.at === 'string' ? frame.at : 'unknown',
|
|
156
|
+
progress: progressOf(frame.n, frame.total, undefined),
|
|
157
|
+
...(frame.ref?.plan ? { ref: { plan: redact(frame.ref.plan) } } : {}),
|
|
158
|
+
}));
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const known = (list) => (list === null ? 'unknown' : 'ok');
|
|
163
|
+
const statusRank = { 'waiting-on-user': 0, active: 1, ended: 2, unknown: 3 };
|
|
164
|
+
|
|
165
|
+
export const collectRewind = ({
|
|
166
|
+
cwd = process.cwd(),
|
|
167
|
+
here = false,
|
|
168
|
+
since = DEFAULT_SINCE,
|
|
169
|
+
max = DEFAULT_MAX,
|
|
170
|
+
sessionId = null,
|
|
171
|
+
env = process.env,
|
|
172
|
+
now = Date.now(),
|
|
173
|
+
exec = defaultExec,
|
|
174
|
+
record = true,
|
|
175
|
+
} = {}) => {
|
|
176
|
+
const home = env.HOME || homedir();
|
|
177
|
+
const redact = makeRedactor({ env, home });
|
|
178
|
+
const budget = makeBudget();
|
|
179
|
+
const sinceMs = parseSince(since) ?? parseSince(DEFAULT_SINCE);
|
|
180
|
+
const limit = Number.isInteger(max) && max > 0 ? Math.min(max, 50) : DEFAULT_MAX;
|
|
181
|
+
const start = resolve(cwd);
|
|
182
|
+
const listed = here ? null : worktreesOf(start, exec);
|
|
183
|
+
const roots = [...new Set([start, ...(here ? [] : listed ?? [])])];
|
|
184
|
+
|
|
185
|
+
// Which conversations belong to this workspace: the route-state folder of each root (worktree) lists them by id.
|
|
186
|
+
const stateDirs = roots.map((r) => ({ root: r, dir: dirname(sessionPath(r, 'x', env)) }));
|
|
187
|
+
const owner = new Map();
|
|
188
|
+
for (const { root: r, dir } of stateDirs) {
|
|
189
|
+
for (const e of entries(dir) ?? []) {
|
|
190
|
+
const m = /^([A-Za-z0-9._:-]{1,160})\.json$/.exec(e.name);
|
|
191
|
+
if (e.isFile() && m && !/\.(?:snapshot|stack|motion)$/.test(m[1]) && !owner.has(m[1])) owner.set(m[1], r);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const geminiDir = join(home, '.gemini', 'antigravity-cli');
|
|
195
|
+
const transcripts = owner.size ? findTranscripts(geminiDir, [...owner.keys()]) : { status: 'unknown', files: [] };
|
|
196
|
+
const sessions = [];
|
|
197
|
+
for (const { id, path } of transcripts.files) {
|
|
198
|
+
if (sessions.length >= limit || budget.exhausted) break;
|
|
199
|
+
const lines = readTranscriptLines(path, budget);
|
|
200
|
+
const session = lines ? sessionRecord(lines, { redact, now, cwd: owner.get(id) }) : null;
|
|
201
|
+
if (!session || (session.lastMs !== null && now - session.lastMs > sinceMs)) continue;
|
|
202
|
+
session.sessionId = id;
|
|
203
|
+
session.id8 = id.slice(0, 8);
|
|
204
|
+
session.root = owner.get(id);
|
|
205
|
+
if (here && resolve(session.cwd).normalize('NFC') !== start.normalize('NFC')) continue;
|
|
206
|
+
sessions.push(session);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const collectEach = (read) => {
|
|
210
|
+
const results = roots.map(read);
|
|
211
|
+
return results.every((v) => v === null) ? null : results.flatMap((v) => v ?? []);
|
|
212
|
+
};
|
|
213
|
+
const plans = collectEach((r) => plansIn(r, budget, redact, resolve(r) === start));
|
|
214
|
+
const litgoal = collectEach((r) => {
|
|
215
|
+
const goal = litgoalOf(r, budget, redact);
|
|
216
|
+
return goal ? [{ ...goal, local: resolve(r) === start }] : null;
|
|
217
|
+
});
|
|
218
|
+
const handoffs = roots.flatMap((r) => handoffsOf(r, budget, redact));
|
|
219
|
+
const commits = collectEach((r) => commitsOf(r, sinceMs, now, exec, redact));
|
|
220
|
+
const stackLists = stateDirs.map(({ dir }) => stacksOf(dir, budget, redact));
|
|
221
|
+
const branches = new Map(roots.map((r) => [r, branchOf(r, exec)]));
|
|
222
|
+
const workflows = stackLists.every((v) => v === null) ? null : stackLists.flatMap((v) => v ?? []);
|
|
223
|
+
|
|
224
|
+
for (const session of sessions) {
|
|
225
|
+
const frames = (workflows ?? []).filter((f) => f.sessionId === session.sessionId);
|
|
226
|
+
const top = frames.at(-1);
|
|
227
|
+
if (frames.some((f) => f.status === 'paused') && session.status !== 'waiting-on-user') {
|
|
228
|
+
session.status = 'waiting-on-user';
|
|
229
|
+
session.waitingReason = 'paused workflow';
|
|
230
|
+
}
|
|
231
|
+
session.progress = top?.progress ?? progressOf(null, null);
|
|
232
|
+
const branch = branches.get(session.root);
|
|
233
|
+
if (branch) session.branch = redact(branch);
|
|
234
|
+
session.done.commits = (commits ?? [])
|
|
235
|
+
.filter((c) => session.lastMs !== null && Date.parse(session.started) <= c.atMs && c.atMs <= session.lastMs + 5 * 60_000)
|
|
236
|
+
.slice(0, 5)
|
|
237
|
+
.map(({ hash, subject }) => ({ hash, subject }));
|
|
238
|
+
}
|
|
239
|
+
sessions.sort((a, b) => statusRank[a.status] - statusRank[b.status] || (b.lastMs ?? 0) - (a.lastMs ?? 0));
|
|
240
|
+
|
|
241
|
+
// This folder's open plans, then another folder's plans changed inside the window, newest first; a
|
|
242
|
+
// finished plan elsewhere or one nobody touched lately is history, not roadmap.
|
|
243
|
+
const recent = (p) => p.local || (!p.finished && p.mtime !== null && now - p.mtime <= sinceMs);
|
|
244
|
+
const orderedPlans = (plans ?? []).filter(recent).sort((a, b) => Number(b.local) - Number(a.local) || (b.mtime ?? 0) - (a.mtime ?? 0));
|
|
245
|
+
const shownPlans = orderedPlans.slice(0, PLAN_LIMIT);
|
|
246
|
+
const localGoals = (litgoal ?? []).filter((g) => g.local);
|
|
247
|
+
const roadmapItems = [...orderedPlans.filter((p) => p.local).map((p) => p.progress), ...localGoals.map((g) => g.progress)];
|
|
248
|
+
const data = {
|
|
249
|
+
version: 1,
|
|
250
|
+
generatedAt: new Date(now).toISOString(),
|
|
251
|
+
scope: { here, since: sinceMs === parseSince(since) ? since : DEFAULT_SINCE, max: limit, worktrees: roots.map(redact) },
|
|
252
|
+
sources: {
|
|
253
|
+
transcripts: transcripts.status,
|
|
254
|
+
litgoal: known(litgoal),
|
|
255
|
+
plans: known(plans),
|
|
256
|
+
handoffs: handoffs.length ? 'ok' : 'unknown',
|
|
257
|
+
git: known(commits),
|
|
258
|
+
workflowStack: known(workflows),
|
|
259
|
+
},
|
|
260
|
+
budget: { bytesRead: budget.used, limit: budget.limit, exhausted: budget.exhausted },
|
|
261
|
+
summary: {
|
|
262
|
+
sessions: sessions.length,
|
|
263
|
+
waitingOnUser: sessions.filter((s) => s.status === 'waiting-on-user').length,
|
|
264
|
+
active: sessions.filter((s) => s.status === 'active').length,
|
|
265
|
+
},
|
|
266
|
+
sessions: sessions.map(({ cwd: _cwd, lastMs: _lastMs, root: _root, sessionId: id, ...rest }) => ({ ...rest, self: Boolean(sessionId) && id === sessionId })),
|
|
267
|
+
roadmap: {
|
|
268
|
+
plans: shownPlans,
|
|
269
|
+
plansOmitted: orderedPlans.length - shownPlans.length,
|
|
270
|
+
// Another folder's finished objective is history.
|
|
271
|
+
litgoal: (litgoal ?? []).filter((g) => g.local || g.status !== 'complete'),
|
|
272
|
+
progress: roadmapItems.length ? aggregateProgress(roadmapItems) : progressOf(null, null),
|
|
273
|
+
},
|
|
274
|
+
workflows: (workflows ?? []).map((f) => ({ ...f, self: Boolean(sessionId) && f.sessionId === sessionId })),
|
|
275
|
+
// A start-work run is a start-work frame on a workflow stack; agy keeps no other record of one.
|
|
276
|
+
startWork: (workflows ?? []).filter((f) => f.skill === 'start-work').map((f) => ({ sessionId: f.sessionId, status: f.status, plan: f.ref?.plan ?? null })),
|
|
277
|
+
handoffs,
|
|
278
|
+
commits: (commits ?? []).slice(0, 20).map(({ atMs: _atMs, ...c }) => c),
|
|
279
|
+
};
|
|
280
|
+
const next = chooseNextStep(data, sessionId);
|
|
281
|
+
data.next = next;
|
|
282
|
+
data.nextRecorded = false;
|
|
283
|
+
if (record && sessionId) {
|
|
284
|
+
try {
|
|
285
|
+
// The same root PreInvocation hands takeNextStep, so `go` finds what this brief offered.
|
|
286
|
+
writeNextStep(stateRoot(env), sessionId, next, new Date(now));
|
|
287
|
+
data.nextRecorded = true;
|
|
288
|
+
} catch {
|
|
289
|
+
data.nextRecorded = false;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
for (const f of data.workflows) delete f.sessionId;
|
|
293
|
+
for (const w of data.startWork) delete w.sessionId;
|
|
294
|
+
return data;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// The brief as Markdown (brief.mjs). `width` sizes the next-step box.
|
|
298
|
+
export const renderRewind = (data, { lang = 'en', width = 72 } = {}) => renderBrief(data, { lang, width: Math.max(40, Math.min(width, 100)) });
|
|
299
|
+
|
|
300
|
+
export const runRewindCli = (args, cwd = process.cwd(), { env = process.env, stdout = process.stdout, stderr = process.stderr } = {}) => {
|
|
301
|
+
const options = { cwd, env, here: false, since: DEFAULT_SINCE, max: DEFAULT_MAX, sessionId: null };
|
|
302
|
+
let json = false;
|
|
303
|
+
let lang = 'en';
|
|
304
|
+
let width = Math.min(Number(stdout.columns) || 72, 72);
|
|
305
|
+
const usage = 'Usage: rewind.mjs [--brief|--json] [--lang en|ko] [--here] [--since 7d] [--max 12] [--session <id>] [--width N]';
|
|
306
|
+
if (args.some((a) => a === '--help' || a === '-h')) {
|
|
307
|
+
stdout.write(`${usage}\n`);
|
|
308
|
+
return 0;
|
|
309
|
+
}
|
|
310
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
311
|
+
const arg = args[i];
|
|
312
|
+
if (arg === '--json') json = true;
|
|
313
|
+
else if (arg === '--brief') json = false;
|
|
314
|
+
else if (arg === '--lang' && ['en', 'ko'].includes(args[i + 1])) lang = args[++i];
|
|
315
|
+
else if (arg === '--here') options.here = true;
|
|
316
|
+
else if (arg === '--since' && parseSince(args[i + 1])) options.since = args[++i];
|
|
317
|
+
else if (arg === '--max' && /^\d{1,2}$/u.test(args[i + 1] ?? '')) options.max = Number(args[++i]);
|
|
318
|
+
else if (arg === '--session' && /^[A-Za-z0-9._:-]{1,160}$/u.test(args[i + 1] ?? '')) options.sessionId = args[++i];
|
|
319
|
+
else if (arg === '--width' && /^\d{2,3}$/u.test(args[i + 1] ?? '')) width = Number(args[++i]);
|
|
320
|
+
else {
|
|
321
|
+
stderr.write(`rewind: unknown argument ${JSON.stringify(basename(String(arg)))}. ${usage}\n`);
|
|
322
|
+
return 64;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
const data = collectRewind(options);
|
|
326
|
+
stdout.write(json ? `${JSON.stringify(data, null, 2)}\n` : renderRewind(data, { lang, width }));
|
|
327
|
+
return 0;
|
|
328
|
+
};
|