@skitterbyte/skitterspec-jira 2.10.0 → 2.12.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/assets/claude-md-section.md +8 -2
- package/assets/commands/allow-project.md +28 -0
- package/assets/core/env.config.md +29 -3
- package/assets/hooks/project-guard.cjs +161 -0
- package/assets/rules/spec-planning.md +44 -1
- package/assets/skills/spec/SKILL.md +30 -0
- package/assets/skills/spec-cancel/SKILL.md +22 -4
- package/assets/skills/spec-complete/SKILL.md +34 -6
- package/assets/skills/spec-idea/SKILL.md +115 -0
- package/assets/skills/spec-init/SKILL.md +3 -1
- package/assets/skills/spec-review/SKILL.md +22 -4
- package/assets/skills/spec-tada/SKILL.md +26 -4
- package/assets/skills/spec-todo/SKILL.md +104 -0
- package/bin/skitterspec-jira.js +4 -0
- package/package.json +1 -1
- package/src/cli.js +266 -21
- package/src/env/config.js +26 -3
- package/src/env/hooks.js +10 -0
- package/src/env/integrate.js +5 -34
- package/src/env/live.js +106 -4
- package/src/env/projectguard.js +389 -0
- package/src/env/triggered.js +50 -0
- package/src/idea.js +190 -0
- package/src/ideacmd.js +242 -0
- package/src/tada/digest.js +41 -2
- package/src/tada/format.js +4 -2
- package/src/tada/page.js +35 -7
- package/src/tada/repo.js +22 -2
- package/src/tada/serve.js +13 -7
- package/src/tada/todo.js +250 -0
- package/src/vendor/jira/cli-sync.js +33 -11
- package/src/vendor/provider-kit/src/apply.js +90 -5
package/src/ideacmd.js
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `skitterspec idea <add|list|drop>` — the side-effecting half of `idea.js`.
|
|
5
|
+
*
|
|
6
|
+
* The file store writes `specs/ideas.md` straight onto the base branch with
|
|
7
|
+
* plumbing — a throwaway index, `commit-tree`, then a fast-forward — so no
|
|
8
|
+
* checkout is switched, no worktree is made, and the primary checkout is never
|
|
9
|
+
* left dirty. Where the base branch is checked out, the fast-forward runs
|
|
10
|
+
* there (`merge --ff-only`) so its working tree follows; elsewhere the ref
|
|
11
|
+
* moves by compare-and-swap. Either way a base that moved underneath us
|
|
12
|
+
* refuses rather than overwriting it.
|
|
13
|
+
*
|
|
14
|
+
* Nothing is pushed. The base branch is shared once it is pushed, and a push
|
|
15
|
+
* is always the operator's to make, so the command prints it instead.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const fs = require('node:fs')
|
|
19
|
+
const os = require('node:os')
|
|
20
|
+
const path = require('node:path')
|
|
21
|
+
const { execFileSync } = require('node:child_process')
|
|
22
|
+
|
|
23
|
+
const { IDEAS_FILE, parseIdeas, planAdd, planDrop, selectStore, getProviderIdeaStore } = require('./idea.js')
|
|
24
|
+
const { loadEnvConfig, providerConfigured } = require('./env/config.js')
|
|
25
|
+
const { describeBaseBranch, baseRemote } = require('./env/resolve.js')
|
|
26
|
+
const { primaryAnchor } = require('./env/project.js')
|
|
27
|
+
|
|
28
|
+
const USAGE =
|
|
29
|
+
'Usage: skitterspec idea add <text> | list [--count] | drop <id> [--reason <why>] [--json] [--dir <path>]\n'
|
|
30
|
+
|
|
31
|
+
function reader(cwd) {
|
|
32
|
+
return (argv) => {
|
|
33
|
+
try {
|
|
34
|
+
return execFileSync('git', ['-C', cwd, ...argv], { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
35
|
+
.toString()
|
|
36
|
+
.trim()
|
|
37
|
+
} catch {
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// A mutating call: throws with git's own stderr, which is what gets relayed.
|
|
44
|
+
function git(cwd, argv, { input, env } = {}) {
|
|
45
|
+
try {
|
|
46
|
+
return execFileSync('git', ['-C', cwd, ...argv], {
|
|
47
|
+
input,
|
|
48
|
+
env: env || process.env,
|
|
49
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
50
|
+
})
|
|
51
|
+
.toString()
|
|
52
|
+
.trim()
|
|
53
|
+
} catch (error) {
|
|
54
|
+
throw new Error((error.stderr && error.stderr.toString().trim()) || error.message)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function parseArgs(argv) {
|
|
59
|
+
const flags = { json: false, count: false, dir: null, reason: null }
|
|
60
|
+
const positional = []
|
|
61
|
+
for (let i = 0; i < argv.length; i++) {
|
|
62
|
+
const a = argv[i]
|
|
63
|
+
if (a === '--json') flags.json = true
|
|
64
|
+
else if (a === '--count') flags.count = true
|
|
65
|
+
else if (a === '--dir') flags.dir = argv[++i]
|
|
66
|
+
else if (a === '--reason') flags.reason = argv[++i]
|
|
67
|
+
else positional.push(a)
|
|
68
|
+
}
|
|
69
|
+
return { flags, positional }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function localDay(now) {
|
|
73
|
+
const pad = (n) => String(n).padStart(2, '0')
|
|
74
|
+
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Where the file store lives: the primary checkout, its base branch, the path. */
|
|
78
|
+
function fileContext(from) {
|
|
79
|
+
const anchor = primaryAnchor(from, reader(from))
|
|
80
|
+
const read = reader(anchor.root)
|
|
81
|
+
let config = {}
|
|
82
|
+
try {
|
|
83
|
+
config = loadEnvConfig(anchor.dir).config
|
|
84
|
+
} catch {
|
|
85
|
+
// an unreadable config resolves the base the way a missing one does
|
|
86
|
+
}
|
|
87
|
+
const { base, refused } = describeBaseBranch(config, read)
|
|
88
|
+
return {
|
|
89
|
+
anchor,
|
|
90
|
+
read,
|
|
91
|
+
base,
|
|
92
|
+
refused,
|
|
93
|
+
remote: baseRemote(config),
|
|
94
|
+
rel: anchor.prefix ? `${anchor.prefix}/${IDEAS_FILE}` : IDEAS_FILE,
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The file as the base branch holds it — `''` when it is not there yet. */
|
|
99
|
+
function readOnBase(ctx) {
|
|
100
|
+
const tip = ctx.read(['rev-parse', '--verify', '--quiet', `refs/heads/${ctx.base}^{commit}`])
|
|
101
|
+
if (!tip) return { tip: null, text: null }
|
|
102
|
+
return { tip, text: ctx.read(['show', `${tip}:${ctx.rel}`]) || '' }
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The worktree that has `branch` checked out, else null. */
|
|
106
|
+
function checkedOutAt(ctx, branch) {
|
|
107
|
+
const out = ctx.read(['worktree', 'list', '--porcelain']) || ''
|
|
108
|
+
let at = null
|
|
109
|
+
for (const line of out.split('\n')) {
|
|
110
|
+
if (line.startsWith('worktree ')) at = line.slice('worktree '.length)
|
|
111
|
+
else if (line === `branch refs/heads/${branch}`) return at
|
|
112
|
+
}
|
|
113
|
+
return null
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Commit `content` at `rel` on top of `tip`, then fast-forward the base to it. */
|
|
117
|
+
function landOnBase(ctx, tip, content, message) {
|
|
118
|
+
const root = ctx.anchor.root
|
|
119
|
+
const index = path.join(os.tmpdir(), `skitterspec-idea-${process.pid}-${Date.now()}.index`)
|
|
120
|
+
const env = { ...process.env, GIT_INDEX_FILE: index }
|
|
121
|
+
let commit
|
|
122
|
+
try {
|
|
123
|
+
git(root, ['read-tree', tip], { env })
|
|
124
|
+
const blob = git(root, ['hash-object', '-w', '--stdin'], { input: content })
|
|
125
|
+
git(root, ['update-index', '--add', '--cacheinfo', `100644,${blob},${ctx.rel}`], { env })
|
|
126
|
+
const tree = git(root, ['write-tree'], { env })
|
|
127
|
+
commit = git(root, ['commit-tree', tree, '-p', tip, '-F', '-'], { input: message })
|
|
128
|
+
} finally {
|
|
129
|
+
fs.rmSync(index, { force: true })
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const at = checkedOutAt(ctx, ctx.base)
|
|
133
|
+
if (at) {
|
|
134
|
+
// Its working tree must follow the ref, so the move happens there — and a
|
|
135
|
+
// local edit to the file is someone's work, which a fast-forward would
|
|
136
|
+
// either refuse over or carry; refuse first, with the reason in words.
|
|
137
|
+
const dirty = reader(at)(['status', '--porcelain', '--', ctx.rel])
|
|
138
|
+
if (dirty) throw new Error(`${ctx.rel} has uncommitted changes in ${at} — commit or discard them first`)
|
|
139
|
+
git(at, ['merge', '--ff-only', '--quiet', commit])
|
|
140
|
+
} else {
|
|
141
|
+
git(root, ['update-ref', '-m', 'skitterspec idea', `refs/heads/${ctx.base}`, commit, tip])
|
|
142
|
+
}
|
|
143
|
+
return commit
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function write(out, flags, json, lines) {
|
|
147
|
+
out.write(flags.json ? JSON.stringify(json, null, 2) + '\n' : lines.join('\n') + '\n')
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function refuse(out, flags, reason, extra = {}) {
|
|
151
|
+
write(out, flags, { ok: false, refused: reason, ...extra }, [`idea: ${reason}`])
|
|
152
|
+
return 1
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function fileStore(sub, positional, flags, { cwd, now, out }) {
|
|
156
|
+
const ctx = fileContext(cwd)
|
|
157
|
+
if (!ctx.base) return refuse(out, flags, ctx.refused ? ctx.refused.message : 'cannot resolve the base branch')
|
|
158
|
+
const { tip, text } = readOnBase(ctx)
|
|
159
|
+
|
|
160
|
+
if (sub === 'list') {
|
|
161
|
+
const ideas = tip ? parseIdeas(text).entries : []
|
|
162
|
+
if (flags.count) {
|
|
163
|
+
write(out, flags, { store: 'file', count: ideas.length }, [String(ideas.length)])
|
|
164
|
+
return 0
|
|
165
|
+
}
|
|
166
|
+
const lines = ideas.length
|
|
167
|
+
? [`ideas on ${ctx.base} (${ctx.rel}):`, ...ideas.map((e) => ` ${e.id.padEnd(30)} ${e.date} ${e.title}`)]
|
|
168
|
+
: [`idea: nothing waiting on ${ctx.base}`]
|
|
169
|
+
write(out, flags, { store: 'file', base: ctx.base, file: ctx.rel, ideas }, lines)
|
|
170
|
+
return 0
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!tip) return refuse(out, flags, `the base branch ${ctx.base} has no commits here`)
|
|
174
|
+
|
|
175
|
+
const plan =
|
|
176
|
+
sub === 'add'
|
|
177
|
+
? planAdd(text, {
|
|
178
|
+
text: positional.join(' '),
|
|
179
|
+
author: ctx.read(['config', 'user.name']),
|
|
180
|
+
date: localDay(now),
|
|
181
|
+
})
|
|
182
|
+
: planDrop(text, { id: positional[0], reason: flags.reason })
|
|
183
|
+
if (plan.refused) return refuse(out, flags, plan.refused, sub === 'add' ? { text: positional.join(' ') } : {})
|
|
184
|
+
|
|
185
|
+
let commit
|
|
186
|
+
try {
|
|
187
|
+
commit = landOnBase(ctx, tip, plan.content, plan.message)
|
|
188
|
+
} catch (error) {
|
|
189
|
+
return refuse(out, flags, `nothing landed — ${error.message}`, sub === 'add' ? { text: positional.join(' ') } : {})
|
|
190
|
+
}
|
|
191
|
+
const push = `git push ${ctx.remote} ${ctx.base}`
|
|
192
|
+
const verb = sub === 'add' ? 'added' : 'dropped'
|
|
193
|
+
write(
|
|
194
|
+
out,
|
|
195
|
+
flags,
|
|
196
|
+
{ ok: true, store: 'file', action: sub, id: plan.id, title: plan.entry.title, base: ctx.base, commit, file: ctx.rel, push },
|
|
197
|
+
[
|
|
198
|
+
`idea: ${verb} "${plan.id}" ${sub === 'add' ? 'to' : 'from'} ${ctx.rel} on ${ctx.base} (${commit.slice(0, 7)})`,
|
|
199
|
+
` title: ${plan.entry.title}`,
|
|
200
|
+
` pushed: no — ${push} publishes it`,
|
|
201
|
+
],
|
|
202
|
+
)
|
|
203
|
+
return 0
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Entry point. Resolves to an exit code: 0 for an answer, 1 for a refusal —
|
|
208
|
+
* which for `add` carries the text back, so a refused capture loses nothing.
|
|
209
|
+
*/
|
|
210
|
+
async function ideaCommand(argv, { cwd = process.cwd(), now = new Date(), out = process.stdout } = {}) {
|
|
211
|
+
const [sub, ...rest] = argv
|
|
212
|
+
const { flags, positional } = parseArgs(rest)
|
|
213
|
+
const from = path.resolve(flags.dir || cwd)
|
|
214
|
+
if (!['add', 'list', 'drop'].includes(sub)) {
|
|
215
|
+
out.write(USAGE)
|
|
216
|
+
return sub ? 1 : 0
|
|
217
|
+
}
|
|
218
|
+
if (sub === 'add' && !positional.join(' ').trim()) return refuse(out, flags, 'nothing to capture — give the idea some text')
|
|
219
|
+
if (sub === 'drop' && !positional[0]) return refuse(out, flags, 'name the idea to drop — `skitterspec idea list` shows them')
|
|
220
|
+
|
|
221
|
+
const anchor = primaryAnchor(from, reader(from))
|
|
222
|
+
const store = getProviderIdeaStore()
|
|
223
|
+
const where = selectStore({ providerConfigured: providerConfigured(anchor.dir), store })
|
|
224
|
+
if (where === 'provider') return store.run(sub, rest, { cwd: from, out })
|
|
225
|
+
if (where === 'unknown') {
|
|
226
|
+
if (sub === 'list') {
|
|
227
|
+
write(out, flags, { store: 'unknown', count: null }, ['idea: cannot tell where ideas live — the configured provider declares no idea store'])
|
|
228
|
+
return 0
|
|
229
|
+
}
|
|
230
|
+
const text = positional.join(' ')
|
|
231
|
+
return refuse(
|
|
232
|
+
out,
|
|
233
|
+
flags,
|
|
234
|
+
'cannot tell where ideas live — the configured provider declares no idea store; nothing was written' +
|
|
235
|
+
(sub === 'add' ? `\n your idea, so nothing is lost:\n ${text.replace(/\n/g, '\n ')}` : ''),
|
|
236
|
+
sub === 'add' ? { text } : {},
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
return fileStore(sub, positional, flags, { cwd: from, now, out })
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
module.exports = { ideaCommand, USAGE }
|
package/src/tada/digest.js
CHANGED
|
@@ -15,6 +15,7 @@ const path = require('node:path')
|
|
|
15
15
|
const { execFileSync } = require('node:child_process')
|
|
16
16
|
|
|
17
17
|
const { listTranscripts, readSession, trimPrompts } = require('./transcripts.js')
|
|
18
|
+
const { splitPrefix } = require('../env/resolve.js')
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* The repo a cwd belongs to, through the shared git dir — which every worktree
|
|
@@ -59,8 +60,11 @@ function memo(fn) {
|
|
|
59
60
|
* - `chat` keep every prompt, no-spec ones included (`--chat`)
|
|
60
61
|
* - `category` the running project's category: only projects carrying the
|
|
61
62
|
* same one are reported. Null reports every project.
|
|
63
|
+
* - `home` the cwd the run started from; the project it belongs to is
|
|
64
|
+
* stamped `here`, so a recap can keep its closing advice to the
|
|
65
|
+
* work this session owns. Null, or outside any repo, stamps none.
|
|
62
66
|
*/
|
|
63
|
-
async function buildDigest({ root, window, here = null, repoOf = gitRepoOf, facts = null, openFor = null, category = null, chat = false }) {
|
|
67
|
+
async function buildDigest({ root, window, here = null, home = null, repoOf = gitRepoOf, facts = null, openFor = null, category = null, chat = false }) {
|
|
64
68
|
const resolve = memo(repoOf)
|
|
65
69
|
const notes = []
|
|
66
70
|
const refolded = new Set()
|
|
@@ -133,6 +137,10 @@ async function buildDigest({ root, window, here = null, repoOf = gitRepoOf, fact
|
|
|
133
137
|
list = list.filter((p) => p.key === key)
|
|
134
138
|
}
|
|
135
139
|
|
|
140
|
+
// Matched by repo, so a run from one of its worktrees is still home. A home
|
|
141
|
+
// outside any repo stamps nothing: there is no project to have been run from.
|
|
142
|
+
const homeRepo = home ? resolve(path.isAbsolute(home) ? home : path.resolve(home)).repo || null : null
|
|
143
|
+
|
|
136
144
|
const want = category ? fold(category) : null
|
|
137
145
|
const reported = list
|
|
138
146
|
.map((p) => ({ p, f: p.repo && facts ? facts(p.repo) : null }))
|
|
@@ -145,6 +153,7 @@ async function buildDigest({ root, window, here = null, repoOf = gitRepoOf, fact
|
|
|
145
153
|
return {
|
|
146
154
|
repo: p.repo,
|
|
147
155
|
name: (f && f.name) || p.name,
|
|
156
|
+
...(homeRepo && p.repo === homeRepo ? { here: true } : {}),
|
|
148
157
|
...(f && f.category ? { category: f.category } : {}),
|
|
149
158
|
git: p.git,
|
|
150
159
|
skitterspec: Boolean(f && f.skitterspec),
|
|
@@ -225,7 +234,17 @@ function groupsOf(p, f, open, { chat = false } = {}) {
|
|
|
225
234
|
g.commits.sort(byTime)
|
|
226
235
|
g.events.sort(byTime)
|
|
227
236
|
const ticket = g.spec && f ? f.ticket(g.spec) || refTicket(g.commits) : null
|
|
228
|
-
|
|
237
|
+
const wins = winsOf(g)
|
|
238
|
+
return {
|
|
239
|
+
spec: g.spec,
|
|
240
|
+
branch: g.branch,
|
|
241
|
+
...(ticket ? { ticket } : {}),
|
|
242
|
+
sessions: g.sessions,
|
|
243
|
+
commits: g.commits,
|
|
244
|
+
events: g.events,
|
|
245
|
+
...(wins.length ? { wins } : {}),
|
|
246
|
+
inFlight: g.inFlight,
|
|
247
|
+
}
|
|
229
248
|
})
|
|
230
249
|
.sort((a, b) => {
|
|
231
250
|
// Activity first, in the order it happened; a spec that is only open —
|
|
@@ -239,6 +258,26 @@ function groupsOf(p, f, open, { chat = false } = {}) {
|
|
|
239
258
|
})
|
|
240
259
|
}
|
|
241
260
|
|
|
261
|
+
// The kinds whose completion means something was broken and now is not.
|
|
262
|
+
const RESCUES = new Set(['bug', 'hotfix', 'incident'])
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The group's wins, as facts rather than judgement: a completed bug, hotfix or
|
|
266
|
+
* incident is `saved-bacon`; any other completed spec, and a tag cut on one of
|
|
267
|
+
* the window's commits, is a `win`. Read off the spec's folder prefix — the
|
|
268
|
+
* kind's positive signal — and the tags git holds, so the same day always
|
|
269
|
+
* reads the same. A cancelled spec and a finished phase are progress, not wins.
|
|
270
|
+
*/
|
|
271
|
+
function winsOf(g) {
|
|
272
|
+
const wins = []
|
|
273
|
+
for (const e of g.events) {
|
|
274
|
+
if (e.kind !== 'completed') continue
|
|
275
|
+
wins.push({ kind: RESCUES.has(splitPrefix(e.spec).type) ? 'saved-bacon' : 'win', what: `${e.spec} completed`, at: e.at })
|
|
276
|
+
}
|
|
277
|
+
for (const c of g.commits) for (const t of c.tags || []) wins.push({ kind: 'win', what: `${t} cut`, at: c.at })
|
|
278
|
+
return wins
|
|
279
|
+
}
|
|
280
|
+
|
|
242
281
|
// Stable on a tie — a rebased run shares one committer second, and its order
|
|
243
282
|
// is the walk's, which is oldest first.
|
|
244
283
|
function byTime(a, b) {
|
package/src/tada/format.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* recap costs. Pure.
|
|
7
7
|
*
|
|
8
8
|
* Line markers carry the kind, so the skill can tell them apart without
|
|
9
|
-
* labels: `*` a lifecycle move, `+` a commit, `-` a prompt.
|
|
9
|
+
* labels: `*` a lifecycle move, `+` a commit, `-` a prompt, `★` a win. The
|
|
10
|
+
* project the run started from is marked `(here)`.
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
function formatTada(digest) {
|
|
@@ -15,10 +16,11 @@ function formatTada(digest) {
|
|
|
15
16
|
const out = [`ta-da: ${w.label || `${w.since} → ${w.until}`}${scope}`]
|
|
16
17
|
if (digest.projects.length === 0) out.push(' nothing in this window.')
|
|
17
18
|
for (const p of digest.projects) {
|
|
18
|
-
out.push('', `${p.name}${p.repo ? ` (${p.repo})` : ' (not a git repo)'}`)
|
|
19
|
+
out.push('', `${p.name}${p.here ? ' (here)' : ''}${p.repo ? ` (${p.repo})` : ' (not a git repo)'}`)
|
|
19
20
|
for (const g of p.groups) {
|
|
20
21
|
const head = g.spec ? `${g.spec}${g.ticket ? ` [${g.ticket.id}]` : ''}` : `${g.branch || '(no branch)'} — no spec`
|
|
21
22
|
out.push(` ${head}`)
|
|
23
|
+
for (const w of g.wins || []) out.push(` ★ ${w.kind === 'saved-bacon' ? 'saved bacon' : 'win'}: ${w.what}`)
|
|
22
24
|
for (const e of g.events) out.push(` * ${e.kind === 'phase-done' ? `phase ${e.phase} done` : e.kind}`)
|
|
23
25
|
for (const c of g.commits) out.push(` + ${c.sha} ${c.subject}`)
|
|
24
26
|
const sessions = g.sessions.length
|
package/src/tada/page.js
CHANGED
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
* text, so a `<script>` in a prompt arrives as text, never as a tag.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
const todo = require('./todo.js')
|
|
18
|
+
|
|
19
|
+
const blockedText = (b) => todo.blockedText(b, new Date())
|
|
20
|
+
|
|
17
21
|
function escapeHtml(s) {
|
|
18
22
|
return String(s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c])
|
|
19
23
|
}
|
|
@@ -93,17 +97,28 @@ function groupHtml(g) {
|
|
|
93
97
|
? `<span class="spec">${escapeHtml(g.spec)}</span>${ticketHtml(g.ticket)}`
|
|
94
98
|
: `<span class="branch">${escapeHtml(g.branch || '(no branch)')}</span> <span class="muted">no spec</span>`
|
|
95
99
|
const parts = [`<h4>${head}</h4>`]
|
|
96
|
-
if (g.
|
|
100
|
+
if (g.wins && g.wins.length) {
|
|
101
|
+
parts.push(
|
|
102
|
+
`<div class="chips">${g.wins
|
|
103
|
+
.map((w) => `<span class="chip win">★ ${w.kind === 'saved-bacon' ? 'saved bacon' : 'win'}: ${escapeHtml(w.what)}</span>`)
|
|
104
|
+
.join('')}</div>`,
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
// A to-do group carries where it was left and the last thing typed, in
|
|
108
|
+
// place of the day's full moves, commits and sessions.
|
|
109
|
+
if (g.left) parts.push(`<p>left: ${escapeHtml(g.left)}</p>`)
|
|
110
|
+
if (g.prompt) parts.push(`<p class="muted">${escapeHtml(g.prompt)}</p>`)
|
|
111
|
+
if ((g.events || []).length) {
|
|
97
112
|
parts.push(`<div class="chips">${g.events.map((e) => `<span class="chip">${escapeHtml(eventText(e))}</span>`).join('')}</div>`)
|
|
98
113
|
}
|
|
99
|
-
if (g.commits.length) {
|
|
114
|
+
if ((g.commits || []).length) {
|
|
100
115
|
parts.push(
|
|
101
116
|
`<ul class="commits">${g.commits
|
|
102
117
|
.map((c) => `<li><code>${escapeHtml(c.sha)}</code> ${escapeHtml(c.subject)}</li>`)
|
|
103
118
|
.join('')}</ul>`,
|
|
104
119
|
)
|
|
105
120
|
}
|
|
106
|
-
if (g.sessions.length) {
|
|
121
|
+
if ((g.sessions || []).length) {
|
|
107
122
|
const prompts = g.sessions
|
|
108
123
|
.map(
|
|
109
124
|
(s) =>
|
|
@@ -121,8 +136,19 @@ function groupHtml(g) {
|
|
|
121
136
|
return `<section class="group">${parts.join('\n')}</section>`
|
|
122
137
|
}
|
|
123
138
|
|
|
139
|
+
// A to-do project's blockers and today-so-far; a ta-da project has neither.
|
|
140
|
+
function projectExtras(p) {
|
|
141
|
+
const parts = []
|
|
142
|
+
if ((p.finished || []).length) parts.push(`<p class="muted">finished: ${p.finished.map(escapeHtml).join(', ')}</p>`)
|
|
143
|
+
for (const b of p.blocked || []) parts.push(`<p class="blocked">blocked: ${escapeHtml(blockedText(b))}</p>`)
|
|
144
|
+
if (p.today && (p.today.commits || p.today.moves)) {
|
|
145
|
+
parts.push(`<p class="muted">today so far: ${p.today.commits} commit${p.today.commits === 1 ? '' : 's'}, ${p.today.moves} move${p.today.moves === 1 ? '' : 's'}</p>`)
|
|
146
|
+
}
|
|
147
|
+
return parts.join('\n')
|
|
148
|
+
}
|
|
149
|
+
|
|
124
150
|
/**
|
|
125
|
-
* @param {object} digest `buildDigest`'s answer
|
|
151
|
+
* @param {object} digest `buildDigest`'s answer, or `buildTodo`'s
|
|
126
152
|
* @param {object} opts
|
|
127
153
|
* - `recap` the model's markdown recap, or null for the digest alone
|
|
128
154
|
* - `title` the page title — the caller's, in the reader's own dates
|
|
@@ -140,8 +166,8 @@ function renderTadaPage(digest, { recap = null, title = 'Ta-da', project = null,
|
|
|
140
166
|
const projects = digest.projects
|
|
141
167
|
.map(
|
|
142
168
|
(p) =>
|
|
143
|
-
`<article class="project"><h3>${escapeHtml(p.name)} <span class="muted">${escapeHtml(p.repo || 'not a git repo')}</span></h3>\n` +
|
|
144
|
-
`${p.groups.map(groupHtml).join('\n') || '<p class="muted">nothing here</p>'}</article>`,
|
|
169
|
+
`<article class="project"><h3>${escapeHtml(p.name)}${p.here ? ' <span class="chip">here</span>' : ''} <span class="muted">${escapeHtml(p.repo || 'not a git repo')}</span></h3>\n` +
|
|
170
|
+
`${p.groups.map(groupHtml).join('\n') || '<p class="muted">nothing here</p>'}${projectExtras(p)}</article>`,
|
|
145
171
|
)
|
|
146
172
|
.join('\n')
|
|
147
173
|
const notes = digest.notes.length ? `<ul class="notes">${digest.notes.map((n) => `<li>${escapeHtml(n)}</li>`).join('')}</ul>` : ''
|
|
@@ -187,11 +213,13 @@ code { font: 0.88em ui-monospace, "SF Mono", Menlo, monospace; overflow-wrap: an
|
|
|
187
213
|
.group { background: var(--panel); border-radius: 8px; padding: 12px 14px; margin: 10px 0; }
|
|
188
214
|
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
|
|
189
215
|
.chip { background: var(--chip-bg); color: var(--chip-fg); border-radius: 999px; padding: 1px 10px; font-size: 0.85em; }
|
|
216
|
+
.chip.win { background: var(--accent); color: var(--bg, #fff); }
|
|
190
217
|
.ticket { font-weight: normal; font-size: 0.9em; }
|
|
191
218
|
ul { padding-left: 1.2em; margin: 6px 0; }
|
|
192
219
|
.commits, .prompts { list-style: none; padding-left: 0; }
|
|
193
220
|
.commits li, .prompts li { overflow-wrap: anywhere; }
|
|
194
221
|
.inflight { margin: 8px 0 0; color: var(--good-fg); }
|
|
222
|
+
.blocked { margin: 8px 0 0; font-weight: 600; }
|
|
195
223
|
.notes { color: var(--muted); font-size: 0.9em; }
|
|
196
224
|
details summary { cursor: pointer; color: var(--muted); }
|
|
197
225
|
</style>
|
|
@@ -202,7 +230,7 @@ ${eyebrow ? `<p class="eyebrow">${eyebrow}</p>` : ''}
|
|
|
202
230
|
<h1>${escapeHtml(name)}</h1>
|
|
203
231
|
${recap ? `<section class="recap">${renderMarkdown(recap)}${written}</section>` : ''}
|
|
204
232
|
<h2>What it was written from</h2>
|
|
205
|
-
${projects ||
|
|
233
|
+
${projects || `<p class="muted">${digest.kind === 'todo' ? 'Nothing in flight.' : 'Nothing in this window.'}</p>`}
|
|
206
234
|
${notes}
|
|
207
235
|
</main>
|
|
208
236
|
</body>
|
package/src/tada/repo.js
CHANGED
|
@@ -69,6 +69,7 @@ function readRepoFacts({ repo, git, config, window }) {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const show = (ref, p) => git(['show', `${ref}:${p}`])
|
|
72
|
+
const tags = tagsBySha(git)
|
|
72
73
|
const onBase = onBaseIn(git, base, span)
|
|
73
74
|
const commits = []
|
|
74
75
|
const events = []
|
|
@@ -84,7 +85,7 @@ function readRepoFacts({ repo, git, config, window }) {
|
|
|
84
85
|
// Where a commit with no spec is reported: the base branch when it is
|
|
85
86
|
// there, else the first branch holding it.
|
|
86
87
|
const branch = landed ? base : branches[0] || null
|
|
87
|
-
commits.push({ sha: c.sha.slice(0, SHORT), at: c.at, subject: c.subject, spec, branch, refs: c.refs })
|
|
88
|
+
commits.push({ sha: c.sha.slice(0, SHORT), at: c.at, subject: c.subject, spec, branch, refs: c.refs, ...(tags.has(c.sha) ? { tags: tags.get(c.sha) } : {}) })
|
|
88
89
|
if (skitterspec) {
|
|
89
90
|
for (const e of lifecycleEvents(c, show)) events.push({ ...e, sha: c.sha.slice(0, SHORT), at: c.at })
|
|
90
91
|
}
|
|
@@ -99,4 +100,23 @@ function readRepoFacts({ repo, git, config, window }) {
|
|
|
99
100
|
return { name, category: projectCategory(config), skitterspec, base, toSpec, ticket, commits, events, notes }
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Every tag, keyed by the commit it names — an annotated tag through the
|
|
105
|
+
* commit it peels to. One read for the repo, not one per commit. A failed read
|
|
106
|
+
* is no tags at all: a release missing from the wins is a quieter error than a
|
|
107
|
+
* report that fails to print.
|
|
108
|
+
*/
|
|
109
|
+
function tagsBySha(git) {
|
|
110
|
+
const out = git(['for-each-ref', '--format=%(objectname) %(*objectname) %(refname:short)', 'refs/tags']) || ''
|
|
111
|
+
const map = new Map()
|
|
112
|
+
for (const line of out.split('\n')) {
|
|
113
|
+
const [obj, peeled, name] = line.split(' ')
|
|
114
|
+
if (!name) continue
|
|
115
|
+
const sha = peeled || obj
|
|
116
|
+
if (!map.has(sha)) map.set(sha, [])
|
|
117
|
+
map.get(sha).push(name)
|
|
118
|
+
}
|
|
119
|
+
return map
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
module.exports = { readRepoFacts, tagsBySha }
|
package/src/tada/serve.js
CHANGED
|
@@ -32,8 +32,11 @@ const BIN = path.join(__dirname, '..', '..', 'bin', 'skitterspec.js')
|
|
|
32
32
|
* absolute day so a link keeps meaning the same thing tomorrow, and the
|
|
33
33
|
* scope flags. `since` and `on` are both day strings (`YYYY-MM-DD`) or absent.
|
|
34
34
|
*/
|
|
35
|
-
function tadaQuery({ on = null, since = null, all = false, chat = false, here = false } = {}) {
|
|
35
|
+
function tadaQuery({ on = null, since = null, all = false, chat = false, here = false, todo = false } = {}) {
|
|
36
36
|
const q = new URLSearchParams()
|
|
37
|
+
// The to-do is always "this morning": its window is the engine's to find,
|
|
38
|
+
// so it carries the day it was asked on and nothing else.
|
|
39
|
+
if (todo) q.set('todo', '1')
|
|
37
40
|
if (on) q.set('on', on)
|
|
38
41
|
else if (since) q.set('since', since)
|
|
39
42
|
if (all) q.set('all', '1')
|
|
@@ -50,7 +53,7 @@ function readTadaQuery(search, now = new Date()) {
|
|
|
50
53
|
const since = q.get('since')
|
|
51
54
|
const window = windowFor({ on: on || undefined, since: since || undefined }, now)
|
|
52
55
|
const flag = (k) => ['1', 'true', ''].includes(q.get(k)) && q.has(k)
|
|
53
|
-
return { on, since, all: flag('all'), chat: flag('chat'), here: flag('here'), window }
|
|
56
|
+
return { on, since, all: flag('all'), chat: flag('chat'), here: flag('here'), todo: flag('todo'), window }
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
/**
|
|
@@ -58,8 +61,8 @@ function readTadaQuery(search, now = new Date()) {
|
|
|
58
61
|
* end: `--since friday` runs to now, so an end-keyed recap would be lost the
|
|
59
62
|
* next morning while the link that names it still works.
|
|
60
63
|
*/
|
|
61
|
-
function recapKey({ on, since, window, all, chat }) {
|
|
62
|
-
const kind = on ? 'on' : since ? 'since' : 'on'
|
|
64
|
+
function recapKey({ on, since, window, all, chat, todo = false }) {
|
|
65
|
+
const kind = todo ? 'todo' : on ? 'on' : since ? 'since' : 'on'
|
|
63
66
|
return `${kind}-${localDay(window.since)}${all ? '-all' : ''}${chat ? '-chat' : ''}`
|
|
64
67
|
}
|
|
65
68
|
|
|
@@ -69,9 +72,12 @@ function recapPath(stateDir, key) {
|
|
|
69
72
|
|
|
70
73
|
/** The CLI's digest for one window, run where the server's project lives. */
|
|
71
74
|
function runDigest({ dir, ask, exec = execFile, bin = BIN }) {
|
|
72
|
-
const args = [bin, 'tada', '--json']
|
|
75
|
+
const args = [bin, ask.todo ? 'todo' : 'tada', '--json']
|
|
73
76
|
const day = localDay(ask.window.since)
|
|
74
|
-
if (ask.
|
|
77
|
+
if (ask.todo) {
|
|
78
|
+
// `todo` finds its own window from today; a page asked for a past day's
|
|
79
|
+
// to-do still shows this morning's, which is the only one there is.
|
|
80
|
+
} else if (ask.on) args.push('--on', day)
|
|
75
81
|
else if (ask.since) args.push('--since', day)
|
|
76
82
|
if (ask.all) args.push('--all-projects')
|
|
77
83
|
if (ask.chat) args.push('--chat')
|
|
@@ -117,7 +123,7 @@ async function renderServedTada({ dir, stateDir, search, project = null, now = n
|
|
|
117
123
|
html: renderTadaPage(out.digest, {
|
|
118
124
|
recap,
|
|
119
125
|
writtenAt,
|
|
120
|
-
title:
|
|
126
|
+
title: `${ask.todo ? 'To-do' : 'Ta-da'} · ${humanLabel(ask.window)}`,
|
|
121
127
|
project,
|
|
122
128
|
category: out.digest.category || null,
|
|
123
129
|
}),
|