@skitterbyte/skitterspec-linear 19.10.0 → 19.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/README.md +3 -0
- 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/core/linear.config.md +7 -0
- 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-linear.js +8 -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/linear/api.js +3 -1
- package/src/vendor/linear/cli-sync.js +165 -14
- package/src/vendor/linear/config.js +3 -1
- package/src/vendor/provider-kit/src/apply.js +90 -5
package/src/tada/todo.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The morning half of the ta-da list (feat-spec-todo, phase 2): where each
|
|
5
|
+
* project was left on the last day with any activity, and what is ahead. It
|
|
6
|
+
* reads the same digest `skitterspec tada` does — once for the lookback, once
|
|
7
|
+
* for the day it found — so the two can never disagree about what happened.
|
|
8
|
+
* Pure: every input arrives already read.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fs = require('node:fs')
|
|
12
|
+
const path = require('node:path')
|
|
13
|
+
|
|
14
|
+
const { localDay } = require('./window.js')
|
|
15
|
+
const { waitingPasses, readGate, gateState } = require('../env/review.js')
|
|
16
|
+
|
|
17
|
+
// Far enough to bridge a long weekend or a week away; past it, "where did I
|
|
18
|
+
// leave off" has no useful answer and the report says so.
|
|
19
|
+
const LOOKBACK_DAYS = 14
|
|
20
|
+
|
|
21
|
+
function daysBefore(d, n) {
|
|
22
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate() - n)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Every instant a digest saw something happen: prompts, sessions, commits, moves. */
|
|
26
|
+
function activityTimes(digest) {
|
|
27
|
+
const times = []
|
|
28
|
+
for (const p of digest.projects) {
|
|
29
|
+
for (const g of p.groups) {
|
|
30
|
+
for (const s of g.sessions) {
|
|
31
|
+
times.push(s.start, s.end)
|
|
32
|
+
for (const pr of s.prompts) times.push(pr.at)
|
|
33
|
+
}
|
|
34
|
+
for (const c of g.commits) times.push(c.at)
|
|
35
|
+
for (const e of g.events) times.push(e.at)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return times.filter(Boolean)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The local midnight of the most recent day before `todayStart` with any
|
|
43
|
+
* activity, at most `lookback` days back — so Monday reads Friday and a day
|
|
44
|
+
* off is skipped. Null when nothing falls in the lookback.
|
|
45
|
+
*
|
|
46
|
+
* @param {string[]} times ISO instants (`activityTimes`)
|
|
47
|
+
* @param {Date} todayStart local midnight today
|
|
48
|
+
*/
|
|
49
|
+
function lastActiveDay(times, todayStart, lookback = LOOKBACK_DAYS) {
|
|
50
|
+
const floor = daysBefore(todayStart, lookback).getTime()
|
|
51
|
+
const end = todayStart.getTime()
|
|
52
|
+
let best = null
|
|
53
|
+
for (const t of times) {
|
|
54
|
+
const ms = Date.parse(t)
|
|
55
|
+
if (Number.isNaN(ms) || ms < floor || ms >= end) continue
|
|
56
|
+
if (best === null || ms > best) best = ms
|
|
57
|
+
}
|
|
58
|
+
if (best === null) return null
|
|
59
|
+
const d = new Date(best)
|
|
60
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate())
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const EVENT = { written: 'written', started: 'started', completed: 'completed', cancelled: 'cancelled' }
|
|
64
|
+
const eventText = (e) => (e.kind === 'phase-done' ? `phase ${e.phase} done` : EVENT[e.kind] || e.kind)
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Where one group was left: its last move or commit, whichever came later —
|
|
68
|
+
* a commit after a move is the newer fact. Null when the group only has
|
|
69
|
+
* sessions or an in-flight row.
|
|
70
|
+
*/
|
|
71
|
+
function leftOf(g) {
|
|
72
|
+
const last = [
|
|
73
|
+
...g.events.map((e) => ({ at: e.at, text: eventText(e) })),
|
|
74
|
+
...g.commits.map((c) => ({ at: c.at, text: `${c.sha} ${c.subject}` })),
|
|
75
|
+
].sort((a, b) => Date.parse(a.at) - Date.parse(b.at))
|
|
76
|
+
return last.length ? last[last.length - 1].text : null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// The last thing typed in the group's last session — what was on the
|
|
80
|
+
// person's mind when they stopped.
|
|
81
|
+
function lastPrompt(g) {
|
|
82
|
+
const s = g.sessions[g.sessions.length - 1]
|
|
83
|
+
const p = s && s.prompts[s.prompts.length - 1]
|
|
84
|
+
return p ? `${p.command ? `${p.command} ` : ''}${p.text}`.trim() : null
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* What stands in a project's way, read only for the specs in flight there: a
|
|
89
|
+
* pass waiting on the review page, or a gate armed by a phase that ended. A
|
|
90
|
+
* pass for a spec no longer in flight is an old one nobody is waiting on, and
|
|
91
|
+
* is left out rather than reported as a blocker.
|
|
92
|
+
*
|
|
93
|
+
* @param {object} a
|
|
94
|
+
* - `specs` the project's in-flight spec names
|
|
95
|
+
* - `passes` `waitingPasses(...).passes`
|
|
96
|
+
* - `gates` `{ [spec]: gateState(...) }`; a missing or `unknown` state is
|
|
97
|
+
* cannot-tell, and says nothing
|
|
98
|
+
*/
|
|
99
|
+
function blockersFrom({ specs, passes = [], gates = {} }) {
|
|
100
|
+
const want = new Set(specs)
|
|
101
|
+
const out = []
|
|
102
|
+
for (const p of passes) {
|
|
103
|
+
if (want.has(p.spec)) out.push({ spec: p.spec, kind: 'verdict', verdict: p.verdict, code: p.code, at: p.at })
|
|
104
|
+
}
|
|
105
|
+
for (const spec of specs) {
|
|
106
|
+
const g = gates[spec]
|
|
107
|
+
if (g && g.state === 'armed') out.push({ spec, kind: 'gate', phase: g.gate ? g.gate.phase : null })
|
|
108
|
+
}
|
|
109
|
+
return out
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* `blockersFrom`, read off one repo's review store. A store that does not
|
|
114
|
+
* exist — a repo that never rendered a review — is nothing in the way, not a
|
|
115
|
+
* failure; an unreadable gate is `gateState`'s cannot-tell and says nothing.
|
|
116
|
+
*
|
|
117
|
+
* @param {string} reviews the repo's reviews dir (`<state dir>/reviews`)
|
|
118
|
+
* @param {string[]} specs its in-flight spec names
|
|
119
|
+
* @param {boolean} [required] `review.required`; false opts the gates out
|
|
120
|
+
*/
|
|
121
|
+
function readBlockers(reviews, specs, required) {
|
|
122
|
+
if (!fs.existsSync(reviews)) return []
|
|
123
|
+
const gates = {}
|
|
124
|
+
for (const spec of specs) gates[spec] = gateState({ ...readGate(path.join(reviews, `${spec}.html`), spec), required })
|
|
125
|
+
return blockersFrom({ specs, passes: waitingPasses(reviews).passes, gates })
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The to-do: the left-off day's projects, each open spec reduced to where it
|
|
130
|
+
* was left, the specs that day finished by name, today's activity so far, and
|
|
131
|
+
* what is blocking each project.
|
|
132
|
+
*
|
|
133
|
+
* @param {object} a
|
|
134
|
+
* - `leftOff` the digest for the left-off day, or null when none
|
|
135
|
+
* - `leftOffDay` that day's local midnight, or null
|
|
136
|
+
* - `today` today's digest so far
|
|
137
|
+
* - `home` the home project as a digest project (in-flight groups
|
|
138
|
+
* only) for when neither digest lists it, else null
|
|
139
|
+
* - `blockersFor` `(repo, specs) => blockers` — read only for a repo
|
|
140
|
+
*/
|
|
141
|
+
function buildTodo({ leftOff, leftOffDay, today, home = null, blockersFor = () => [] }) {
|
|
142
|
+
const projects = new Map()
|
|
143
|
+
const keyOf = (p) => p.repo || p.name
|
|
144
|
+
const entry = (p) => {
|
|
145
|
+
const k = keyOf(p)
|
|
146
|
+
if (!projects.has(k)) projects.set(k, { repo: p.repo, name: p.name, here: false, groups: [], finished: [], today: { commits: 0, moves: 0 } })
|
|
147
|
+
const e = projects.get(k)
|
|
148
|
+
if (p.here) e.here = true
|
|
149
|
+
return e
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
for (const p of leftOff ? leftOff.projects : []) {
|
|
153
|
+
const e = entry(p)
|
|
154
|
+
for (const g of p.groups) {
|
|
155
|
+
// The morning wants what is still open. A spec the day finished is said
|
|
156
|
+
// once, by name; work on no spec is history, not a place to pick up.
|
|
157
|
+
if (!g.inFlight) {
|
|
158
|
+
if (g.spec && g.events.some((ev) => ev.kind === 'completed' || ev.kind === 'cancelled')) e.finished.push(g.spec)
|
|
159
|
+
continue
|
|
160
|
+
}
|
|
161
|
+
const left = leftOf(g)
|
|
162
|
+
const prompt = lastPrompt(g)
|
|
163
|
+
e.groups.push({ spec: g.spec, branch: g.branch, ...(g.ticket ? { ticket: g.ticket } : {}), left, prompt, inFlight: g.inFlight })
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
for (const p of today.projects) {
|
|
167
|
+
const e = entry(p)
|
|
168
|
+
const known = new Set(e.groups.map((g) => g.spec).filter(Boolean))
|
|
169
|
+
for (const g of p.groups) {
|
|
170
|
+
e.today.commits += g.commits.length
|
|
171
|
+
e.today.moves += g.events.length
|
|
172
|
+
// What is ahead in a project the left-off day did not touch.
|
|
173
|
+
if (g.spec && g.inFlight && !known.has(g.spec)) {
|
|
174
|
+
e.groups.push({ spec: g.spec, branch: g.branch, ...(g.ticket ? { ticket: g.ticket } : {}), left: null, prompt: null, inFlight: g.inFlight })
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (home && !projects.has(keyOf(home))) {
|
|
179
|
+
const e = entry({ ...home, here: true })
|
|
180
|
+
for (const g of home.groups) if (g.inFlight) e.groups.push({ spec: g.spec, branch: null, left: null, prompt: null, inFlight: g.inFlight })
|
|
181
|
+
}
|
|
182
|
+
// Ideas are counted for home only: the count is this project's to act on,
|
|
183
|
+
// and asking every project's tracker would turn a morning read into a crawl.
|
|
184
|
+
// Null — could not ask — and zero both print nothing.
|
|
185
|
+
if (home && home.ideas > 0) projects.get(keyOf(home)).ideas = home.ideas
|
|
186
|
+
|
|
187
|
+
const list = [...projects.values()]
|
|
188
|
+
.map((e) => {
|
|
189
|
+
const specs = e.groups.filter((g) => g.spec && g.inFlight).map((g) => g.spec)
|
|
190
|
+
return { ...e, blocked: e.repo && specs.length ? blockersFor(e.repo, specs) : [] }
|
|
191
|
+
})
|
|
192
|
+
.filter((e) => e.groups.length || e.finished.length || e.today.commits || e.today.moves || e.ideas)
|
|
193
|
+
// The home project first: it is the one this session acts on.
|
|
194
|
+
.sort((a, b) => (a.here !== b.here ? (a.here ? -1 : 1) : a.name.localeCompare(b.name)))
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
kind: 'todo',
|
|
198
|
+
leftOff: leftOffDay ? { day: localDay(leftOffDay) } : null,
|
|
199
|
+
lookbackDays: LOOKBACK_DAYS,
|
|
200
|
+
...(today.category ? { category: today.category } : {}),
|
|
201
|
+
projects: list,
|
|
202
|
+
notes: [...new Set([...(leftOff ? leftOff.notes : []), ...today.notes])],
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const ageText = (at, now) => {
|
|
207
|
+
const ms = now - Date.parse(at)
|
|
208
|
+
if (Number.isNaN(ms) || ms < 0) return ''
|
|
209
|
+
const h = Math.floor(ms / 3_600_000)
|
|
210
|
+
return h < 24 ? ` · ${h}h` : ` · ${Math.floor(h / 24)}d`
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function blockedText(b, now) {
|
|
214
|
+
if (b.kind === 'gate') return `${b.spec} — gate armed${b.phase ? `, phase ${b.phase}` : ''}: a verdict is owed`
|
|
215
|
+
return `${b.spec} — ${b.verdict || 'a'} verdict waiting (${b.code}${b.at ? ageText(b.at, now) : ''})`
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* The to-do as text — the same markers as `tada`, plus `left:` for where a
|
|
220
|
+
* group stopped, `finished:` for the specs that day closed, `blocked:` for what stands in a project's way, and `today:`
|
|
221
|
+
* for what has happened since midnight.
|
|
222
|
+
*/
|
|
223
|
+
function formatTodo(todo, now = new Date()) {
|
|
224
|
+
const scope = todo.category ? ` · ${todo.category}` : ''
|
|
225
|
+
const head = todo.leftOff
|
|
226
|
+
? `todo: left off ${todo.leftOff.label || todo.leftOff.day} · today ${todo.todayLabel || ''}`.trimEnd()
|
|
227
|
+
: `todo: nothing in the last ${todo.lookbackDays} days · today ${todo.todayLabel || ''}`.trimEnd()
|
|
228
|
+
const out = [`${head}${scope}`]
|
|
229
|
+
if (todo.projects.length === 0) out.push(' nothing in flight.')
|
|
230
|
+
for (const p of todo.projects) {
|
|
231
|
+
out.push('', `${p.name}${p.here ? ' (here)' : ''}${p.repo ? ` (${p.repo})` : ''}`)
|
|
232
|
+
for (const g of p.groups) {
|
|
233
|
+
out.push(` ${g.spec ? `${g.spec}${g.ticket ? ` [${g.ticket.id}]` : ''}` : `${g.branch || '(no branch)'} — no spec`}`)
|
|
234
|
+
if (g.left) out.push(` left: ${g.left}`)
|
|
235
|
+
if (g.prompt) out.push(` - ${g.prompt}`)
|
|
236
|
+
if (g.inFlight) out.push(` in flight: ${g.inFlight.detail}${g.inFlight.next ? ` · next: ${g.inFlight.next}` : ''}`)
|
|
237
|
+
}
|
|
238
|
+
if (p.finished.length) out.push(` finished: ${p.finished.join(', ')}`)
|
|
239
|
+
for (const b of p.blocked) out.push(` blocked: ${blockedText(b, now)}`)
|
|
240
|
+
if (p.ideas) out.push(` ideas: ${p.ideas} waiting · /spec-idea lists them`)
|
|
241
|
+
if (p.today.commits || p.today.moves) {
|
|
242
|
+
const parts = [p.today.commits && `${p.today.commits} commit${p.today.commits === 1 ? '' : 's'}`, p.today.moves && `${p.today.moves} move${p.today.moves === 1 ? '' : 's'}`]
|
|
243
|
+
out.push(` today: ${parts.filter(Boolean).join(', ')}`)
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
for (const n of todo.notes) out.push('', n)
|
|
247
|
+
return out.join('\n') + '\n'
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
module.exports = { LOOKBACK_DAYS, activityTimes, lastActiveDay, leftOf, blockersFrom, readBlockers, buildTodo, formatTodo, blockedText }
|
package/src/vendor/linear/api.js
CHANGED
|
@@ -352,10 +352,12 @@ function makeApiAdapter({ apiKey, fetch: fetchImpl, endpoint, sleep, maxRetries
|
|
|
352
352
|
// The intake inbox. A free-text term uses Linear's `searchIssues` query; a
|
|
353
353
|
// label/team filter alone uses `issues`. Two queries rather than one because
|
|
354
354
|
// Linear exposes text search as its own root field, not an `IssueFilter` key.
|
|
355
|
-
async searchIssues({ label, query, teamId } = {}) {
|
|
355
|
+
async searchIssues({ label, query, teamId, openOnly = false } = {}) {
|
|
356
356
|
const filter = {}
|
|
357
357
|
if (label) filter.labels = { name: { eq: label } }
|
|
358
358
|
if (teamId) filter.team = { id: { eq: teamId } }
|
|
359
|
+
// Open means neither finished nor cancelled — what `idea list` wants.
|
|
360
|
+
if (openOnly) filter.state = { type: { nin: ['completed', 'canceled'] } }
|
|
359
361
|
if (query) {
|
|
360
362
|
const data = await call(
|
|
361
363
|
`query($term: String!, $filter: IssueFilter) {
|
|
@@ -138,7 +138,7 @@ async function specSyncBoard(dir, config, specArg, flags, out) {
|
|
|
138
138
|
const specSyncWhoami = (dir, config, flags, out) => assignment.whoami(dir, config, flags, out)
|
|
139
139
|
const specSyncUsers = (dir, config, query, flags, out) => assignment.users(dir, config, query, flags, out)
|
|
140
140
|
const { readAllStdin, promptHidden } = require('../provider-kit/src/prompt.js')
|
|
141
|
-
const { applySpecPlan } = require('../provider-kit/src/apply.js')
|
|
141
|
+
const { applySpecPlan, heldFlags, heldOverMcp } = require('../provider-kit/src/apply.js')
|
|
142
142
|
|
|
143
143
|
// Spec resolution, listing and lint reporting come from the provider kit
|
|
144
144
|
// (`src/specs.js`), keyed by this provider's `config.fields`. `linkedIdentifier`
|
|
@@ -178,6 +178,109 @@ function specSyncLinked(dir, config, flags, out) {
|
|
|
178
178
|
out.write(lines.join('\n') + '\n')
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
+
// `idea add|list|drop` — the store `skitterspec idea` hands Linear: an issue in
|
|
182
|
+
// the configured team carrying `intake.ideaLabel`, deliberately in NO project.
|
|
183
|
+
// A project is where specs live; a parked thought does not belong to one.
|
|
184
|
+
// `/spec KEY-N` adopts an idea like any other issue, which is why an adopted
|
|
185
|
+
// one drops out of `list`.
|
|
186
|
+
//
|
|
187
|
+
// API only. Without a key a capture REFUSES (exit 1) and hands the text back —
|
|
188
|
+
// a write that did not happen must not read as one that did — while the
|
|
189
|
+
// listing exits 0 with `count: null`, because zero ideas and "could not ask"
|
|
190
|
+
// are different answers.
|
|
191
|
+
async function specSyncIdea(dir, config, positional, flags, out) {
|
|
192
|
+
const [verb, ...words] = positional
|
|
193
|
+
const label = config.intake.ideaLabel
|
|
194
|
+
const teamId = config.linear.teamId
|
|
195
|
+
const text = words.join(' ')
|
|
196
|
+
const say = (json, lines) => out.write(flags.json ? JSON.stringify(json, null, 2) + '\n' : lines.join('\n') + '\n')
|
|
197
|
+
const refuse = (reason, extra = {}) => {
|
|
198
|
+
const back = verb === 'add' && text ? `\n your idea, so nothing is lost:\n ${text.replace(/\n/g, '\n ')}` : ''
|
|
199
|
+
say({ ok: false, store: 'linear', refused: reason, ...extra }, [`spec-sync idea: ${reason}${back}`])
|
|
200
|
+
return 1
|
|
201
|
+
}
|
|
202
|
+
if (!['add', 'list', 'drop'].includes(verb)) {
|
|
203
|
+
out.write('Usage: skitterspec spec-sync idea add <text> | list [--count] | drop <KEY-N> [--reason <why>] [--json]\n')
|
|
204
|
+
return verb ? 1 : 0
|
|
205
|
+
}
|
|
206
|
+
if (!label) return refuse('intake.ideaLabel is empty — an idea is an issue carrying that label, so set one')
|
|
207
|
+
if (!teamId) return refuse('linear.teamId is not set — an idea is filed in the configured team')
|
|
208
|
+
|
|
209
|
+
const key = resolveApiKey(config, flags.env || process.env)
|
|
210
|
+
if (resolveTransport(flags, config, key.ok) === 'mcp' || !key.ok) {
|
|
211
|
+
const why = key.ok ? '--via mcp was requested' : key.error.split('\n')[0]
|
|
212
|
+
if (verb === 'list') {
|
|
213
|
+
say({ store: 'linear', count: null, ideas: null }, [`spec-sync idea: needs the API — ${why}`])
|
|
214
|
+
return 0
|
|
215
|
+
}
|
|
216
|
+
return refuse(`needs the API — ${why}; nothing was written`, verb === 'add' ? { text } : {})
|
|
217
|
+
}
|
|
218
|
+
const linear = flags.adapter || makeApiAdapter({ apiKey: key.key, fetch: flags.fetch })
|
|
219
|
+
|
|
220
|
+
const open = async () => {
|
|
221
|
+
const claimed = new Set(listSpecs(dir, config).map((s) => s.identifier).filter(Boolean))
|
|
222
|
+
const issues = await linear.searchIssues({ label, teamId, openOnly: true })
|
|
223
|
+
return issues.filter((i) => !claimed.has(i.identifier))
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
try {
|
|
227
|
+
if (verb === 'add') {
|
|
228
|
+
const lines = text.replace(/\r\n/g, '\n').split('\n')
|
|
229
|
+
const at = lines.findIndex((l) => l.trim())
|
|
230
|
+
if (at === -1) return refuse('nothing to capture — give the idea some text')
|
|
231
|
+
const title = lines[at].trim()
|
|
232
|
+
const description = lines.slice(at + 1).join('\n').trim()
|
|
233
|
+
const found = (await linear.listLabels(teamId)).find((l) => String(l.name).toLowerCase() === label.toLowerCase())
|
|
234
|
+
if (!found) return refuse(`the team has no "${label}" label — create it in Linear, or set intake.ideaLabel`, { text })
|
|
235
|
+
const made = await linear.createIssue({ teamId, title, description, labelIds: [found.id] })
|
|
236
|
+
say({ ok: true, store: 'linear', action: 'add', identifier: made.identifier, url: made.url, title }, [
|
|
237
|
+
`spec-sync idea: filed ${made.identifier} "${title}" (labelled "${label}", in no project)`,
|
|
238
|
+
` url: ${made.url}`,
|
|
239
|
+
` promote: /spec ${made.identifier}`,
|
|
240
|
+
])
|
|
241
|
+
return 0
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (verb === 'list') {
|
|
245
|
+
const ideas = (await open()).map((i) => ({ identifier: i.identifier, title: i.title, url: i.url, promote: `/spec ${i.identifier}` }))
|
|
246
|
+
if (flags.count) {
|
|
247
|
+
say({ store: 'linear', count: ideas.length }, [String(ideas.length)])
|
|
248
|
+
return 0
|
|
249
|
+
}
|
|
250
|
+
say(
|
|
251
|
+
{ store: 'linear', label, ideas },
|
|
252
|
+
ideas.length
|
|
253
|
+
? [`spec-sync idea: "${label}"`, ...ideas.map((i) => ` ${i.identifier}\t${i.title || ''}`)]
|
|
254
|
+
: [`spec-sync idea: nothing waiting under "${label}"`],
|
|
255
|
+
)
|
|
256
|
+
return 0
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// drop. The open-ideas listing is the positive signal that the reference
|
|
260
|
+
// IS an idea — closing an arbitrary issue under that name is the expensive
|
|
261
|
+
// mistake here, so anything not in it is refused and left alone.
|
|
262
|
+
const ref = words[0]
|
|
263
|
+
if (!ref) return refuse('name the idea to drop — `idea list` shows them')
|
|
264
|
+
const issue = (await open()).find((i) => i.identifier === ref || i.id === ref)
|
|
265
|
+
if (!issue) return refuse(`${ref} is not an open idea under "${label}" — left alone`)
|
|
266
|
+
const cancelled = (await linear.listIssueStates(teamId)).find((s) => s.type === 'canceled')
|
|
267
|
+
if (!cancelled) return refuse('the team has no cancelled state to move the idea to')
|
|
268
|
+
const why = flags.reason && String(flags.reason).trim() ? String(flags.reason).trim() : 'no reason given'
|
|
269
|
+
await linear.createComment(issue.id, `Dropped as an idea: ${why}`)
|
|
270
|
+
await linear.updateIssue(issue.id, { stateId: cancelled.id })
|
|
271
|
+
say({ ok: true, store: 'linear', action: 'drop', identifier: issue.identifier, title: issue.title, reason: why }, [
|
|
272
|
+
`spec-sync idea: dropped ${issue.identifier} "${issue.title || ''}" — moved to ${cancelled.name} (${why})`,
|
|
273
|
+
])
|
|
274
|
+
return 0
|
|
275
|
+
} catch (error) {
|
|
276
|
+
if (verb === 'list') {
|
|
277
|
+
say({ store: 'linear', count: null, ideas: null }, [`spec-sync idea: ${error.message}`])
|
|
278
|
+
return 1
|
|
279
|
+
}
|
|
280
|
+
return refuse(`Linear refused — ${error.message}`, verb === 'add' ? { text } : {})
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
181
284
|
// `spec-sync normalize <spec>` — print the local projection as JSON.
|
|
182
285
|
function specSyncNormalize(dir, config, specArg, out, err) {
|
|
183
286
|
const snapshotDir = resolveOrExit(specArg, dir, out)
|
|
@@ -432,11 +535,14 @@ function specSyncStamp(dir, config, specArg, flags, out) {
|
|
|
432
535
|
|
|
433
536
|
// `spec-sync record <spec>` — write the last-pushed snapshot from the CURRENT
|
|
434
537
|
// files. The skill calls this AFTER applying the plan and stamping new ids.
|
|
435
|
-
function specSyncRecord(dir, config, specArg, out) {
|
|
538
|
+
function specSyncRecord(dir, config, specArg, flags, out) {
|
|
436
539
|
const snapshotDir = resolveOrExit(specArg, dir, out)
|
|
437
540
|
if (!snapshotDir) return 1
|
|
438
541
|
const identifier = specIdentifier(snapshotDir, config)
|
|
439
|
-
|
|
542
|
+
// --held: the hand-applied twin of `apply --hold-state` — the state was left
|
|
543
|
+
// out on purpose, and is recorded as sent so run 2 rewrites nothing.
|
|
544
|
+
const sent = flags && flags.held ? { issue: true, subIssues: new Set() } : null
|
|
545
|
+
const file = recordPush({ dir, snapshotDir, identifier, config, sent })
|
|
440
546
|
out.write(`spec-sync record: snapshot written → ${path.relative(dir, file).split(path.sep).join('/')}\n`)
|
|
441
547
|
}
|
|
442
548
|
|
|
@@ -2309,7 +2415,20 @@ function specKindOf(snapshotDir) {
|
|
|
2309
2415
|
return 'feature'
|
|
2310
2416
|
}
|
|
2311
2417
|
|
|
2312
|
-
async function applyOneSpec({
|
|
2418
|
+
async function applyOneSpec({
|
|
2419
|
+
dir,
|
|
2420
|
+
config,
|
|
2421
|
+
snapshotDir,
|
|
2422
|
+
plan,
|
|
2423
|
+
adapter,
|
|
2424
|
+
teamId,
|
|
2425
|
+
project,
|
|
2426
|
+
states,
|
|
2427
|
+
forceNew = false,
|
|
2428
|
+
holdState = false,
|
|
2429
|
+
sendHeld = false,
|
|
2430
|
+
out = null,
|
|
2431
|
+
}) {
|
|
2313
2432
|
const kind = specKindOf(snapshotDir)
|
|
2314
2433
|
// Per-kind state resolution: statesByKind[kind] overlays states inside
|
|
2315
2434
|
// stateIdFor, and a bucket overridden to null resolves to no transition.
|
|
@@ -2424,7 +2543,7 @@ async function applyOneSpec({ dir, config, snapshotDir, plan, adapter, teamId, p
|
|
|
2424
2543
|
}))
|
|
2425
2544
|
},
|
|
2426
2545
|
}
|
|
2427
|
-
return applySpecPlan({ dir, config, snapshotDir, plan, adapter, ops, forceNew })
|
|
2546
|
+
return applySpecPlan({ dir, config, snapshotDir, plan, adapter, ops, forceNew, holdState, sendHeld, program: 'spec-sync' })
|
|
2428
2547
|
}
|
|
2429
2548
|
|
|
2430
2549
|
|
|
@@ -2460,6 +2579,11 @@ async function applyOneSpec({ dir, config, snapshotDir, plan, adapter, teamId, p
|
|
|
2460
2579
|
*/
|
|
2461
2580
|
async function specSyncApply(dir, config, specArg, flags, out) {
|
|
2462
2581
|
const bulk = flags.all != null
|
|
2582
|
+
const held = heldFlags(flags, 'spec-sync')
|
|
2583
|
+
if (held.error) {
|
|
2584
|
+
out.write(held.error + '\n')
|
|
2585
|
+
return 1
|
|
2586
|
+
}
|
|
2463
2587
|
if (bulk && !BUCKETS.includes(flags.all)) {
|
|
2464
2588
|
out.write(`spec-sync apply: --all ${flags.all} is not a bucket (${BUCKETS.join('|')})\n`)
|
|
2465
2589
|
return 1
|
|
@@ -2470,7 +2594,11 @@ async function specSyncApply(dir, config, specArg, flags, out) {
|
|
|
2470
2594
|
if (!bulk) {
|
|
2471
2595
|
snapshotDir = resolveOrExit(specArg, dir, out)
|
|
2472
2596
|
if (!snapshotDir) return 1
|
|
2473
|
-
if (!flags.plan) {
|
|
2597
|
+
if (!flags.plan && held.sendHeld) {
|
|
2598
|
+
// --send-held computes its own. After the merge it is normally empty, and
|
|
2599
|
+
// that empty plan is what tells apply that run 1 held the state.
|
|
2600
|
+
plan = push({ dir, snapshotDir, identifier: specIdentifier(snapshotDir, config), config }).plan
|
|
2601
|
+
} else if (!flags.plan) {
|
|
2474
2602
|
out.write(
|
|
2475
2603
|
'spec-sync apply: refusing to run without --plan <file>.\n' +
|
|
2476
2604
|
' Get one with: skitterspec spec-sync plan <spec> --json > plan.json\n' +
|
|
@@ -2478,11 +2606,13 @@ async function specSyncApply(dir, config, specArg, flags, out) {
|
|
|
2478
2606
|
)
|
|
2479
2607
|
return 1
|
|
2480
2608
|
}
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2609
|
+
if (flags.plan) {
|
|
2610
|
+
try {
|
|
2611
|
+
plan = JSON.parse(fs.readFileSync(flags.plan, 'utf-8'))
|
|
2612
|
+
} catch (error) {
|
|
2613
|
+
out.write(`spec-sync apply: cannot read --plan ${flags.plan}: ${error.message}\n`)
|
|
2614
|
+
return 1
|
|
2615
|
+
}
|
|
2486
2616
|
}
|
|
2487
2617
|
|
|
2488
2618
|
// A pre-9.0 mirror reads as unlinked, so its plan is all-creates and applying
|
|
@@ -2494,7 +2624,7 @@ async function specSyncApply(dir, config, specArg, flags, out) {
|
|
|
2494
2624
|
)
|
|
2495
2625
|
return 1
|
|
2496
2626
|
}
|
|
2497
|
-
if (isEmptyPlan(plan)) {
|
|
2627
|
+
if (!held.sendHeld && isEmptyPlan(plan)) {
|
|
2498
2628
|
out.write('spec-sync apply: nothing to apply — the mirror is up to date.\n')
|
|
2499
2629
|
return 0
|
|
2500
2630
|
}
|
|
@@ -2523,6 +2653,7 @@ async function specSyncApply(dir, config, specArg, flags, out) {
|
|
|
2523
2653
|
' apply the plan over MCP as /spec-push describes, then run:',
|
|
2524
2654
|
' skitterspec spec-sync stamp <spec> --issue … [--sub <ref>=… …]',
|
|
2525
2655
|
' skitterspec spec-sync record <spec>',
|
|
2656
|
+
...[heldOverMcp(held, 'spec-sync')].filter(Boolean),
|
|
2526
2657
|
].join('\n') + '\n',
|
|
2527
2658
|
)
|
|
2528
2659
|
return 0
|
|
@@ -2543,7 +2674,18 @@ async function specSyncApply(dir, config, specArg, flags, out) {
|
|
|
2543
2674
|
out.write(`spec-sync apply: ${error.message}\n`)
|
|
2544
2675
|
return 1
|
|
2545
2676
|
}
|
|
2546
|
-
const shared = {
|
|
2677
|
+
const shared = {
|
|
2678
|
+
dir,
|
|
2679
|
+
config,
|
|
2680
|
+
adapter,
|
|
2681
|
+
teamId,
|
|
2682
|
+
project: flags.project,
|
|
2683
|
+
states,
|
|
2684
|
+
forceNew: flags.forceNew,
|
|
2685
|
+
holdState: held.holdState,
|
|
2686
|
+
sendHeld: held.sendHeld,
|
|
2687
|
+
out,
|
|
2688
|
+
}
|
|
2547
2689
|
|
|
2548
2690
|
if (!bulk) {
|
|
2549
2691
|
const lines = ['spec-sync apply: transport = api']
|
|
@@ -3426,6 +3568,9 @@ async function specSync(rest, io = {}) {
|
|
|
3426
3568
|
// Distinct from `--force`, deliberately. That one overrides other guards;
|
|
3427
3569
|
// this one says "the duplicate title is real, create a second issue".
|
|
3428
3570
|
else if (args[i] === '--force-new') flags.forceNew = true
|
|
3571
|
+
else if (args[i] === '--hold-state') flags.holdState = true
|
|
3572
|
+
else if (args[i] === '--send-held') flags.sendHeld = true
|
|
3573
|
+
else if (args[i] === '--held') flags.held = true
|
|
3429
3574
|
else if (args[i] === '--yes') flags.yes = true
|
|
3430
3575
|
else if (args[i] === '--check-remote') flags.remoteCheck = true
|
|
3431
3576
|
else if (args[i] === '--stdin') flags.stdin = true
|
|
@@ -3438,6 +3583,8 @@ async function specSync(rest, io = {}) {
|
|
|
3438
3583
|
else if (args[i] === '--to') flags.to = String(args[++i] || '').trim()
|
|
3439
3584
|
else if (args[i] === '--release') flags.release = true
|
|
3440
3585
|
else if (args[i] === '--if-unassigned') flags.ifUnassigned = true
|
|
3586
|
+
else if (args[i] === '--reason') flags.reason = args[++i]
|
|
3587
|
+
else if (args[i] === '--count') flags.count = true
|
|
3441
3588
|
else if (args[i] === '--no-assign') flags.noAssign = true
|
|
3442
3589
|
else if (args[i] === '--limit') flags.limit = Number(args[++i]) || 0
|
|
3443
3590
|
else if (args[i] === '--cursor') flags.cursor = String(args[++i] || '').trim()
|
|
@@ -3548,7 +3695,7 @@ async function specSync(rest, io = {}) {
|
|
|
3548
3695
|
case 'stamp':
|
|
3549
3696
|
return specSyncStamp(dir, config, positional[0], flags, out)
|
|
3550
3697
|
case 'record':
|
|
3551
|
-
return specSyncRecord(dir, config, positional[0], out) || 0
|
|
3698
|
+
return specSyncRecord(dir, config, positional[0], flags, out) || 0
|
|
3552
3699
|
case 'status':
|
|
3553
3700
|
return specSyncStatus(dir, config, positional[0], flags, out) || 0
|
|
3554
3701
|
case 'projects':
|
|
@@ -3587,6 +3734,8 @@ async function specSync(rest, io = {}) {
|
|
|
3587
3734
|
case 'linked':
|
|
3588
3735
|
specSyncLinked(dir, config, flags, out)
|
|
3589
3736
|
return 0
|
|
3737
|
+
case 'idea':
|
|
3738
|
+
return specSyncIdea(dir, config, positional, flags, out)
|
|
3590
3739
|
case 'ownership':
|
|
3591
3740
|
return specSyncOwnership(config, flags, out, 'spec-sync')
|
|
3592
3741
|
case 'board':
|
|
@@ -3604,6 +3753,7 @@ async function specSync(rest, io = {}) {
|
|
|
3604
3753
|
' skitterspec spec-sync users [<name-or-email>] [--limit N] [--cursor C] [--json]\n' +
|
|
3605
3754
|
' skitterspec spec-sync assign <spec> --to <id> [--name N] [--if-unassigned] | --release [--json]\n' +
|
|
3606
3755
|
' skitterspec spec-sync apply <spec> --plan <file> [--via api|mcp] [--project id] [--json]\n' +
|
|
3756
|
+
' skitterspec spec-sync apply <spec> --hold-state | --send-held (PR-mode completion)\n' +
|
|
3607
3757
|
' skitterspec spec-sync apply --all <bucket> [--via api|mcp] [--json]\n' +
|
|
3608
3758
|
' skitterspec spec-sync verify <spec> --stored <file>\n' +
|
|
3609
3759
|
' skitterspec spec-sync splice <spec> --live <file> [--phase <ref>]\n' +
|
|
@@ -3611,6 +3761,7 @@ async function specSync(rest, io = {}) {
|
|
|
3611
3761
|
' skitterspec spec-sync comment <spec> --file <file> [--via api|mcp]\n' +
|
|
3612
3762
|
' skitterspec spec-sync list [--state <name> …|--all|--in-progress] [--next N] [--mine|--by <user>] [--limit N] [--archived] [--json]\n' +
|
|
3613
3763
|
' skitterspec spec-sync linked [--json]\n' +
|
|
3764
|
+
' skitterspec spec-sync idea add <text> | list [--count] | drop <KEY-N> [--reason R] [--json]\n' +
|
|
3614
3765
|
' skitterspec spec-sync ownership [--json]\n' +
|
|
3615
3766
|
' skitterspec spec-sync board <spec> [--json]\n' +
|
|
3616
3767
|
' skitterspec spec-sync ref [<spec>] [--json]\n' +
|
|
@@ -145,7 +145,7 @@ const DEFAULT_CONFIG = Object.freeze({
|
|
|
145
145
|
// feature, and the only signal would be noticing a lost report weeks later.
|
|
146
146
|
// Being wrong in this direction costs a comment nobody needed; the other
|
|
147
147
|
// direction costs someone their words.
|
|
148
|
-
intake: Object.freeze({ label: '', bugLabels: Object.freeze([]), hotfixLabels: Object.freeze([]), preserveOriginal: true }),
|
|
148
|
+
intake: Object.freeze({ label: '', ideaLabel: 'idea', bugLabels: Object.freeze([]), hotfixLabels: Object.freeze([]), preserveOriginal: true }),
|
|
149
149
|
// A spec is a Linear ISSUE; each phase is a SUB-ISSUE of it; tasks are not
|
|
150
150
|
// synced (they live only in the repo phase files).
|
|
151
151
|
// A spec is an ISSUE; each phase a SUB-ISSUE of it. `tasks` selects how the
|
|
@@ -282,6 +282,7 @@ function defaults() {
|
|
|
282
282
|
linear: { ...DEFAULT_CONFIG.linear, labelsByKind: { ...DEFAULT_CONFIG.linear.labelsByKind }, severityLabels: { ...DEFAULT_CONFIG.linear.severityLabels } },
|
|
283
283
|
intake: {
|
|
284
284
|
label: DEFAULT_CONFIG.intake.label,
|
|
285
|
+
ideaLabel: DEFAULT_CONFIG.intake.ideaLabel,
|
|
285
286
|
bugLabels: [...DEFAULT_CONFIG.intake.bugLabels],
|
|
286
287
|
hotfixLabels: [...DEFAULT_CONFIG.intake.hotfixLabels],
|
|
287
288
|
preserveOriginal: DEFAULT_CONFIG.intake.preserveOriginal,
|
|
@@ -355,6 +356,7 @@ function mergeConfig(base, parsed) {
|
|
|
355
356
|
|
|
356
357
|
if (isObject(parsed.intake)) {
|
|
357
358
|
assign(base.intake, parsed.intake, 'label', 'string?')
|
|
359
|
+
assign(base.intake, parsed.intake, 'ideaLabel', 'string?')
|
|
358
360
|
if (Array.isArray(parsed.intake.bugLabels)) {
|
|
359
361
|
base.intake.bugLabels = stringList(parsed.intake.bugLabels)
|
|
360
362
|
}
|