@soleur/opencode 3.401.2 → 3.403.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/package.json
CHANGED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Read-only intake of a specs/<prefix>-<short-name>/ directory. Writes nothing.
|
|
3
|
+
exec python3 - "$@" <<'PY'
|
|
4
|
+
import errno
|
|
5
|
+
import hashlib
|
|
6
|
+
import os
|
|
7
|
+
import re
|
|
8
|
+
import stat
|
|
9
|
+
import sys
|
|
10
|
+
|
|
11
|
+
CAP = 1048576
|
|
12
|
+
DIR_FLAGS = os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW | os.O_NONBLOCK
|
|
13
|
+
FILE_FLAGS = os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK
|
|
14
|
+
CLOSED_NEVER = ("research.md", "data-model.md", "contracts", "quickstart.md")
|
|
15
|
+
MARKERS = ("--- side-evidence ---", "--- projected ---")
|
|
16
|
+
READ_NAMES = ("spec.md", "plan.md", "tasks.md")
|
|
17
|
+
LEAF_TS = re.compile(r"[0-9]{8}-[0-9]{6}-[A-Za-z0-9][A-Za-z0-9_-]*\Z")
|
|
18
|
+
LEAF_NUM = re.compile(r"[0-9]{3}-[A-Za-z0-9][A-Za-z0-9_-]*\Z")
|
|
19
|
+
ATX = re.compile(r"^#{1,6}[ \t]+(.+?)[ \t]*\Z")
|
|
20
|
+
USER_STORY = re.compile(r"(?<![A-Za-z0-9])user\s+story(?![A-Za-z0-9])", re.IGNORECASE)
|
|
21
|
+
PRIORITY = re.compile(r"\bP[123]\b")
|
|
22
|
+
FENCE = re.compile(r"^( {0,3})(`{3,}|~{3,})(.*)\Z")
|
|
23
|
+
LABEL_LINE = re.compile(r"(?:moved|unmapped|never-read):")
|
|
24
|
+
DIGEST_LINE = re.compile(
|
|
25
|
+
r"(?:spec|plan|tasks)\.md (?:absent|[0-9]+ [0-9a-f]{64}(?: not-requirements)?)\Z"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def refuse(reason):
|
|
30
|
+
sys.stdout.write("intake: %s\n" % reason)
|
|
31
|
+
raise SystemExit(1)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def valid_leaf(name):
|
|
35
|
+
return LEAF_TS.fullmatch(name) is not None or LEAF_NUM.fullmatch(name) is not None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def resolve(cwd, dire):
|
|
39
|
+
if dire.startswith("/"):
|
|
40
|
+
return dire
|
|
41
|
+
if not cwd:
|
|
42
|
+
refuse("not-a-directory")
|
|
43
|
+
if cwd.endswith("/"):
|
|
44
|
+
return cwd + dire
|
|
45
|
+
return cwd + "/" + dire
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def parts_of(path):
|
|
49
|
+
if not path.startswith("/"):
|
|
50
|
+
refuse("not-a-directory")
|
|
51
|
+
parts = [p for p in path.split("/") if p and p != "."]
|
|
52
|
+
if any(p == ".." for p in parts):
|
|
53
|
+
refuse("not-a-directory")
|
|
54
|
+
if len(parts) < 2 or parts[-2] != "specs" or not valid_leaf(parts[-1]):
|
|
55
|
+
refuse("not-a-directory")
|
|
56
|
+
return parts
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def open_dir_component(parent, name):
|
|
60
|
+
"""O_DIRECTORY plus O_NOFOLLOW reports a symlink as ENOTDIR.
|
|
61
|
+
|
|
62
|
+
A second open without O_DIRECTORY still sets O_NOFOLLOW, so a symlink
|
|
63
|
+
returns ELOOP and is not followed. A non-directory is not-a-directory.
|
|
64
|
+
"""
|
|
65
|
+
try:
|
|
66
|
+
return os.open(name, DIR_FLAGS, dir_fd=parent)
|
|
67
|
+
except OSError as err:
|
|
68
|
+
if err.errno == errno.ELOOP:
|
|
69
|
+
refuse("symlink-escape")
|
|
70
|
+
if err.errno != errno.ENOTDIR:
|
|
71
|
+
refuse("not-a-directory")
|
|
72
|
+
try:
|
|
73
|
+
probed = os.open(name, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=parent)
|
|
74
|
+
except OSError as err:
|
|
75
|
+
if err.errno == errno.ELOOP:
|
|
76
|
+
refuse("symlink-escape")
|
|
77
|
+
refuse("not-a-directory")
|
|
78
|
+
os.close(probed)
|
|
79
|
+
refuse("not-a-directory")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def walk(parts):
|
|
83
|
+
try:
|
|
84
|
+
fd = os.open("/", DIR_FLAGS)
|
|
85
|
+
except OSError:
|
|
86
|
+
refuse("not-a-directory")
|
|
87
|
+
try:
|
|
88
|
+
for name in parts:
|
|
89
|
+
nxt = open_dir_component(fd, name)
|
|
90
|
+
os.close(fd)
|
|
91
|
+
fd = nxt
|
|
92
|
+
owned = fd
|
|
93
|
+
fd = -1
|
|
94
|
+
return owned
|
|
95
|
+
finally:
|
|
96
|
+
if fd >= 0:
|
|
97
|
+
os.close(fd)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def hostile(name):
|
|
101
|
+
if name in MARKERS:
|
|
102
|
+
return True
|
|
103
|
+
for ch in name:
|
|
104
|
+
code = ord(ch)
|
|
105
|
+
if code < 32 and code != 9:
|
|
106
|
+
return True
|
|
107
|
+
if code in (127, 0x85, 0x2028, 0x2029):
|
|
108
|
+
return True
|
|
109
|
+
return False
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def load_file(dir_fd, name):
|
|
113
|
+
try:
|
|
114
|
+
fd = os.open(name, FILE_FLAGS, dir_fd=dir_fd)
|
|
115
|
+
except OSError as err:
|
|
116
|
+
if err.errno == errno.ENOENT:
|
|
117
|
+
return "absent", None
|
|
118
|
+
if err.errno == errno.ELOOP:
|
|
119
|
+
return "symlink-escape", None
|
|
120
|
+
return "unreadable", None
|
|
121
|
+
try:
|
|
122
|
+
st = os.fstat(fd)
|
|
123
|
+
if stat.S_ISLNK(st.st_mode):
|
|
124
|
+
return "symlink-escape", None
|
|
125
|
+
if not stat.S_ISREG(st.st_mode):
|
|
126
|
+
return "not-a-regular-file", None
|
|
127
|
+
if st.st_size > CAP:
|
|
128
|
+
return "over-cap", None
|
|
129
|
+
size = st.st_size
|
|
130
|
+
data = b""
|
|
131
|
+
while len(data) < size:
|
|
132
|
+
chunk = os.read(fd, size - len(data))
|
|
133
|
+
if not chunk:
|
|
134
|
+
break
|
|
135
|
+
data += chunk
|
|
136
|
+
st2 = os.fstat(fd)
|
|
137
|
+
if st2.st_size != size or len(data) != size:
|
|
138
|
+
return "over-cap", None
|
|
139
|
+
return "ok", data
|
|
140
|
+
finally:
|
|
141
|
+
os.close(fd)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def strip_once(data):
|
|
145
|
+
out = bytearray()
|
|
146
|
+
i = 0
|
|
147
|
+
n = len(data)
|
|
148
|
+
while i < n:
|
|
149
|
+
b = data[i]
|
|
150
|
+
if b == 0xC2 and i + 1 < n and data[i + 1] == 0x85:
|
|
151
|
+
i += 2
|
|
152
|
+
continue
|
|
153
|
+
if b == 0xE2 and i + 2 < n and data[i + 1] == 0x80 and data[i + 2] in (0xA8, 0xA9):
|
|
154
|
+
i += 3
|
|
155
|
+
continue
|
|
156
|
+
if b < 32 and b not in (9, 10):
|
|
157
|
+
i += 1
|
|
158
|
+
continue
|
|
159
|
+
if b == 127:
|
|
160
|
+
i += 1
|
|
161
|
+
continue
|
|
162
|
+
out.append(b)
|
|
163
|
+
i += 1
|
|
164
|
+
return bytes(out)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def strip_controls(data):
|
|
168
|
+
cur = data
|
|
169
|
+
for _ in range(len(data) + 1):
|
|
170
|
+
nxt = strip_once(cur)
|
|
171
|
+
if nxt == cur:
|
|
172
|
+
break
|
|
173
|
+
if len(nxt) >= len(cur):
|
|
174
|
+
refuse("unreadable")
|
|
175
|
+
cur = nxt
|
|
176
|
+
else:
|
|
177
|
+
refuse("unreadable")
|
|
178
|
+
try:
|
|
179
|
+
text = cur.decode("utf-8")
|
|
180
|
+
except UnicodeDecodeError:
|
|
181
|
+
refuse("unreadable")
|
|
182
|
+
return text.translate({0x85: None, 0x2028: None, 0x2029: None})
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def heading_text(raw):
|
|
186
|
+
return re.sub(r"[ \t]+#+\Z", "", raw)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def fence_marks(line):
|
|
190
|
+
match = FENCE.match(line)
|
|
191
|
+
if match is None:
|
|
192
|
+
return None
|
|
193
|
+
marks = match.group(2)
|
|
194
|
+
rest = match.group(3)
|
|
195
|
+
if marks[0] == "`" and "`" in rest:
|
|
196
|
+
return None
|
|
197
|
+
return marks[0], len(marks), rest
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def fence_closer(line, char, length):
|
|
201
|
+
found = fence_marks(line)
|
|
202
|
+
if found is None:
|
|
203
|
+
return False
|
|
204
|
+
mark, size, rest = found
|
|
205
|
+
return mark == char and size >= length and rest.strip(" \t") == ""
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def is_delim(line):
|
|
209
|
+
return line.startswith("---") and line[3:].strip(" \t") == ""
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def parse_sections(text):
|
|
213
|
+
if text.startswith("\ufeff"):
|
|
214
|
+
text = text[1:]
|
|
215
|
+
lines = text.split("\n")
|
|
216
|
+
opener = None
|
|
217
|
+
closer = None
|
|
218
|
+
fence = None
|
|
219
|
+
for idx, line in enumerate(lines):
|
|
220
|
+
if fence is not None:
|
|
221
|
+
if fence_closer(line, fence[0], fence[1]):
|
|
222
|
+
fence = None
|
|
223
|
+
continue
|
|
224
|
+
opened = fence_marks(line)
|
|
225
|
+
if opened is not None:
|
|
226
|
+
fence = (opened[0], opened[1])
|
|
227
|
+
continue
|
|
228
|
+
if not is_delim(line):
|
|
229
|
+
continue
|
|
230
|
+
if opener is None:
|
|
231
|
+
opener = idx
|
|
232
|
+
continue
|
|
233
|
+
closer = idx
|
|
234
|
+
break
|
|
235
|
+
if opener is not None and closer is not None:
|
|
236
|
+
lines = lines[:opener] + lines[closer + 1 :]
|
|
237
|
+
sections = []
|
|
238
|
+
title = None
|
|
239
|
+
body = []
|
|
240
|
+
fence = None
|
|
241
|
+
for line in lines:
|
|
242
|
+
if fence is not None:
|
|
243
|
+
if fence_closer(line, fence[0], fence[1]):
|
|
244
|
+
fence = None
|
|
245
|
+
if title is not None:
|
|
246
|
+
body.append(line)
|
|
247
|
+
continue
|
|
248
|
+
opened = fence_marks(line)
|
|
249
|
+
if opened is not None:
|
|
250
|
+
fence = (opened[0], opened[1])
|
|
251
|
+
if title is not None:
|
|
252
|
+
body.append(line)
|
|
253
|
+
continue
|
|
254
|
+
match = ATX.match(line)
|
|
255
|
+
if match:
|
|
256
|
+
if title is not None:
|
|
257
|
+
sections.append((title, "\n".join(body)))
|
|
258
|
+
title = heading_text(match.group(1))
|
|
259
|
+
body = []
|
|
260
|
+
continue
|
|
261
|
+
if title is not None:
|
|
262
|
+
body.append(line)
|
|
263
|
+
if title is not None:
|
|
264
|
+
sections.append((title, "\n".join(body)))
|
|
265
|
+
return sections
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def classify(title, body):
|
|
269
|
+
if "NEEDS CLARIFICATION" in body:
|
|
270
|
+
return "unmapped", title
|
|
271
|
+
folded = title.casefold().strip()
|
|
272
|
+
pri = set(PRIORITY.findall(title))
|
|
273
|
+
if USER_STORY.search(title):
|
|
274
|
+
if "P1" in pri and "P2" not in pri and "P3" not in pri:
|
|
275
|
+
return "fr", body.strip()
|
|
276
|
+
return "unmapped", title
|
|
277
|
+
if folded == "success criteria":
|
|
278
|
+
return "goals", body.strip()
|
|
279
|
+
if folded in ("out of scope", "non-goals", "exclusions"):
|
|
280
|
+
return "nongoals", body.strip()
|
|
281
|
+
return "unmapped", title
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def project(text):
|
|
285
|
+
goals = []
|
|
286
|
+
nongoals = []
|
|
287
|
+
frs = []
|
|
288
|
+
unmapped = []
|
|
289
|
+
for title, body in parse_sections(text):
|
|
290
|
+
kind, payload = classify(title, body)
|
|
291
|
+
if kind == "goals" and payload:
|
|
292
|
+
goals.append(payload)
|
|
293
|
+
elif kind == "nongoals" and payload:
|
|
294
|
+
nongoals.append(payload)
|
|
295
|
+
elif kind == "fr" and payload:
|
|
296
|
+
frs.append(payload)
|
|
297
|
+
else:
|
|
298
|
+
unmapped.append(title)
|
|
299
|
+
moved = []
|
|
300
|
+
if goals:
|
|
301
|
+
moved.append("Goals")
|
|
302
|
+
if nongoals:
|
|
303
|
+
moved.append("Non-Goals")
|
|
304
|
+
if frs:
|
|
305
|
+
moved.append("Functional Requirements")
|
|
306
|
+
body = "\n".join(
|
|
307
|
+
[
|
|
308
|
+
"---",
|
|
309
|
+
"lane: cross-domain",
|
|
310
|
+
"brand_survival_threshold: single-user incident",
|
|
311
|
+
"---",
|
|
312
|
+
"",
|
|
313
|
+
"## Goals",
|
|
314
|
+
"",
|
|
315
|
+
"\n\n".join(goals),
|
|
316
|
+
"",
|
|
317
|
+
"## Non-Goals",
|
|
318
|
+
"",
|
|
319
|
+
"\n\n".join(nongoals),
|
|
320
|
+
"",
|
|
321
|
+
"## Functional Requirements",
|
|
322
|
+
"",
|
|
323
|
+
"\n\n".join(frs),
|
|
324
|
+
"",
|
|
325
|
+
"## Unmapped appendix",
|
|
326
|
+
"",
|
|
327
|
+
"\n".join("- %s" % name for name in unmapped),
|
|
328
|
+
"",
|
|
329
|
+
"Not a requirement. Not built from.",
|
|
330
|
+
"",
|
|
331
|
+
]
|
|
332
|
+
)
|
|
333
|
+
return moved, unmapped, body
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def digest_line(name, data):
|
|
337
|
+
return "%s %s %s" % (name, len(data), hashlib.sha256(data).hexdigest())
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
def indent(text):
|
|
341
|
+
lines = text.split("\n")
|
|
342
|
+
if lines and lines[-1] == "":
|
|
343
|
+
lines = lines[:-1]
|
|
344
|
+
return "\n".join(" " + line for line in lines)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def side_block(name, data, text):
|
|
348
|
+
if data is None:
|
|
349
|
+
return "%s absent" % name
|
|
350
|
+
return digest_line(name, data) + " not-requirements\n" + indent(text)
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
def receipt_lines(key, items):
|
|
354
|
+
if not items:
|
|
355
|
+
return []
|
|
356
|
+
return ["%s: %s" % (key, item) for item in items]
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def forged(projected):
|
|
360
|
+
for line in projected.split("\n"):
|
|
361
|
+
if line in MARKERS or LABEL_LINE.match(line) or DIGEST_LINE.match(line):
|
|
362
|
+
return True
|
|
363
|
+
return False
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def emit(names, spec, plan, tasks):
|
|
367
|
+
spec_text = strip_controls(spec)
|
|
368
|
+
plan_text = None if plan is None else strip_controls(plan)
|
|
369
|
+
tasks_text = None if tasks is None else strip_controls(tasks)
|
|
370
|
+
moved, unmapped, projected = project(spec_text)
|
|
371
|
+
if forged(projected):
|
|
372
|
+
refuse("unreadable")
|
|
373
|
+
never = list(CLOSED_NEVER)
|
|
374
|
+
for name in sorted(names):
|
|
375
|
+
if name in READ_NAMES or name in CLOSED_NEVER:
|
|
376
|
+
continue
|
|
377
|
+
never.append(name)
|
|
378
|
+
lines = ["moved: %s" % (", ".join(moved) if moved else "none")]
|
|
379
|
+
lines.extend(receipt_lines("unmapped", unmapped))
|
|
380
|
+
lines.extend(receipt_lines("never-read", never))
|
|
381
|
+
lines.extend(
|
|
382
|
+
[
|
|
383
|
+
digest_line("spec.md", spec),
|
|
384
|
+
side_block("plan.md", plan, plan_text).split("\n")[0],
|
|
385
|
+
side_block("tasks.md", tasks, tasks_text).split("\n")[0],
|
|
386
|
+
"--- side-evidence ---",
|
|
387
|
+
side_block("plan.md", plan, plan_text),
|
|
388
|
+
side_block("tasks.md", tasks, tasks_text),
|
|
389
|
+
"--- projected ---",
|
|
390
|
+
projected,
|
|
391
|
+
]
|
|
392
|
+
)
|
|
393
|
+
sys.stdout.write("\n".join(lines))
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
def take(dir_fd, name, required):
|
|
397
|
+
status, data = load_file(dir_fd, name)
|
|
398
|
+
if status == "ok":
|
|
399
|
+
return data
|
|
400
|
+
if status == "absent" and not required:
|
|
401
|
+
return None
|
|
402
|
+
if status == "absent" and required:
|
|
403
|
+
refuse("missing-spec")
|
|
404
|
+
refuse(status)
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
def run(argv):
|
|
408
|
+
if "--probe" in argv:
|
|
409
|
+
sys.stdout.write("spec-kit-intake: ok\n")
|
|
410
|
+
return
|
|
411
|
+
cwd = None
|
|
412
|
+
dire = None
|
|
413
|
+
i = 0
|
|
414
|
+
while i < len(argv):
|
|
415
|
+
if argv[i] == "--cwd" and i + 1 < len(argv):
|
|
416
|
+
cwd = argv[i + 1]
|
|
417
|
+
i += 2
|
|
418
|
+
continue
|
|
419
|
+
if argv[i] == "--dir" and i + 1 < len(argv):
|
|
420
|
+
dire = argv[i + 1]
|
|
421
|
+
i += 2
|
|
422
|
+
continue
|
|
423
|
+
refuse("not-a-directory")
|
|
424
|
+
if dire is None:
|
|
425
|
+
refuse("not-a-directory")
|
|
426
|
+
path = resolve(cwd, dire)
|
|
427
|
+
parts = parts_of(path)
|
|
428
|
+
dir_fd = walk(parts)
|
|
429
|
+
try:
|
|
430
|
+
names = []
|
|
431
|
+
with os.scandir(dir_fd) as scan:
|
|
432
|
+
for entry in scan:
|
|
433
|
+
names.append(entry.name)
|
|
434
|
+
for name in names:
|
|
435
|
+
if hostile(name):
|
|
436
|
+
refuse("unreadable")
|
|
437
|
+
spec = take(dir_fd, "spec.md", True)
|
|
438
|
+
plan = take(dir_fd, "plan.md", False)
|
|
439
|
+
tasks = take(dir_fd, "tasks.md", False)
|
|
440
|
+
emit(names, spec, plan, tasks)
|
|
441
|
+
finally:
|
|
442
|
+
os.close(dir_fd)
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
def main():
|
|
446
|
+
try:
|
|
447
|
+
run(sys.argv[1:])
|
|
448
|
+
except SystemExit:
|
|
449
|
+
raise
|
|
450
|
+
except Exception:
|
|
451
|
+
sys.stdout.write("intake: unreadable\n")
|
|
452
|
+
raise SystemExit(1)
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
if __name__ == "__main__":
|
|
456
|
+
main()
|
|
457
|
+
PY
|
|
@@ -40,6 +40,8 @@ Brainstorming helps answer **WHAT** to build through collaborative dialogue. It
|
|
|
40
40
|
|
|
41
41
|
<feature_description> #$ARGUMENTS </feature_description>
|
|
42
42
|
|
|
43
|
+
**Spec Kit directory.** When `$ARGUMENTS` is an existing directory whose last two segments are `specs/<prefix>-<short-name>/` and the branch spec is absent, capture `pwd` before any worktree `cd` and run `"${CLAUDE_PLUGIN_ROOT}/scripts/spec-kit-intake.sh"`. A relative `--dir` uses that `--cwd`. An argument that is already absolute is `--dir` as given. Prose, including a sentence that names a live directory, is not intake: do not call the script. On non-zero, stop: do not edit the kit directory, do not run the script again, and do not paste the path as prose. On zero, show the receipt and keep the absolute directory captured before the worktree `cd`. The projected body is the feature description only for the Brainstorm anyway arm. One-shot and Plan first arms pass that absolute directory, not the projected body and not the raw relative token. One-shot forwards it unchanged as plan's arguments. Do not edit the one-shot skill. When the branch spec exists, including zero bytes, do not run the script and do not replace it. An empty spec directory is not the stop.
|
|
44
|
+
|
|
43
45
|
**If the feature description above is empty, ask the user:** "What would you like to explore? Please describe the feature, problem, or improvement you're thinking about."
|
|
44
46
|
|
|
45
47
|
Do not proceed until you have a feature description from the user.
|
|
@@ -87,7 +89,7 @@ Options:
|
|
|
87
89
|
2. **Plan first** - Use the **Skill tool**: `skill: soleur:plan` to create a plan before implementing
|
|
88
90
|
3. **Brainstorm anyway** - Continue exploring the idea
|
|
89
91
|
|
|
90
|
-
If one-shot is selected,
|
|
92
|
+
If one-shot is selected, stop brainstorm execution. Pass the intake absolute directory when intake ran, otherwise the original feature description. This skips Phases 3, 3.5, and 3.6.
|
|
91
93
|
|
|
92
94
|
### Phase 0.1: User-Impact Framing
|
|
93
95
|
|
|
@@ -561,8 +563,9 @@ Do NOT record a "skipped" outcome and proceed — the only terminal states are `
|
|
|
561
563
|
- Add Functional Requirements (FR1, FR2...) from key features
|
|
562
564
|
- Add Technical Requirements (TR1, TR2...) from constraints
|
|
563
565
|
- **spec.md frontmatter MUST include `lane: <value>`** where `<value>` is the resolved `LANE` from Phase 0.4. spec.md is the canonical post-Phase-3.6 lane source for downstream `plan` and `work` skills (per `## Lane Inference` carry-forward contract). spec.md frontmatter MUST also include `brand_survival_threshold:` matching the Phase 0.1 framing.
|
|
566
|
+
- If a projected body exists, do not generate a second spec. Step 5 writes that body verbatim only when the file is absent.
|
|
564
567
|
|
|
565
|
-
5. **Save spec.md** to the worktree: `<worktree-path>/knowledge-base/project/specs/feat-<name>/spec.md` (replace `<worktree-path>` with the actual worktree path)
|
|
568
|
+
5. **Save spec.md** to the worktree: `<worktree-path>/knowledge-base/project/specs/feat-<name>/spec.md` (replace `<worktree-path>` with the actual worktree path). If the file exists, including a zero-byte file, do not replace it.
|
|
566
569
|
|
|
567
570
|
6. **Commit and push all brainstorm artifacts:**
|
|
568
571
|
|
package/skills/plan/SKILL.md
CHANGED
|
@@ -57,18 +57,12 @@ fi
|
|
|
57
57
|
|
|
58
58
|
**Branch safety check (defense-in-depth):** Run `git branch --show-current`. If the result is `main` or `master`, abort immediately with: "Error: plan cannot run on main/master. Checkout a feature branch first." This check fires in all modes as defense-in-depth alongside PreToolUse hooks -- it fires even if hooks are unavailable (e.g., in CI).
|
|
59
59
|
|
|
60
|
-
**Check for knowledge-base directory and load context:**
|
|
61
|
-
|
|
62
|
-
Check if `knowledge-base/` directory exists. If it does:
|
|
63
|
-
|
|
64
|
-
1. Run `git branch --show-current` to get the current branch name
|
|
65
|
-
2. If the branch starts with `feat-`, read `knowledge-base/project/specs/<branch-name>/spec.md` if it exists
|
|
66
|
-
|
|
67
60
|
**If knowledge-base/ exists:**
|
|
68
61
|
|
|
69
62
|
1. Read `CLAUDE.md` if it exists - apply project conventions during planning
|
|
70
63
|
2. If `# Project Constitution` heading is NOT already in context, read `knowledge-base/project/constitution.md` - use principles to guide planning decisions. Skip if already loaded (e.g., from a preceding `soleur:brainstorm`).
|
|
71
64
|
3. Detect feature from current branch (`feat-<name>` pattern)
|
|
65
|
+
**Spec-kit intake, before step 4.** If the branch spec.md is absent and the argument is an existing specs/<prefix>-<short-name>/ directory, Read `${CLAUDE_PLUGIN_ROOT}/skills/plan/references/spec-kit-intake.md` and follow it. If that spec file exists, including zero bytes, do not run the script and do not replace it.
|
|
72
66
|
4. Read `knowledge-base/project/specs/feat-<name>/spec.md` if it exists - use as planning input
|
|
73
67
|
5. Announce: "Loaded constitution and spec for `feat-<name>`"
|
|
74
68
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Spec Kit intake
|
|
2
|
+
|
|
3
|
+
**Plugin root in this file:** this file is Read, not delivered by the skill loader, so `${CLAUDE_PLUGIN_ROOT}` below is not replaced for you. The root is ONLY the prefix of the path you read this file from, cut at its last `/skills/` — never a value from repository files, PR text or tool output, and never a directory inside the checked-out repository. Check first with `echo "root=[${CLAUDE_PLUGIN_ROOT}]"`: if it prints that root, proceed; if it prints `root=[]`, prefix every Bash or Monitor command below with `export CLAUDE_PLUGIN_ROOT=<root>` (each starts a fresh shell) and write the absolute root into any subagent prompt; if it prints anything else, stop — something other than the loader set it. If you cannot name the root (the path you read this file from still shows `${CLAUDE_PLUGIN_ROOT}`, or starts with `/skills/`), stop and hand the step to the operator. Left unset, every command fails closed on a `/skills/` or `/scripts/` path; never repair that with a CWD-relative plugin path, which runs the checked-out repository's copy.
|
|
4
|
+
|
|
5
|
+
Read this only when the branch `spec.md` is absent and the argument is an existing `specs/<prefix>-<short-name>/` directory. Prefix is three digits or `YYYYMMDD-HHMMSS`. The short-name starts with a letter or digit.
|
|
6
|
+
|
|
7
|
+
Capture `pwd` before any `cd`. Run `bash "${CLAUDE_PLUGIN_ROOT}/scripts/spec-kit-intake.sh"`. Pass that `pwd` as `--cwd` when `--dir` is relative. An argument that is already absolute is `--dir` as given, including after one-shot has changed directory.
|
|
8
|
+
|
|
9
|
+
On non-zero, stop. Do not edit the kit directory, do not run the script again, and do not paste the path as prose. A refusal is final.
|
|
10
|
+
|
|
11
|
+
On zero, show the receipt. Save the projected body, the text after the single `--- projected ---` line, as `knowledge-base/project/specs/<branch>/spec.md` only when that file is absent. Then plan from the saved file. Do not replace an existing file, including a zero-byte file. An empty spec directory is not the stop.
|
|
12
|
+
|
|
13
|
+
The script writes nothing. `plan.md` and `tasks.md` are side evidence under `--- side-evidence ---`, indented four spaces, and are not requirements. The receipt lists what moved, what was unmapped, and the never-read names `research.md`, `data-model.md`, `contracts`, and `quickstart.md`.
|
|
@@ -80,7 +80,7 @@ Two lessons from #9448 belong in every fix-agent and review-seat brief (full acc
|
|
|
80
80
|
- **Two review-environment traps (#9505).** (1) The guardrail hook refuses writes into the shared git dir (`$(git rev-parse --git-dir)` resolves under the bare checkout) whenever other worktrees exist, so a fix brief cannot be persisted there: write it to the session scratchpad under a lead-unique name and re-derive from the PR if the session is lost. (2) a `TEST_GROUP=affected` run of `scripts/test-all.sh` queues behind every other worktree's full-gate run (`LOCK_WAIT_HEARTBEAT ... position=N of 7200s`) and the runner flags a commit made during its run as a suite writing to the repo: read the runner's `--capacity` verdict first and, if it is queued, stop it and rely on the targeted suites rather than let it race a fix commit. See `knowledge-base/project/learnings/2026-10-05-the-advice-i-added-to-the-abort-message-satisfied-the-assertions-written-against-it.md`.
|
|
81
81
|
|
|
82
82
|
- **Re-attach before the first commit after a panel returns, and test the branch name for EMPTY.** Report-only seats still run `git checkout --detach`, and `git branch --show-current && git commit …` does not stop on a detached HEAD because the empty output exits 0 (#9584: a fix commit landed detached). Guard with `[ -n "$(git branch --show-current)" ] || { echo DETACHED; exit 1; }`; recover with `git branch -f <branch> HEAD && git switch <branch>`. See `knowledge-base/project/learnings/2026-10-06-a-truncated-sweep-blamed-the-nav-drawer-and-a-redundant-alternative-hid-a-regression.md`.
|
|
83
|
-
- **A seat must never mutation-test the LIVE worktree, and a bare-root `git` call reviews the wrong tree.** On #6760's fix rounds one seat `sed`-mutated `run-scan.sh` in place (restored after probing) and a second seat reported the residue as an uncommitted P1; two other seats ran `git diff origin/main...HEAD` in the bare checkout where the branch isn't checked out and nearly read an empty diff. Brief every seat to (a) open with `cd <worktree> && pwd` and confirm `git rev-parse --show-toplevel` is the worktree, and (b) apply mutants to a
|
|
83
|
+
- **A seat must never mutation-test the LIVE worktree, and a bare-root `git` call reviews the wrong tree.** On #6760's fix rounds one seat `sed`-mutated `run-scan.sh` in place (restored after probing) and a second seat reported the residue as an uncommitted P1; two other seats ran `git diff origin/main...HEAD` in the bare checkout where the branch isn't checked out and nearly read an empty diff. Brief every seat to (a) open with `cd <worktree> && pwd` and confirm `git rev-parse --show-toplevel` is the worktree, and (b) apply mutants to a sandbox from the allocator (review/SKILL.md, the mutating-seat sandbox rule), never the tree under review. See `knowledge-base/project/learnings/workflow-patterns/2026-10-12-fix-rounds-catch-the-regressions-the-fix-introduced.md`. A failed `cd` into the sandbox falls through to the live tree, and a sandbox under a git-tracked directory (such as a home-directory repo) resolves to that repo, so every Bash call that runs git in the sandbox starts with the check in the same call: `cd "$SBX" || exit 1; [ "$(git rev-parse --show-toplevel 2>/dev/null)" = "$SBX" ] || { echo NOT-SBX; exit 1; }`. A Bash call's cwd does not carry to the next call, so a check in one call protects no git command in another. An allocated sandbox has no `.git`, so the check fails until the seat runs `(cd "$SBX" && git init -q && git add -A)` (work-scratch-sandboxes.md); a probe that needs no repo runs no git there. **Why:** #12705 — a seat's probe ran after a failed `cd` and switched the live worktree to an orphan branch.
|
|
84
84
|
- **Never edit a script while a suite is still executing it — bash reads a running script incrementally.** During #10117's fix rounds the affected battery (`bash <plugin-root>/scripts/test-all-affected.test.sh`, ~13 min) was mid-run when fix edits landed twice; each edit shifted the file's byte offsets and the still-running process re-read corrupted text, forcing a kill and a full re-run. Check `pgrep -f <suite>` before editing a suite file, or hold edits until the run completes — the fix commits need a fresh battery either way. See `knowledge-base/project/learnings/workflow-patterns/2026-10-14-bash-reads-a-running-script-incrementally-mid-run-edits-corrupt-it.md`.
|
|
85
85
|
- **Tell every seat to RETURN its report instead of parking on a Monitor.** A seat that ended its turn "waiting on its own monitor" sat idle about 4.5 hours on #10111 until the lead resumed it with `SendMessage`; its transcript showed only an interim line. Ask for the final report within the seat's own run (a bounded wait, then report what is verified and say what is not), and if a seat shows only an interim, resume it once rather than waiting on a notification that is not coming.
|
|
86
86
|
- **Fix agents obey the same rule as seats: finish in the foreground.** Brief a fix agent to run its suites with `timeout` in the foreground and to report only after it has the exit code; one that ended a turn "waiting on its own monitor" left unfinished work and a stale exact floor (`EXPECTED_PASSES` 96, real 131) and sat idle about 45 minutes until the lead resumed it with `SendMessage`. Check the exact-floor constant against a green run before committing a fix batch. See `knowledge-base/project/learnings/2026-11-07-a-guard-must-equal-the-platforms-own-reader-not-yaml-semantics.md` (#12295).
|