@zalom/plastic 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PLASTIC.md +12 -9
- package/README.md +3 -3
- package/agents/plastic-enforcer.md +8 -4
- package/agents/plastic-executor.md +5 -5
- package/agents/plastic-future-intent-researcher.md +1 -1
- package/agents/plastic-planner.md +15 -11
- package/hooks/check-update +1 -1
- package/hooks/continue +1 -1
- package/package.json +1 -1
- package/scripts/dashboard.rb +29 -24
- package/scripts/doctor.rb +180 -5
- package/scripts/hook-continue +3 -3
- package/scripts/install.rb +2 -1
- package/scripts/lib/bridge.rb +114 -11
- package/scripts/lib/dashboard_banner.rb +8 -9
- package/scripts/lib/installer_core.rb +12 -3
- package/scripts/lib/legacy_bookend_amnesty.rb +35 -0
- package/scripts/lib/release_guard.rb +62 -0
- package/scripts/lib/roadmap_queue.rb +285 -0
- package/scripts/lib/roadmap_savepoint.rb +213 -0
- package/scripts/lib/skill_lint.rb +304 -0
- package/scripts/lib/worktree.rb +21 -0
- package/scripts/new-intent +1 -0
- package/scripts/read-config +3 -3
- package/scripts/roadmap-next +44 -0
- package/scripts/roadmap-savepoint +64 -0
- package/scripts/skill-lint +50 -0
- package/skills/auto/SKILL.md +32 -11
- package/skills/auto/references/tiers.md +4 -3
- package/skills/continuing/SKILL.md +34 -0
- package/skills/continuing/evals/evals.json +91 -0
- package/skills/dashboard/SKILL.md +17 -14
- package/skills/dashboard/references/classification.md +3 -3
- package/skills/dashboard/templates/dashboard-global.md +8 -23
- package/skills/dashboard/templates/dashboard-project.md +7 -26
- package/skills/doctor/SKILL.md +1 -1
- package/skills/install/SKILL.md +10 -10
- package/skills/intent-continuing/SKILL.md +26 -68
- package/skills/intent-continuing/evals/evals.json +26 -26
- package/skills/intent-continuing/references/context-management.md +15 -19
- package/skills/intent-planning/SKILL.md +11 -11
- package/skills/intent-planning/evals/evals.json +20 -5
- package/skills/intent-planning/references/plan-format.md +9 -5
- package/skills/intent-savepoint/SKILL.md +12 -0
- package/skills/intent-starting/evals/evals.json +1 -1
- package/skills/project-continuing/SKILL.md +104 -0
- package/skills/project-continuing/evals/evals.json +100 -0
- package/skills/project-continuing/references/board-fill.md +33 -0
- package/skills/releasing/SKILL.md +48 -0
- package/skills/releasing/references/release-lines.md +105 -0
- package/skills/roadmap/SKILL.md +7 -1
- package/skills/roadmap/references/file-format.md +30 -1
- package/skills/roadmap/references/operations.md +26 -6
- package/skills/roadmap-continuing/SKILL.md +85 -0
- package/skills/roadmap-continuing/evals/evals.json +82 -0
- package/skills/roadmap-continuing/references/liveness-ranking.md +56 -0
- package/skills/skill-evaluating/evals/evals.json +1 -1
- package/skills/tutorial/references/track-1-guided.md +5 -4
- package/skills/tutorial/references/track-2-auto.md +1 -1
- package/skills/uninstall/SKILL.md +2 -2
- package/skills/update/SKILL.md +2 -2
- package/templates/config.yml +2 -1
- package/templates/index.md +4 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "time"
|
|
5
|
+
require "fileutils"
|
|
6
|
+
|
|
7
|
+
# RoadmapSavepoint - the roadmap's machine counterpart to its human `## Log` (intent 134).
|
|
8
|
+
#
|
|
9
|
+
# Mirrors scripts/lib/qmd_sync.rb's class shape and the cycle-step savepoint ledger in
|
|
10
|
+
# scripts/lib/bridge.rb (append semantics: idempotent `(event, detail)` pair dedup, one
|
|
11
|
+
# deterministic append primitive). Constructor-DI, hermetic: no eval, no ENV or global config
|
|
12
|
+
# seam, clock injected through `now:`. Two operations:
|
|
13
|
+
#
|
|
14
|
+
# append(roadmap_path, event, detail, now:) - one deterministic, idempotent append
|
|
15
|
+
# rebuild(roadmap_path) - reconstruct the ledger from the roadmap's
|
|
16
|
+
# `## Log` (and, for delivered wave entries with
|
|
17
|
+
# no matching Log line, from INDEX `## Completed`)
|
|
18
|
+
#
|
|
19
|
+
# The ledger is sugar on top of the roadmap file: derived, rebuildable, never a status source.
|
|
20
|
+
# INDEX.md stays the single status writer.
|
|
21
|
+
module RoadmapSavepoint
|
|
22
|
+
module_function
|
|
23
|
+
|
|
24
|
+
EVENTS = %w[created dispatched parked merged release handoff closed added reordered wave].freeze
|
|
25
|
+
|
|
26
|
+
# Keyword -> event classification for `rebuild`, checked top to bottom, first match wins.
|
|
27
|
+
# Kept small and deterministic (action 1). Order matters: more specific/rarer words are
|
|
28
|
+
# checked before the broader "wave" fallback so an incidental "wave" mention in an otherwise
|
|
29
|
+
# classifiable line never shadows its real event.
|
|
30
|
+
KEYWORD_TABLE = [
|
|
31
|
+
[/\bclosed\b/i, "closed"],
|
|
32
|
+
[/\bhanded off\b|\bhandoff\b/i, "handoff"],
|
|
33
|
+
[/\breleased?\b|\bcut\b|\btagged\b/i, "release"],
|
|
34
|
+
[/\bparked\b|\bblocked\b|\bholds?\b/i, "parked"],
|
|
35
|
+
[/\bdelivered\b|\bmerged\b|\bshipped\b/i, "merged"],
|
|
36
|
+
[/\bdelivering\b|\bdispatch(?:ed)?\b/i, "dispatched"],
|
|
37
|
+
[/\breordered\b/i, "reordered"],
|
|
38
|
+
[/\badded\b|\badds\b/i, "added"],
|
|
39
|
+
[/\bcreated\b/i, "created"],
|
|
40
|
+
[/\bwave\b/i, "wave"],
|
|
41
|
+
].freeze
|
|
42
|
+
|
|
43
|
+
# --- append -----------------------------------------------------------------
|
|
44
|
+
|
|
45
|
+
# The name-paired sibling ledger for a roadmap path: roadmaps/<slug>.md becomes
|
|
46
|
+
# roadmaps/<slug>.savepoint.md. Resolves correctly for a live roadmap and for one already
|
|
47
|
+
# moved under roadmaps/archived/, because both are plain path substitutions.
|
|
48
|
+
def ledger_path_for(roadmap_path)
|
|
49
|
+
roadmap_path.sub(/\.md\z/, ".savepoint.md")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# `(event, detail)` pairs already recorded in a ledger file, the dedup key (D2): two
|
|
53
|
+
# `dispatched` events with different details are distinct, so the event word alone would be
|
|
54
|
+
# too coarse a key.
|
|
55
|
+
def recorded_pairs(ledger_path)
|
|
56
|
+
return [] unless File.exist?(ledger_path)
|
|
57
|
+
File.read(ledger_path).each_line.filter_map { |line| parse_pair(line) }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def parse_pair(line)
|
|
61
|
+
parts = line.strip.split(/\s{2,}/)
|
|
62
|
+
parts.length >= 3 ? [parts[1], parts[2]] : nil
|
|
63
|
+
end
|
|
64
|
+
private_class_method :parse_pair
|
|
65
|
+
|
|
66
|
+
# Append one ledger line "<iso8601> <event> <detail>" unless `(event, detail)` is already
|
|
67
|
+
# recorded (no-op). Creates the paired ledger file (and its directory) lazily. Raises
|
|
68
|
+
# ArgumentError when `event` is outside the controlled vocabulary. Returns true when a line
|
|
69
|
+
# was written, false on a dedup no-op.
|
|
70
|
+
def append(roadmap_path, event, detail, now: Time.now)
|
|
71
|
+
unless EVENTS.include?(event)
|
|
72
|
+
raise ArgumentError, "event must be one of #{EVENTS.join(', ')}, got #{event.inspect}"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
ledger_path = ledger_path_for(roadmap_path)
|
|
76
|
+
return false if recorded_pairs(ledger_path).include?([event, detail])
|
|
77
|
+
|
|
78
|
+
FileUtils.mkdir_p(File.dirname(ledger_path))
|
|
79
|
+
File.open(ledger_path, "a") { |io| io.write(format_line(now, event, detail)) }
|
|
80
|
+
true
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def format_line(time, event, detail)
|
|
84
|
+
"#{time.utc.iso8601} #{event} #{detail.to_s.strip}\n"
|
|
85
|
+
end
|
|
86
|
+
private_class_method :format_line
|
|
87
|
+
|
|
88
|
+
# --- rebuild ------------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
# Reconstruct the paired ledger deterministically from the roadmap file's `## Log` (never the
|
|
91
|
+
# roadmap `.md`, which is read-only here), cross-checked against `## Waves` and the tier's
|
|
92
|
+
# INDEX so every `delivered` wave entry has a `merged` line. Every timestamp comes from an
|
|
93
|
+
# on-disk source (the Log, or INDEX `## Completed`); an entry with no recoverable timestamp is
|
|
94
|
+
# not emitted (D4, never invented). Overwrites the ledger (the one operation allowed to rewrite
|
|
95
|
+
# it, matching `Bridge.rebuild_savepoint`). Returns the number of lines written.
|
|
96
|
+
def rebuild(roadmap_path)
|
|
97
|
+
text = File.read(roadmap_path)
|
|
98
|
+
log_lines = classify_log(section_body(text, "Log"))
|
|
99
|
+
delivered_ids = delivered_wave_ids(section_body(text, "Waves"))
|
|
100
|
+
backfilled = backfill_merged_lines(log_lines, delivered_ids, roadmap_path)
|
|
101
|
+
|
|
102
|
+
lines = dedup_pairs(log_lines + backfilled)
|
|
103
|
+
File.write(ledger_path_for(roadmap_path), lines.map { |t, e, d| format_line(t, e, d) }.join)
|
|
104
|
+
lines.length
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Every `- YYYY-MM-DD HH:MM UTC ...` line in the `## Log` body, classified into
|
|
108
|
+
# [time, event, detail]. A line with no keyword match is dropped (no event to record); a
|
|
109
|
+
# continuation line (no date prefix) never matches the header pattern, so it is inherently
|
|
110
|
+
# ignored for classification, per action 1.
|
|
111
|
+
def classify_log(log_body)
|
|
112
|
+
log_body.each_line.filter_map { |line| classify_log_line(line) }
|
|
113
|
+
end
|
|
114
|
+
private_class_method :classify_log
|
|
115
|
+
|
|
116
|
+
LOG_LINE = /\A-\s+(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2})\s+UTC\s+(.*)\z/.freeze
|
|
117
|
+
|
|
118
|
+
def classify_log_line(line)
|
|
119
|
+
m = line.strip.match(LOG_LINE)
|
|
120
|
+
return nil unless m
|
|
121
|
+
event = classify_event(m[3])
|
|
122
|
+
return nil unless event
|
|
123
|
+
[parse_log_time(m[1], m[2]), event, m[3].strip]
|
|
124
|
+
end
|
|
125
|
+
private_class_method :classify_log_line
|
|
126
|
+
|
|
127
|
+
def parse_log_time(date, hhmm)
|
|
128
|
+
y, mo, d = date.split("-").map(&:to_i)
|
|
129
|
+
h, mi = hhmm.split(":").map(&:to_i)
|
|
130
|
+
Time.utc(y, mo, d, h, mi, 0)
|
|
131
|
+
end
|
|
132
|
+
private_class_method :parse_log_time
|
|
133
|
+
|
|
134
|
+
def classify_event(text)
|
|
135
|
+
hit = KEYWORD_TABLE.find { |regex, _event| text =~ regex }
|
|
136
|
+
hit && hit[1]
|
|
137
|
+
end
|
|
138
|
+
private_class_method :classify_event
|
|
139
|
+
|
|
140
|
+
WAVE_ENTRY = /\A-\s*\[([ xX])\]\s+(\S+)\s+.+—\s*(\S+)\s*\z/.freeze
|
|
141
|
+
|
|
142
|
+
# Intent ids of every `[x] ... — delivered` entry in the `## Waves` body.
|
|
143
|
+
def delivered_wave_ids(waves_body)
|
|
144
|
+
waves_body.each_line.filter_map do |line|
|
|
145
|
+
m = line.strip.match(WAVE_ENTRY)
|
|
146
|
+
next nil unless m
|
|
147
|
+
checked = m[1].strip.downcase == "x"
|
|
148
|
+
status = m[3].strip.downcase
|
|
149
|
+
m[2] if checked && status == "delivered"
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
private_class_method :delivered_wave_ids
|
|
153
|
+
|
|
154
|
+
# For every delivered wave id with no `merged` line already among `log_lines` (the "matching
|
|
155
|
+
# Log line" source, D4), fall back to the tier's INDEX `## Completed` section (the second
|
|
156
|
+
# on-disk source D4 allows). No source at all -> the id is silently skipped, never invented.
|
|
157
|
+
# Backfilled lines are appended after the Log-derived pass (a reconciliation pass run after
|
|
158
|
+
# reconstruction), each carrying its own real on-disk-sourced timestamp even when that
|
|
159
|
+
# timestamp sorts earlier than same-day Log lines above it (INDEX only carries a date, so the
|
|
160
|
+
# time floors to midnight UTC rather than inventing a time-of-day).
|
|
161
|
+
def backfill_merged_lines(log_lines, delivered_ids, roadmap_path)
|
|
162
|
+
index_path = index_path_for(roadmap_path)
|
|
163
|
+
delivered_ids.filter_map do |id|
|
|
164
|
+
next nil if log_lines.any? { |_t, event, detail| event == "merged" && detail =~ /\b#{Regexp.escape(id)}\b/ }
|
|
165
|
+
date = index_completed_date(index_path, id)
|
|
166
|
+
next nil unless date
|
|
167
|
+
[Time.utc(*date.split("-").map(&:to_i)), "merged", "#{id} (from INDEX Completed)"]
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
private_class_method :backfill_merged_lines
|
|
171
|
+
|
|
172
|
+
# The tier root is the parent of `roadmaps/` (a live roadmap's grandparent, or, for one
|
|
173
|
+
# already moved to `roadmaps/archived/`, its great-grandparent); INDEX.md is that root's
|
|
174
|
+
# sibling file, matching the layout `plastic-roadmap`'s file-format doc defines.
|
|
175
|
+
def index_path_for(roadmap_path)
|
|
176
|
+
dir = File.dirname(roadmap_path)
|
|
177
|
+
dir = File.dirname(dir) if File.basename(dir) == "archived"
|
|
178
|
+
File.join(File.dirname(dir), "INDEX.md")
|
|
179
|
+
end
|
|
180
|
+
private_class_method :index_path_for
|
|
181
|
+
|
|
182
|
+
def index_completed_date(index_path, id)
|
|
183
|
+
return nil unless index_path && File.exist?(index_path)
|
|
184
|
+
section_body(File.read(index_path), "Completed").each_line do |line|
|
|
185
|
+
next unless line.strip.start_with?("- [#{id} ")
|
|
186
|
+
m = line.match(/\)\s*—\s*(\d{4}-\d{2}-\d{2})\b/)
|
|
187
|
+
return m[1] if m
|
|
188
|
+
end
|
|
189
|
+
nil
|
|
190
|
+
end
|
|
191
|
+
private_class_method :index_completed_date
|
|
192
|
+
|
|
193
|
+
# The body text of a `## <heading>` section: everything after the heading line up to (but not
|
|
194
|
+
# including) the next `## ` heading or end of file.
|
|
195
|
+
def section_body(text, heading)
|
|
196
|
+
m = text.match(/^##\s+#{Regexp.escape(heading)}\s*$(.*?)(?=^##\s|\z)/m)
|
|
197
|
+
m ? m[1] : ""
|
|
198
|
+
end
|
|
199
|
+
private_class_method :section_body
|
|
200
|
+
|
|
201
|
+
# Stable dedup on the `(event, detail)` pair, keeping the first occurrence in the given
|
|
202
|
+
# (already chronological-then-backfill-appended) order.
|
|
203
|
+
def dedup_pairs(lines)
|
|
204
|
+
seen = []
|
|
205
|
+
lines.select do |_t, event, detail|
|
|
206
|
+
pair = [event, detail]
|
|
207
|
+
next false if seen.include?(pair)
|
|
208
|
+
seen << pair
|
|
209
|
+
true
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
private_class_method :dedup_pairs
|
|
213
|
+
end
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "yaml"
|
|
5
|
+
|
|
6
|
+
# SkillLint: deterministic, dependency-injected engine that runs five
|
|
7
|
+
# structural checks over a directory of Agent Skills (intent 85b).
|
|
8
|
+
#
|
|
9
|
+
# Pure and DI: constructed with an injected `skills_dir`, performs no writes,
|
|
10
|
+
# no `eval`, and reads no ambient config beyond the injected directory. Mirrors
|
|
11
|
+
# the CLI-over-lib shape of `scripts/lib/intent_validator.rb`: the `skill-lint`
|
|
12
|
+
# CLI (ACTION_2) is a thin wrapper, `scripts/doctor.rb` (ACTION_4) consumes the
|
|
13
|
+
# same engine for an advisory finding, and `test/skill_lint_test.rb` (ACTION_3)
|
|
14
|
+
# proves every check red-and-green plus a no-skip-list live-tree guard.
|
|
15
|
+
#
|
|
16
|
+
# Each violation is a Hash:
|
|
17
|
+
# { check:, skill:, file:, line:, rule:, message: }
|
|
18
|
+
# `check` is one of the five check-ids below, `skill` is the skill directory
|
|
19
|
+
# basename, `file` is the offending path, `line` is an Integer where locatable
|
|
20
|
+
# else nil, `rule` cites the standard being enforced, `message` is an
|
|
21
|
+
# actionable fix instruction.
|
|
22
|
+
class SkillLint
|
|
23
|
+
# A binding keyword: a mention's paragraph carries an observable trigger
|
|
24
|
+
# condition when it names one of these (word-boundary, case-insensitive).
|
|
25
|
+
BINDING_KEYWORD_RE = /\b(when|if|before|after|while)\b/i
|
|
26
|
+
|
|
27
|
+
# A `to <verb>` or `for <noun-phrase>` purpose clause.
|
|
28
|
+
PURPOSE_RE = /\b(to|for)\s+\S/i
|
|
29
|
+
|
|
30
|
+
Result = Struct.new(:violations) do
|
|
31
|
+
def ok?
|
|
32
|
+
violations.empty?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Slice violations down to one check-id, e.g. for a doctor finding or a
|
|
36
|
+
# red-proof assertion.
|
|
37
|
+
def violations_for(check_id)
|
|
38
|
+
violations.select { |v| v[:check] == check_id }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def initialize(skills_dir:)
|
|
43
|
+
@skills_dir = skills_dir
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def run
|
|
47
|
+
violations = []
|
|
48
|
+
|
|
49
|
+
skill_md_paths.each do |skill_md|
|
|
50
|
+
skill_dir = File.dirname(skill_md)
|
|
51
|
+
content = File.read(skill_md)
|
|
52
|
+
|
|
53
|
+
violations.concat(check_body_budget(skill_dir, skill_md, content))
|
|
54
|
+
violations.concat(check_frontmatter_validity(skill_dir, skill_md, content))
|
|
55
|
+
violations.concat(check_bare_pointer(skill_dir, skill_md, content))
|
|
56
|
+
violations.concat(check_orphan_files(skill_dir))
|
|
57
|
+
violations.concat(check_references_depth(skill_dir))
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
Result.new(violations)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
def skill_md_paths
|
|
66
|
+
Dir.glob(File.join(@skills_dir, "*", "SKILL.md")).sort
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def skill_name(skill_dir)
|
|
70
|
+
File.basename(skill_dir)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def violation(check:, skill:, file:, line:, rule:, message:)
|
|
74
|
+
{ check: check, skill: skill, file: file, line: line, rule: rule, message: message }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Frontmatter split uses the shared convention (scripts/lib/intent_validator.rb):
|
|
78
|
+
# `content.split("---", 3)`; parts[1] is the frontmatter text, parts[2] is the
|
|
79
|
+
# body. Also computes the body's starting line number (0-based line count of
|
|
80
|
+
# everything before the body) so callers can report absolute file line
|
|
81
|
+
# numbers, not just body-relative ones.
|
|
82
|
+
def frontmatter_and_body(content)
|
|
83
|
+
parts = content.split("---", 3)
|
|
84
|
+
return { frontmatter: nil, body: content, body_offset_lines: 0 } if parts.length < 3
|
|
85
|
+
|
|
86
|
+
prefix_len = parts[0].length + 3 + parts[1].length + 3
|
|
87
|
+
prefix = content[0...prefix_len]
|
|
88
|
+
{ frontmatter: parts[1], body: parts[2], body_offset_lines: prefix.count("\n") }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# --- 1. body-budget ---
|
|
92
|
+
|
|
93
|
+
def check_body_budget(skill_dir, skill_md, content)
|
|
94
|
+
violations = []
|
|
95
|
+
body = frontmatter_and_body(content)[:body]
|
|
96
|
+
name = skill_name(skill_dir)
|
|
97
|
+
|
|
98
|
+
line_count = body.lines.count
|
|
99
|
+
if line_count >= 500
|
|
100
|
+
violations << violation(
|
|
101
|
+
check: "body-budget", skill: name, file: skill_md, line: nil,
|
|
102
|
+
rule: "body under 500 lines",
|
|
103
|
+
message: "SKILL.md body is #{line_count} lines; move detail into references/*.md to get under 500"
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
tokens = (body.split(/\s+/).reject(&:empty?).length * 1.3).round
|
|
108
|
+
if tokens >= 5000
|
|
109
|
+
violations << violation(
|
|
110
|
+
check: "body-budget", skill: name, file: skill_md, line: nil,
|
|
111
|
+
rule: "body under about 5000 tokens (word-based estimate)",
|
|
112
|
+
message: "SKILL.md body is about #{tokens} tokens (word-based estimate); move detail into references/*.md to get under 5000"
|
|
113
|
+
)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
violations
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# --- 2. frontmatter-validity ---
|
|
120
|
+
|
|
121
|
+
def check_frontmatter_validity(skill_dir, skill_md, content)
|
|
122
|
+
violations = []
|
|
123
|
+
name = skill_name(skill_dir)
|
|
124
|
+
frontmatter_text = frontmatter_and_body(content)[:frontmatter]
|
|
125
|
+
|
|
126
|
+
begin
|
|
127
|
+
fm = YAML.safe_load(frontmatter_text.to_s)
|
|
128
|
+
rescue Psych::SyntaxError
|
|
129
|
+
violations << violation(
|
|
130
|
+
check: "frontmatter-validity", skill: name, file: skill_md, line: nil,
|
|
131
|
+
rule: "frontmatter must survive strict YAML.safe_load",
|
|
132
|
+
message: "SKILL.md frontmatter fails YAML.safe_load; quote scalar values that contain an unquoted \": \" sequence"
|
|
133
|
+
)
|
|
134
|
+
return violations
|
|
135
|
+
end
|
|
136
|
+
fm = {} unless fm.is_a?(Hash)
|
|
137
|
+
|
|
138
|
+
expected_name = "plastic-#{name}"
|
|
139
|
+
if fm["name"] != expected_name
|
|
140
|
+
violations << violation(
|
|
141
|
+
check: "frontmatter-validity", skill: name, file: skill_md, line: nil,
|
|
142
|
+
rule: "name: must equal plastic-<directory>",
|
|
143
|
+
message: "frontmatter name: is #{fm["name"].inspect}; expected #{expected_name.inspect}"
|
|
144
|
+
)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
user_invocable = fm["user-invocable"]
|
|
148
|
+
unless user_invocable == true || user_invocable == false
|
|
149
|
+
violations << violation(
|
|
150
|
+
check: "frontmatter-validity", skill: name, file: skill_md, line: nil,
|
|
151
|
+
rule: "user-invocable: must be present and boolean",
|
|
152
|
+
message: "frontmatter user-invocable: is #{user_invocable.inspect}; must be present and true or false"
|
|
153
|
+
)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
violations
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# --- 3. bare-pointer ---
|
|
160
|
+
|
|
161
|
+
def check_bare_pointer(skill_dir, skill_md, content)
|
|
162
|
+
violations = []
|
|
163
|
+
ref_files = Dir.glob(File.join(skill_dir, "references", "*.md")).sort
|
|
164
|
+
return violations if ref_files.empty?
|
|
165
|
+
|
|
166
|
+
parsed = frontmatter_and_body(content)
|
|
167
|
+
body_lines = parsed[:body].lines
|
|
168
|
+
offset = parsed[:body_offset_lines]
|
|
169
|
+
blocks = paragraph_blocks(body_lines)
|
|
170
|
+
name = skill_name(skill_dir)
|
|
171
|
+
|
|
172
|
+
ref_files.each do |ref_file|
|
|
173
|
+
base = File.basename(ref_file)
|
|
174
|
+
mention_indices = (0...body_lines.length).select { |i| body_lines[i].include?(base) }
|
|
175
|
+
next if mention_indices.empty? # zero mentions is an orphan (check 4), not a bare pointer
|
|
176
|
+
|
|
177
|
+
bound = mention_indices.any? { |i| bound_mention?(body_lines[i], i, blocks, base) }
|
|
178
|
+
next if bound
|
|
179
|
+
|
|
180
|
+
first = mention_indices.first
|
|
181
|
+
violations << violation(
|
|
182
|
+
check: "bare-pointer", skill: name, file: skill_md, line: offset + first + 1,
|
|
183
|
+
rule: "every reference link must bind to an observable trigger condition, never a bare pointer",
|
|
184
|
+
message: "#{base} is only ever a bare pointer; add a when/if/before/after/while clause or a " \
|
|
185
|
+
"to/for purpose so the trigger is observable"
|
|
186
|
+
)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
violations
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def bound_mention?(line, index, blocks, base)
|
|
193
|
+
stripped = line.strip
|
|
194
|
+
return table_row_bound?(stripped, base) if stripped.start_with?("|")
|
|
195
|
+
|
|
196
|
+
block = blocks.find { |b| index.between?(b[:start], b[:end]) }
|
|
197
|
+
block_text = block ? block[:text] : line
|
|
198
|
+
|
|
199
|
+
# Narrow to the unit(s) that actually mention the reference, so an
|
|
200
|
+
# unrelated unit elsewhere in the same paragraph cannot launder a
|
|
201
|
+
# genuinely bare pointer through an incidental "to"/"for" (an ordinary
|
|
202
|
+
# preposition, not a binding purpose clause). Split on BOTH sentence
|
|
203
|
+
# boundaries (.!?) AND list-item starts, so a bullet list (which has no
|
|
204
|
+
# terminal punctuation between items) does not collapse into one unit
|
|
205
|
+
# whose bound siblings launder a bare bullet -- the trailing "References"
|
|
206
|
+
# list pattern (most bullets bound, one forgotten) this linter exists to
|
|
207
|
+
# catch. Keep only units that mention `base`. Falls back to the whole
|
|
208
|
+
# block when no unit boundary contains the mention (e.g. a mid-sentence
|
|
209
|
+
# line wrap with no terminal punctuation nearby), so the legitimate
|
|
210
|
+
# multi-line-wrapped case still binds.
|
|
211
|
+
#
|
|
212
|
+
# Known conservative limitation (documented, not closed): a bare mention
|
|
213
|
+
# with NO unit boundary of its own (no leading list marker, no preceding
|
|
214
|
+
# terminal punctuation) immediately followed by an unrelated sentence
|
|
215
|
+
# carrying "to"/"for" can still borrow that neighbor's binding via the
|
|
216
|
+
# empty-fallback path. Closing this structurally risks re-breaking the
|
|
217
|
+
# legitimate wrapped-sentence case (which also relies on the fallback),
|
|
218
|
+
# so it stays open; see intent 85b insights.
|
|
219
|
+
units = block_text.split(/(?<=[.!?])\s+|\n(?=\s*(?:[-*+]|\d+[.)])\s)/)
|
|
220
|
+
mentioning = units.select { |s| s.include?(base) }
|
|
221
|
+
scoped_text = mentioning.empty? ? block_text : mentioning.join(" ")
|
|
222
|
+
|
|
223
|
+
scoped_text.match?(BINDING_KEYWORD_RE) || scoped_text.match?(PURPOSE_RE)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# A table row is bound when some OTHER cell (not the one carrying the
|
|
227
|
+
# reference path) has visible text (the trigger-condition column).
|
|
228
|
+
def table_row_bound?(stripped_line, base)
|
|
229
|
+
cells = stripped_line.split("|").map(&:strip).reject(&:empty?)
|
|
230
|
+
other_cells = cells.reject { |c| c.include?(base) }
|
|
231
|
+
!other_cells.empty?
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# Group body lines into blank-line-delimited paragraph blocks so a mention
|
|
235
|
+
# that trails a wrapped sentence (the binding keyword on the line above) is
|
|
236
|
+
# still evaluated against its full paragraph, not just its own physical line.
|
|
237
|
+
def paragraph_blocks(lines)
|
|
238
|
+
blocks = []
|
|
239
|
+
start = nil
|
|
240
|
+
lines.each_with_index do |line, i|
|
|
241
|
+
if line.strip.empty?
|
|
242
|
+
blocks << { start: start, end: i - 1, text: lines[start..(i - 1)].join } if start
|
|
243
|
+
start = nil
|
|
244
|
+
else
|
|
245
|
+
start ||= i
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
blocks << { start: start, end: lines.length - 1, text: lines[start..-1].join } if start
|
|
249
|
+
blocks
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
# --- 4. orphan-files ---
|
|
253
|
+
|
|
254
|
+
def check_orphan_files(skill_dir)
|
|
255
|
+
violations = []
|
|
256
|
+
ref_files = Dir.glob(File.join(skill_dir, "references", "*.md")).sort
|
|
257
|
+
return violations if ref_files.empty?
|
|
258
|
+
|
|
259
|
+
other_files = Dir.glob(File.join(skill_dir, "**", "*")).select { |p| File.file?(p) }
|
|
260
|
+
name = skill_name(skill_dir)
|
|
261
|
+
|
|
262
|
+
ref_files.each do |ref_file|
|
|
263
|
+
base = File.basename(ref_file)
|
|
264
|
+
mentioned = other_files.any? do |other|
|
|
265
|
+
next false if other == ref_file
|
|
266
|
+
|
|
267
|
+
File.read(other).include?(base)
|
|
268
|
+
end
|
|
269
|
+
next if mentioned
|
|
270
|
+
|
|
271
|
+
violations << violation(
|
|
272
|
+
check: "orphan-files", skill: name, file: ref_file, line: nil,
|
|
273
|
+
rule: "every references/ file must be routed from the skill",
|
|
274
|
+
message: "#{base} is never mentioned anywhere in the skill directory; route it from SKILL.md or delete it"
|
|
275
|
+
)
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
violations
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# --- 5. references-depth ---
|
|
282
|
+
|
|
283
|
+
def check_references_depth(skill_dir)
|
|
284
|
+
violations = []
|
|
285
|
+
refs_root = File.join(skill_dir, "references")
|
|
286
|
+
return violations unless File.directory?(refs_root)
|
|
287
|
+
|
|
288
|
+
name = skill_name(skill_dir)
|
|
289
|
+
Dir.glob(File.join(refs_root, "**", "*")).each do |path|
|
|
290
|
+
next unless File.file?(path)
|
|
291
|
+
|
|
292
|
+
rel = path.sub("#{refs_root}/", "")
|
|
293
|
+
next unless rel.include?("/")
|
|
294
|
+
|
|
295
|
+
violations << violation(
|
|
296
|
+
check: "references-depth", skill: name, file: path, line: nil,
|
|
297
|
+
rule: "references stay one level deep",
|
|
298
|
+
message: "#{rel} is nested under references/; move it to a flat references/*.md file"
|
|
299
|
+
)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
violations
|
|
303
|
+
end
|
|
304
|
+
end
|
package/scripts/lib/worktree.rb
CHANGED
|
@@ -79,6 +79,21 @@ module Worktree
|
|
|
79
79
|
}
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
+
# Derive the OS-HOME level (the PARENT of `.plastic`) from an intent store
|
|
83
|
+
# path, anchored on the `.plastic` path segment (Defect 1, intent 169): a
|
|
84
|
+
# store is always `<plastic_home>/store` or
|
|
85
|
+
# `<plastic_home>/projects/<slug>/store`, and `<plastic_home>` is always the
|
|
86
|
+
# `.plastic` dir. Returns nil when `store` is blank or carries no `.plastic`
|
|
87
|
+
# segment, so callers fall back to their own `home:` default rather than
|
|
88
|
+
# resolving anything. Pure: no `ENV[...]` read, no I/O.
|
|
89
|
+
def home_from_store(store)
|
|
90
|
+
return nil if blank?(store)
|
|
91
|
+
parts = File.expand_path(store.to_s).split(File::SEPARATOR)
|
|
92
|
+
idx = parts.rindex(".plastic")
|
|
93
|
+
return nil unless idx
|
|
94
|
+
parts[0...idx].join(File::SEPARATOR)
|
|
95
|
+
end
|
|
96
|
+
|
|
82
97
|
# Absolute repo path for a project slug from `~/.plastic/projects.yml`, or nil.
|
|
83
98
|
# Reuses the qmd_sync safe-loader pattern: any failure yields nil.
|
|
84
99
|
def repo_for(slug, home: Dir.home)
|
|
@@ -106,6 +121,12 @@ module Worktree
|
|
|
106
121
|
store = intent["store"].to_s
|
|
107
122
|
intent_slug = slug_from_dir(intent["dir"]) || slug_from_dir(store)
|
|
108
123
|
|
|
124
|
+
# Defect 1 fix (intent 169): derive plastic_home from the already-sandboxed
|
|
125
|
+
# store path when possible, so a sandboxed board never falls to the real
|
|
126
|
+
# `Dir.home` default. `home:` remains the fallback only when the store is
|
|
127
|
+
# blank or carries no recognizable `.plastic` segment.
|
|
128
|
+
home = home_from_store(store) || home
|
|
129
|
+
|
|
109
130
|
slug = slug_for_store(store, home: home)
|
|
110
131
|
p = paths(slug: slug, intent_id: intent_id, intent_slug: intent_slug, home: home)
|
|
111
132
|
|
package/scripts/new-intent
CHANGED
|
@@ -282,6 +282,7 @@ def main(argv)
|
|
|
282
282
|
|
|
283
283
|
# 2. Create dirs.
|
|
284
284
|
FileUtils.mkdir_p(File.join(intent_dir, "actions"))
|
|
285
|
+
File.write(File.join(intent_dir, "actions", ".gitkeep"), "")
|
|
285
286
|
FileUtils.mkdir_p(File.join(intent_dir, "resources"))
|
|
286
287
|
|
|
287
288
|
# 3. Render the born-complete intent file from templates/intent.md.
|
package/scripts/read-config
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# Returns scalar values as strings, hash/array values as JSON.
|
|
6
6
|
#
|
|
7
7
|
# Environment:
|
|
8
|
-
#
|
|
8
|
+
# PLASTIC_HOME -- override ~/.plastic (for testing)
|
|
9
9
|
|
|
10
10
|
require "yaml"
|
|
11
11
|
require "json"
|
|
@@ -88,7 +88,7 @@ end
|
|
|
88
88
|
|
|
89
89
|
# Handle --migrate mode
|
|
90
90
|
if ARGV.include?("--migrate")
|
|
91
|
-
global_root = ENV.fetch("
|
|
91
|
+
global_root = ENV.fetch("PLASTIC_HOME", File.expand_path("~/.plastic"))
|
|
92
92
|
config_path = File.join(global_root, "config.yml")
|
|
93
93
|
config = load_yaml(config_path)
|
|
94
94
|
|
|
@@ -116,7 +116,7 @@ if key.nil? || key.empty?
|
|
|
116
116
|
exit 1
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
-
global_root = ENV.fetch("
|
|
119
|
+
global_root = ENV.fetch("PLASTIC_HOME", File.expand_path("~/.plastic"))
|
|
120
120
|
global_config = load_yaml(File.join(global_root, "config.yml"))
|
|
121
121
|
|
|
122
122
|
project_config = {}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# encoding: UTF-8
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
|
|
5
|
+
# roadmap-next - thin CLI over RoadmapQueue (intent 148).
|
|
6
|
+
#
|
|
7
|
+
# The auto loop and plastic-roadmap-continuing both call this instead of ranking roadmap
|
|
8
|
+
# liveness in prose. Queue mode (default) is for the auto loop: it breaks a tie
|
|
9
|
+
# deterministically and reports the winner's frontier state. Which mode (--which) is for
|
|
10
|
+
# plastic-roadmap-continuing: it returns tie_candidates so the skill's single ask can resolve
|
|
11
|
+
# a genuine tie.
|
|
12
|
+
#
|
|
13
|
+
# Usage:
|
|
14
|
+
# roadmap-next --roadmaps-dir <dir> [--index <path>] [--which]
|
|
15
|
+
#
|
|
16
|
+
# Exits 0 on any successful analysis, including state "none" and "exhausted" (valid answers,
|
|
17
|
+
# not errors). Exits non-zero only on a missing required flag.
|
|
18
|
+
|
|
19
|
+
require_relative "lib/roadmap_queue"
|
|
20
|
+
require "json"
|
|
21
|
+
|
|
22
|
+
def opt(args, name)
|
|
23
|
+
(i = args.index(name)) && args[i + 1]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def usage
|
|
27
|
+
warn "Usage: roadmap-next --roadmaps-dir <dir> [--index <path>] [--which]"
|
|
28
|
+
warn " default mode is the auto-loop queue; --which returns tie_candidates for continuing."
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
which = !!ARGV.delete("--which")
|
|
32
|
+
roadmaps_dir = opt(ARGV, "--roadmaps-dir")
|
|
33
|
+
index = opt(ARGV, "--index")
|
|
34
|
+
|
|
35
|
+
if roadmaps_dir.nil?
|
|
36
|
+
warn "roadmap-next: pass --roadmaps-dir <dir>"
|
|
37
|
+
usage
|
|
38
|
+
exit 2
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
reader = RoadmapQueue.new(roadmaps_dir: roadmaps_dir, index_path: index)
|
|
42
|
+
payload = which ? reader.which : reader.queue
|
|
43
|
+
puts JSON.generate(payload)
|
|
44
|
+
exit 0
|