dsh-ecc-skills 0.5.0 → 0.5.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/README.en.md CHANGED
@@ -4,6 +4,8 @@
4
4
  [![GitHub release](https://img.shields.io/github/v/release/gongyijie85/dsh-ecc)](https://github.com/gongyijie85/dsh-ecc/releases)
5
5
  [![CI](https://github.com/gongyijie85/dsh-ecc/actions/workflows/ci.yml/badge.svg)](https://github.com/gongyijie85/dsh-ecc/actions/workflows/ci.yml)
6
6
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
+ [![DSH](https://img.shields.io/badge/DSH-0.1.0--rc.8%2B-4d6bfe)](https://github.com/gongyijie85/dsh-ecc)
8
+ [![-skills](https://img.shields.io/badge/-skills-4d6bfe)]() [![-patterns](https://img.shields.io/badge/-patterns-4d6bfe)]() [![-orchestration](https://img.shields.io/badge/-orchestration-4d6bfe)]() [![-vertical-domains](https://img.shields.io/badge/-vertical--domains-4d6bfe)]() [![-methodology](https://img.shields.io/badge/-methodology-4d6bfe)]()
7
9
 
8
10
  <div align="center">
9
11
 
@@ -12,7 +14,7 @@
12
14
  </div>
13
15
 
14
16
  [affaan-m/ECC](https://github.com/affaan-m/ECC) (the ~227k⭐ "operator system",
15
- 285 skills) skills for the **DeepSeek Harness (DSH)** — a progressive port to
17
+ 286 skills) skills for the **DeepSeek Harness (DSH)** — a progressive port to
16
18
  DSH's Cordis plugin architecture.
17
19
 
18
20
  > **Unofficial port**: skill content adapted from
@@ -36,7 +38,7 @@ dsh plugin --profile web add D:\plugins\dsh-ecc
36
38
 
37
39
  Restart the profile (`dsh web`) — the skills then load with the `skill` tool.
38
40
 
39
- ## Port status: 273 / 285 skills (95.8%)
41
+ ## Port status: 274 / 286 skills (95.8%)
40
42
 
41
43
  - **v0.1.0** ✅ 20 skills — engineering methodology, agent systems, foundations
42
44
  - **v0.2.0** ✅ 68 skills — framework/language patterns (react, vue, django,
@@ -48,16 +50,19 @@ Restart the profile (`dsh web`) — the skills then load with the `skill` tool.
48
50
  - **v0.4.0** ✅ 135 skills — vertical domains (healthcare, homelab, scientific,
49
51
  finance, design/content, network ops, supply chain, marketing, research &
50
52
  data)
53
+ - **v0.5.0 (this release)** ✅ +1 skill — `tasteforge-video` (repeatable
54
+ taste-driven video workflow: taste interview → style pack → validate → apply
55
+ → editable EDL/FCPXML export; ported from upstream 2026-08-18 commit 9c45004)
51
56
  - **Not ported (12)**: 6 skills depending on `/ecc:*` commands/hooks
52
57
  (ecc-guide, ecc-recipes, gateguard, plan-orchestrate, strategic-compact,
53
- continuous-learning-v2) and 7 with companion files — unless a hooks/commands
58
+ continuous-learning-v2) and 6 with companion files — unless a hooks/commands
54
59
  bridge layer is built later.
55
60
 
56
61
  ## Adaptation notes
57
62
 
58
63
  - `skills/<name>/SKILL.md` copied verbatim (standard format, frontmatter carries
59
64
  `metadata.origin: ECC`).
60
- - Zero harness-specific references in all 273 ported skills; only 2 command
65
+ - Zero harness-specific references in all 274 ported skills; only 2 command
61
66
  references were renamed to DSH bare names in v0.1 (`/bug-check` →
62
67
  `bug-check`, `/prompt-optimize` → `prompt-optimizer`).
63
68
  - Skill identity comes from the frontmatter `name` (e.g. the five
@@ -71,7 +76,7 @@ Restart the profile (`dsh web`) — the skills then load with the `skill` tool.
71
76
  Host-layer `ctx.skills.registerProvider` (same pattern as
72
77
  [mattpocock-skills-dsh](https://github.com/gongyijie85/mattpocock-skills-dsh)).
73
78
  Drop a `skills/<kebab-name>/SKILL.md` and it is auto-discovered. Verify with
74
- `npm run verify` (273/273).
79
+ `npm run verify` (274/274).
75
80
 
76
81
  ## License
77
82
 
package/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
  [![GitHub release](https://img.shields.io/github/v/release/gongyijie85/dsh-ecc)](https://github.com/gongyijie85/dsh-ecc/releases)
5
5
  [![CI](https://github.com/gongyijie85/dsh-ecc/actions/workflows/ci.yml/badge.svg)](https://github.com/gongyijie85/dsh-ecc/actions/workflows/ci.yml)
6
6
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
+ [![DSH](https://img.shields.io/badge/DSH-0.1.0--rc.8%2B-4d6bfe)](https://github.com/gongyijie85/dsh-ecc)
8
+ [![-技能](https://img.shields.io/badge/-技能-4d6bfe)]() [![-模式](https://img.shields.io/badge/-模式-4d6bfe)]() [![-编排](https://img.shields.io/badge/-编排-4d6bfe)]() [![-垂直领域](https://img.shields.io/badge/-垂直领域-4d6bfe)]() [![-方法论文法](https://img.shields.io/badge/-方法论文法-4d6bfe)]()
7
9
 
8
10
  <div align="center">
9
11
 
@@ -11,7 +13,7 @@
11
13
 
12
14
  </div>
13
15
 
14
- 把 [affaan-m/ECC](https://github.com/affaan-m/ECC)(~227k⭐ 的"操作员系统",285
16
+ 把 [affaan-m/ECC](https://github.com/affaan-m/ECC)(~227k⭐ 的"操作员系统",286
15
17
  技能)渐进移植到 **DeepSeek Harness (DSH)** 的 Cordis 插件架构。
16
18
 
17
19
  > **English:** ECC (227k⭐ operator system) skills for DeepSeek Harness —
@@ -27,6 +29,8 @@
27
29
 
28
30
  ## 安装
29
31
 
32
+ **支持的 DSH 版本**:`>=0.1.0-rc.8`(宿主面仅 `ctx.skills.registerProvider`,覆盖 0.1.0-rc.8 起全部 rc/alpha 线;实测基线 0.1.1-rc.2)。
33
+
30
34
  ```sh
31
35
  # npm(包名 dsh-ecc 已被同名项目占用,本包发布为 dsh-ecc-skills)
32
36
  dsh plugin --profile web add dsh-ecc-skills
@@ -75,16 +79,19 @@ dsh plugin --profile web add D:\plugins\dsh-ecc
75
79
  - **v0.1.0** ✅ 20 个纯单文件、无 harness 依赖的技能
76
80
  - **v0.2.0** ✅ 68 个模式类批量(前端/后端/语言/数据/架构)
77
81
  - **v0.3.0** ✅ 50 个编排/自动化/运维类(orch-*、council、team-*、e2e-testing、benchmark 等)
78
- - **v0.4.0(本次,收官)** ✅ **135 个垂直领域与全部剩余可移植技能**:
82
+ - **v0.4.0** ✅ **135 个垂直领域与全部剩余可移植技能**:
79
83
  医疗(healthcare-*、hipaa)、家庭网络(homelab-*)、科学(scientific-* / pubmed / uspto / gget)、
80
84
  金融(customer-billing / finance-billing / defi / prediction-market / evm / x402)、
81
85
  设计与内容(brand-*、motion-*、liquid-glass、manim、remotion、article-writing、seo)、
82
86
  网络运维(cisco-ios、netmiko、network-*、terminal-*)、供应链/物流、营销/销售、
83
87
  研究与数据(pytorch、recsys、mle、clickhouse、video/audio)等
84
- - **累计:273/285 技能已移植**( 95.8%);未移植仅 12 个:
88
+ - **v0.5.0(本次)** ✅ **+1 个技能**:`tasteforge-video`(可复现的 taste 驱动
89
+ 视频工作流——风格访谈 → style pack → 校验 → 应用 → EDL/FCPXML 导出,
90
+ 移植上游 2026-08-18 新增提交 9c45004)
91
+ - **累计:274/286 技能已移植**(占 95.8%);未移植仅 12 个:
85
92
  - 依赖 ECC 专属基础设施(`ecc-guide`、`ecc-recipes`、`gateguard`、`plan-orchestrate`、
86
93
  `strategic-compact`、`continuous-learning-v2`)——除非后续做 hooks/commands 桥接层
87
- - 带辅助文件的 7 个(`continuous-learning`、`frontend-slides`、`openclaw-persona-forge`、
94
+ - 带辅助文件的 6 个(`continuous-learning`、`frontend-slides`、`openclaw-persona-forge`、
88
95
  `security-review`、`skill-comply`、`visa-doc-translate`)
89
96
 
90
97
  ## 移植说明(对比上游)
@@ -102,7 +109,7 @@ dsh plugin --profile web add D:\plugins\dsh-ecc
102
109
  同 [mattpocock-skills-dsh](https://github.com/gongyijie85/mattpocock-skills-dsh)
103
110
  (host 层 `ctx.skills.registerProvider`;零运行时依赖;原生解析折叠 YAML
104
111
  frontmatter)。往 `skills/<kebab-name>/SKILL.md` 放文件即自动发现;验证:
105
- `npm run verify`(20/20)。
112
+ `npm run verify`(274/274)。
106
113
 
107
114
  ## 许可证
108
115
 
@@ -0,0 +1,288 @@
1
+ {
2
+ "id": "gongyijie85/dsh-ecc",
3
+ "version": "0.5.2",
4
+ "main": "./lib/index.js",
5
+ "description": "ECC (227k-star operator system) skills for DeepSeek Harness — progressive port of 274 curated single-file skills (agentic engineering, evaluation, testing, patterns, vertical domains, docs). Adapted from affaan-m/ECC (MIT)",
6
+ "engines": {
7
+ "dsh": ">=0.1.0-rc.8"
8
+ },
9
+ "contributes": {
10
+ "tools": [],
11
+ "skills": [
12
+ "accessibility",
13
+ "agent-architecture-audit",
14
+ "agent-eval",
15
+ "agent-harness-construction",
16
+ "agent-introspection-debugging",
17
+ "agent-payment-x402",
18
+ "agent-self-evaluation",
19
+ "agent-sort",
20
+ "agentic-engineering",
21
+ "agentic-os",
22
+ "ai-first-engineering",
23
+ "ai-regression-testing",
24
+ "android-clean-architecture",
25
+ "angular-developer",
26
+ "api-connector-builder",
27
+ "api-design",
28
+ "architecture-decision-records",
29
+ "article-writing",
30
+ "automation-audit-ops",
31
+ "autonomous-agent-harness",
32
+ "autonomous-loops",
33
+ "backend-patterns",
34
+ "benchmark",
35
+ "benchmark-methodology",
36
+ "benchmark-optimization-loop",
37
+ "blender-motion-state-inspection",
38
+ "blueprint",
39
+ "brand-discovery",
40
+ "brand-voice",
41
+ "browser-qa",
42
+ "bun-runtime",
43
+ "canary-watch",
44
+ "carrier-relationship-management",
45
+ "cisco-ios-patterns",
46
+ "ck",
47
+ "claude-devfleet",
48
+ "click-path-audit",
49
+ "clickhouse-io",
50
+ "code-tour",
51
+ "codebase-onboarding",
52
+ "codehealth-mcp",
53
+ "coding-standards",
54
+ "competitive-platform-analysis",
55
+ "competitive-report-structure",
56
+ "compose-multiplatform-patterns",
57
+ "config-gc",
58
+ "configure-ecc",
59
+ "connections-optimizer",
60
+ "content-engine",
61
+ "content-hash-cache-pattern",
62
+ "context-budget",
63
+ "continuous-agent-loop",
64
+ "contract-first",
65
+ "cost-aware-llm-pipeline",
66
+ "cost-tracking",
67
+ "council",
68
+ "council-multi-model",
69
+ "cpp-coding-standards",
70
+ "cpp-testing",
71
+ "crosspost",
72
+ "csharp-testing",
73
+ "customer-billing-ops",
74
+ "customs-trade-compliance",
75
+ "dart-flutter-patterns",
76
+ "dashboard-builder",
77
+ "data-scraper-agent",
78
+ "data-throughput-accelerator",
79
+ "database-migrations",
80
+ "deep-research",
81
+ "defi-amm-security",
82
+ "delivery-gate",
83
+ "deployment-patterns",
84
+ "design-system",
85
+ "dev-team",
86
+ "django-celery",
87
+ "django-patterns",
88
+ "django-security",
89
+ "django-tdd",
90
+ "django-verification",
91
+ "dmux-workflows",
92
+ "docker-patterns",
93
+ "documentation-lookup",
94
+ "dotnet-patterns",
95
+ "dynamic-workflow-mode",
96
+ "e2e-testing",
97
+ "ecc-tools-cost-audit",
98
+ "email-ops",
99
+ "energy-procurement",
100
+ "enterprise-agent-ops",
101
+ "error-handling",
102
+ "eval-harness",
103
+ "evm-token-decimals",
104
+ "exa-search",
105
+ "fal-ai-media",
106
+ "fastapi-patterns",
107
+ "finance-billing-ops",
108
+ "flox-environments",
109
+ "flutter-dart-code-review",
110
+ "foundation-models-on-device",
111
+ "frontend-a11y",
112
+ "frontend-design-direction",
113
+ "frontend-patterns",
114
+ "fsharp-testing",
115
+ "gan-style-harness",
116
+ "generating-python-installer",
117
+ "git-workflow",
118
+ "github-ops",
119
+ "golang-patterns",
120
+ "golang-testing",
121
+ "google-workspace-ops",
122
+ "growth-log",
123
+ "healthcare-cdss-patterns",
124
+ "healthcare-emr-patterns",
125
+ "healthcare-eval-harness",
126
+ "healthcare-phi-compliance",
127
+ "hermes-imports",
128
+ "hexagonal-architecture",
129
+ "hipaa-compliance",
130
+ "homelab-network-readiness",
131
+ "homelab-network-setup",
132
+ "homelab-pihole-dns",
133
+ "homelab-vlan-segmentation",
134
+ "homelab-wireguard-vpn",
135
+ "hookify-rules",
136
+ "inherit-legacy-style",
137
+ "intent-driven-development",
138
+ "inventory-demand-planning",
139
+ "investor-materials",
140
+ "investor-outreach",
141
+ "ios-icon-gen",
142
+ "iterative-retrieval",
143
+ "ito-baskets",
144
+ "ito-compute",
145
+ "ito-inference",
146
+ "ito-training",
147
+ "java-coding-standards",
148
+ "jira-integration",
149
+ "jpa-patterns",
150
+ "knowledge-ops",
151
+ "kotlin-coroutines-flows",
152
+ "kotlin-exposed-patterns",
153
+ "kotlin-ktor-patterns",
154
+ "kotlin-patterns",
155
+ "kotlin-testing",
156
+ "kubernetes-patterns",
157
+ "laravel-patterns",
158
+ "laravel-plugin-discovery",
159
+ "laravel-security",
160
+ "laravel-tdd",
161
+ "laravel-verification",
162
+ "latency-critical-systems",
163
+ "lead-intelligence",
164
+ "liquid-glass-design",
165
+ "living-docs-governance",
166
+ "llm-trading-agent-security",
167
+ "logistics-exception-management",
168
+ "loop-design-check",
169
+ "mailtrap-email-integration",
170
+ "make-interfaces-feel-better",
171
+ "manim-video",
172
+ "market-research",
173
+ "marketing-campaign",
174
+ "mcp-server-patterns",
175
+ "messages-ops",
176
+ "ml-adoption-playbook",
177
+ "mle-workflow",
178
+ "motion-advanced",
179
+ "motion-foundations",
180
+ "motion-patterns",
181
+ "motion-ui",
182
+ "mysql-patterns",
183
+ "nanoclaw-repl",
184
+ "nasiko-control-plane",
185
+ "nestjs-patterns",
186
+ "netmiko-ssh-automation",
187
+ "network-bgp-diagnostics",
188
+ "network-config-validation",
189
+ "network-interface-health",
190
+ "nextjs-turbopack",
191
+ "nodejs-keccak256",
192
+ "nutrient-document-processing",
193
+ "nuxt4-patterns",
194
+ "opensource-pipeline",
195
+ "orch-add-feature",
196
+ "orch-build-mvp",
197
+ "orch-change-feature",
198
+ "orch-fix-defect",
199
+ "orch-pipeline",
200
+ "orch-refine-code",
201
+ "parallel-execution-optimizer",
202
+ "perl-patterns",
203
+ "perl-security",
204
+ "perl-testing",
205
+ "plan-canvas",
206
+ "plankton-code-quality",
207
+ "postgres-patterns",
208
+ "prediction-market-oracle-research",
209
+ "prediction-market-risk-review",
210
+ "prisma-patterns",
211
+ "product-capability",
212
+ "product-lens",
213
+ "production-audit",
214
+ "production-scheduling",
215
+ "project-flow-ops",
216
+ "prompt-optimizer",
217
+ "python-patterns",
218
+ "python-testing",
219
+ "pytorch-patterns",
220
+ "quality-nonconformance",
221
+ "quarkus-patterns",
222
+ "quarkus-security",
223
+ "quarkus-tdd",
224
+ "quarkus-verification",
225
+ "ralphinho-rfc-pipeline",
226
+ "react-native-patterns",
227
+ "react-patterns",
228
+ "react-performance",
229
+ "react-testing",
230
+ "recsys-pipeline-architect",
231
+ "recursive-decision-ledger",
232
+ "redis-patterns",
233
+ "regex-vs-llm-structured-text",
234
+ "remotion-video-creation",
235
+ "repo-scan",
236
+ "research-ops",
237
+ "returns-reverse-logistics",
238
+ "rules-distill",
239
+ "rust-patterns",
240
+ "rust-testing",
241
+ "safety-guard",
242
+ "santa-method",
243
+ "scientific-db-pubmed-database",
244
+ "scientific-db-uspto-database",
245
+ "scientific-pkg-gget",
246
+ "scientific-thinking-literature-review",
247
+ "scientific-thinking-scholar-evaluation",
248
+ "search-first",
249
+ "security-bounty-hunter",
250
+ "security-scan",
251
+ "seo",
252
+ "skill-scout",
253
+ "skill-stocktake",
254
+ "social-graph-ranker",
255
+ "social-publisher",
256
+ "springboot-patterns",
257
+ "springboot-security",
258
+ "springboot-tdd",
259
+ "springboot-verification",
260
+ "swift-actor-persistence",
261
+ "swift-concurrency-6-2",
262
+ "swift-protocol-di-testing",
263
+ "swiftui-patterns",
264
+ "taste",
265
+ "tasteforge-video",
266
+ "tdd-workflow",
267
+ "team-agent-orchestration",
268
+ "team-builder",
269
+ "terminal-opener",
270
+ "terminal-ops",
271
+ "tinystruct-patterns",
272
+ "token-budget-advisor",
273
+ "ui-demo",
274
+ "ui-to-vue",
275
+ "uncloud",
276
+ "unified-memory",
277
+ "unified-notifications-ops",
278
+ "verification-loop",
279
+ "video-editing",
280
+ "videodb",
281
+ "vite-patterns",
282
+ "vue-patterns",
283
+ "windows-desktop-e2e",
284
+ "workspace-surface-audit",
285
+ "x-api"
286
+ ]
287
+ }
288
+ }
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "dsh-ecc-skills",
3
3
  "description": "ECC (227k-star operator system) skills for DeepSeek Harness — progressive port of 274 curated single-file skills (agentic engineering, evaluation, testing, patterns, vertical domains, docs). Adapted from affaan-m/ECC (MIT)",
4
- "version": "0.5.0",
4
+ "version": "0.5.2",
5
5
  "private": false,
6
6
  "type": "module",
7
+ "engines": {
8
+ "dsh": ">=0.1.0-rc.8"
9
+ },
7
10
  "main": "lib/index.js",
8
11
  "exports": {
9
12
  ".": "./lib/index.js",
@@ -12,6 +15,7 @@
12
15
  "files": [
13
16
  "lib",
14
17
  "skills",
18
+ "dsh.plugin.json",
15
19
  "cordis.patch.yml",
16
20
  "README.md",
17
21
  "README.en.md",
@@ -42,6 +46,11 @@
42
46
  "dsh": {
43
47
  "bundle": {
44
48
  "patch": "./cordis.patch.yml"
49
+ },
50
+ "compatibility": {
51
+ "dshReleases": {
52
+ "0.1.1-rc.2": "compatible"
53
+ }
45
54
  }
46
55
  }
47
56
  }
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Itô Compute"
3
+ short_description: "GPU inventory, RFQs, status, and revocation"
4
+ default_prompt: "Use $ito-compute to request a live GPU RFQ, inspect status, or revoke this device safely."
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Nasiko Control Plane"
3
+ short_description: "Safely install and inspect the optional Nasiko control plane"
4
+ default_prompt: "Use $nasiko-control-plane to inspect or explicitly install the pinned Nasiko CLI without enabling telemetry or exposing secrets."
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env bash
2
+ # quick-diff.sh — compare skill file mtimes against results.json evaluated_at
3
+ # Usage: quick-diff.sh RESULTS_JSON [CWD_SKILLS_DIR]
4
+ # Output: JSON array of changed/new files to stdout (empty [] if no changes)
5
+ #
6
+ # When CWD_SKILLS_DIR is omitted, defaults to $PWD/.claude/skills so the
7
+ # script always picks up project-level skills without relying on the caller.
8
+ #
9
+ # Environment:
10
+ # SKILL_STOCKTAKE_GLOBAL_DIR Override ~/.claude/skills (for testing only;
11
+ # do not set in production — intended for bats tests)
12
+ # SKILL_STOCKTAKE_PROJECT_DIR Override project dir detection (for testing only)
13
+
14
+ set -euo pipefail
15
+
16
+ RESULTS_JSON="${1:-}"
17
+ CWD_SKILLS_DIR="${SKILL_STOCKTAKE_PROJECT_DIR:-${2:-$PWD/.claude/skills}}"
18
+ GLOBAL_DIR="${SKILL_STOCKTAKE_GLOBAL_DIR:-$HOME/.claude/skills}"
19
+
20
+ if [[ -z "$RESULTS_JSON" || ! -f "$RESULTS_JSON" ]]; then
21
+ echo "Error: RESULTS_JSON not found: ${RESULTS_JSON:-<empty>}" >&2
22
+ exit 1
23
+ fi
24
+
25
+ # Validate CWD_SKILLS_DIR looks like a .claude/skills path (defense-in-depth).
26
+ # Only warn when the path exists — a nonexistent path poses no traversal risk.
27
+ if [[ -n "$CWD_SKILLS_DIR" && -d "$CWD_SKILLS_DIR" && "$CWD_SKILLS_DIR" != */.claude/skills* ]]; then
28
+ echo "Warning: CWD_SKILLS_DIR does not look like a .claude/skills path: $CWD_SKILLS_DIR" >&2
29
+ fi
30
+
31
+ evaluated_at=$(jq -r '.evaluated_at' "$RESULTS_JSON")
32
+
33
+ # Fail fast on a missing or malformed evaluated_at rather than producing
34
+ # unpredictable results from ISO 8601 string comparison against "null".
35
+ if [[ ! "$evaluated_at" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$ ]]; then
36
+ echo "Error: invalid or missing evaluated_at in $RESULTS_JSON: $evaluated_at" >&2
37
+ exit 1
38
+ fi
39
+
40
+ # Pre-extract known paths from results.json once (O(1) lookup per file instead of O(n*m))
41
+ known_paths=$(jq -r '.skills[].path' "$RESULTS_JSON" 2>/dev/null)
42
+
43
+ tmpdir=$(mktemp -d)
44
+ # Use a function to avoid embedding $tmpdir in a quoted string (prevents injection
45
+ # if TMPDIR were crafted to contain shell metacharacters).
46
+ _cleanup() { rm -rf "$tmpdir"; }
47
+ trap _cleanup EXIT
48
+
49
+ # Shared counter across process_dir calls — intentionally NOT local
50
+ i=0
51
+
52
+ process_dir() {
53
+ local dir="$1"
54
+ while IFS= read -r file; do
55
+ local mtime dp is_new
56
+ mtime=$(date -u -r "$file" +%Y-%m-%dT%H:%M:%SZ)
57
+ dp="${file/#$HOME/~}"
58
+
59
+ # Check if this file is known to results.json (exact whole-line match to
60
+ # avoid substring false-positives, e.g. "python-patterns" matching "python-patterns-v2").
61
+ if echo "$known_paths" | grep -qxF "$dp"; then
62
+ is_new="false"
63
+ # Known file: only emit if mtime changed (ISO 8601 string comparison is safe)
64
+ [[ "$mtime" > "$evaluated_at" ]] || continue
65
+ else
66
+ is_new="true"
67
+ # New file: always emit regardless of mtime
68
+ fi
69
+
70
+ jq -n \
71
+ --arg path "$dp" \
72
+ --arg mtime "$mtime" \
73
+ --argjson is_new "$is_new" \
74
+ '{path:$path,mtime:$mtime,is_new:$is_new}' \
75
+ > "$tmpdir/$i.json"
76
+ i=$((i+1))
77
+ done < <(find "$dir" -name "*.md" -type f 2>/dev/null | sort)
78
+ }
79
+
80
+ [[ -d "$GLOBAL_DIR" ]] && process_dir "$GLOBAL_DIR"
81
+ [[ -n "$CWD_SKILLS_DIR" && -d "$CWD_SKILLS_DIR" ]] && process_dir "$CWD_SKILLS_DIR"
82
+
83
+ if [[ $i -eq 0 ]]; then
84
+ echo "[]"
85
+ else
86
+ jq -s '.' "$tmpdir"/*.json
87
+ fi
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env bash
2
+ # save-results.sh — merge evaluated skills into results.json with correct UTC timestamp
3
+ # Usage: save-results.sh RESULTS_JSON <<< "$EVAL_JSON"
4
+ #
5
+ # stdin format:
6
+ # { "skills": {...}, "mode"?: "full"|"quick", "batch_progress"?: {...} }
7
+ #
8
+ # Always sets evaluated_at to current UTC time via `date -u`.
9
+ # Merges stdin .skills into existing results.json (new entries override old).
10
+ # Optionally updates .mode and .batch_progress if present in stdin.
11
+
12
+ set -euo pipefail
13
+
14
+ RESULTS_JSON="${1:-}"
15
+
16
+ if [[ -z "$RESULTS_JSON" ]]; then
17
+ echo "Error: RESULTS_JSON argument required" >&2
18
+ echo "Usage: save-results.sh RESULTS_JSON <<< \"\$EVAL_JSON\"" >&2
19
+ exit 1
20
+ fi
21
+
22
+ EVALUATED_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)
23
+
24
+ # Read eval results from stdin and validate JSON before touching the results file
25
+ input_json=$(cat)
26
+ if ! echo "$input_json" | jq empty 2>/dev/null; then
27
+ echo "Error: stdin is not valid JSON" >&2
28
+ exit 1
29
+ fi
30
+
31
+ if [[ ! -f "$RESULTS_JSON" ]]; then
32
+ # Bootstrap: create new results.json from stdin JSON + current UTC timestamp
33
+ echo "$input_json" | jq --arg ea "$EVALUATED_AT" \
34
+ '. + { evaluated_at: $ea }' > "$RESULTS_JSON"
35
+ exit 0
36
+ fi
37
+
38
+ # Merge: new .skills override existing ones; old skills not in input_json are kept.
39
+ # Optionally update .mode and .batch_progress if provided.
40
+ #
41
+ # Use mktemp for a collision-safe temp file (concurrent runs on the same RESULTS_JSON
42
+ # would race on a predictable ".tmp" suffix; random suffix prevents silent overwrites).
43
+ tmp=$(mktemp "${RESULTS_JSON}.XXXXXX")
44
+ trap 'rm -f "$tmp"' EXIT
45
+
46
+ jq -s \
47
+ --arg ea "$EVALUATED_AT" \
48
+ '.[0] as $existing | .[1] as $new |
49
+ $existing |
50
+ .evaluated_at = $ea |
51
+ .skills = ($existing.skills + ($new.skills // {})) |
52
+ if ($new | has("mode")) then .mode = $new.mode else . end |
53
+ if ($new | has("batch_progress")) then .batch_progress = $new.batch_progress else . end' \
54
+ "$RESULTS_JSON" <(echo "$input_json") > "$tmp"
55
+
56
+ mv "$tmp" "$RESULTS_JSON"
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env bash
2
+ # scan.sh — enumerate skill files, extract frontmatter and UTC mtime
3
+ # Usage: scan.sh [CWD_SKILLS_DIR]
4
+ # Output: JSON to stdout
5
+ #
6
+ # When CWD_SKILLS_DIR is omitted, defaults to $PWD/.claude/skills so the
7
+ # script always picks up project-level skills without relying on the caller.
8
+ #
9
+ # Environment:
10
+ # SKILL_STOCKTAKE_GLOBAL_DIR Override ~/.claude/skills (for testing only;
11
+ # do not set in production — intended for bats tests)
12
+ # SKILL_STOCKTAKE_PROJECT_DIR Override project dir detection (for testing only)
13
+
14
+ set -euo pipefail
15
+
16
+ GLOBAL_DIR="${SKILL_STOCKTAKE_GLOBAL_DIR:-$HOME/.claude/skills}"
17
+ CWD_SKILLS_DIR="${SKILL_STOCKTAKE_PROJECT_DIR:-${1:-$PWD/.claude/skills}}"
18
+ # Path to JSONL file containing tool-use observations (optional; used for usage frequency counts).
19
+ # Override via SKILL_STOCKTAKE_OBSERVATIONS env var if your setup uses a different path.
20
+ OBSERVATIONS="${SKILL_STOCKTAKE_OBSERVATIONS:-$HOME/.claude/observations.jsonl}"
21
+
22
+ # Validate CWD_SKILLS_DIR looks like a .claude/skills path (defense-in-depth).
23
+ # Only warn when the path exists — a nonexistent path poses no traversal risk.
24
+ if [[ -n "$CWD_SKILLS_DIR" && -d "$CWD_SKILLS_DIR" && "$CWD_SKILLS_DIR" != */.claude/skills* ]]; then
25
+ echo "Warning: CWD_SKILLS_DIR does not look like a .claude/skills path: $CWD_SKILLS_DIR" >&2
26
+ fi
27
+
28
+ # Extract a frontmatter field (handles both quoted and unquoted single-line values).
29
+ # Does NOT support multi-line YAML blocks (| or >) or nested YAML keys.
30
+ extract_field() {
31
+ local file="$1" field="$2"
32
+ awk -v f="$field" '
33
+ BEGIN { fm=0 }
34
+ /^---$/ { fm++; next }
35
+ fm==1 {
36
+ n = length(f) + 2
37
+ if (substr($0, 1, n) == f ": ") {
38
+ val = substr($0, n+1)
39
+ gsub(/^"/, "", val)
40
+ gsub(/"$/, "", val)
41
+ print val
42
+ exit
43
+ }
44
+ }
45
+ fm>=2 { exit }
46
+ ' "$file"
47
+ }
48
+
49
+ # Get UTC timestamp N days ago (supports both macOS and GNU date)
50
+ date_ago() {
51
+ local n="$1"
52
+ date -u -v-"${n}d" +%Y-%m-%dT%H:%M:%SZ 2>/dev/null ||
53
+ date -u -d "${n} days ago" +%Y-%m-%dT%H:%M:%SZ
54
+ }
55
+
56
+ # Count observations matching a file path since a cutoff timestamp
57
+ count_obs() {
58
+ local file="$1" cutoff="$2"
59
+ if [[ ! -f "$OBSERVATIONS" ]]; then
60
+ echo 0
61
+ return
62
+ fi
63
+ jq -r --arg p "$file" --arg c "$cutoff" \
64
+ 'select(.tool=="Read" and .path==$p and .timestamp>=$c) | 1' \
65
+ "$OBSERVATIONS" 2>/dev/null | wc -l | tr -d ' '
66
+ }
67
+
68
+ # Scan a directory and produce a JSON array of skill objects
69
+ scan_dir_to_json() {
70
+ local dir="$1"
71
+ local c7 c30
72
+ c7=$(date_ago 7)
73
+ c30=$(date_ago 30)
74
+
75
+ local tmpdir
76
+ tmpdir=$(mktemp -d)
77
+ # Use a function to avoid embedding $tmpdir in a quoted string (prevents injection
78
+ # if TMPDIR were crafted to contain shell metacharacters).
79
+ local _scan_tmpdir="$tmpdir"
80
+ _scan_cleanup() { rm -rf "$_scan_tmpdir"; }
81
+ trap _scan_cleanup RETURN
82
+
83
+ # Pre-aggregate observation counts in two passes (one per window) instead of
84
+ # calling jq per-file — reduces from O(n*m) to O(n+m) jq invocations.
85
+ local obs_7d_counts obs_30d_counts
86
+ obs_7d_counts=""
87
+ obs_30d_counts=""
88
+ if [[ -f "$OBSERVATIONS" ]]; then
89
+ obs_7d_counts=$(jq -r --arg c "$c7" \
90
+ 'select(.tool=="Read" and .timestamp>=$c) | .path' \
91
+ "$OBSERVATIONS" 2>/dev/null | sort | uniq -c)
92
+ obs_30d_counts=$(jq -r --arg c "$c30" \
93
+ 'select(.tool=="Read" and .timestamp>=$c) | .path' \
94
+ "$OBSERVATIONS" 2>/dev/null | sort | uniq -c)
95
+ fi
96
+
97
+ local i=0
98
+ while IFS= read -r file; do
99
+ local name desc mtime u7 u30 dp
100
+ name=$(extract_field "$file" "name")
101
+ desc=$(extract_field "$file" "description")
102
+ mtime=$(date -u -r "$file" +%Y-%m-%dT%H:%M:%SZ)
103
+ # Use awk exact field match to avoid substring false-positives from grep -F.
104
+ # uniq -c output format: " N /path/to/file" — path is always field 2.
105
+ u7=$(echo "$obs_7d_counts" | awk -v f="$file" '$2 == f {print $1}' | head -1)
106
+ u7="${u7:-0}"
107
+ u30=$(echo "$obs_30d_counts" | awk -v f="$file" '$2 == f {print $1}' | head -1)
108
+ u30="${u30:-0}"
109
+ dp="${file/#$HOME/~}"
110
+
111
+ jq -n \
112
+ --arg path "$dp" \
113
+ --arg name "$name" \
114
+ --arg description "$desc" \
115
+ --arg mtime "$mtime" \
116
+ --argjson use_7d "$u7" \
117
+ --argjson use_30d "$u30" \
118
+ '{path:$path,name:$name,description:$description,use_7d:$use_7d,use_30d:$use_30d,mtime:$mtime}' \
119
+ > "$tmpdir/$i.json"
120
+ i=$((i+1))
121
+ done < <(find "$dir" -name "*.md" -type f 2>/dev/null | sort)
122
+
123
+ if [[ $i -eq 0 ]]; then
124
+ echo "[]"
125
+ else
126
+ jq -s '.' "$tmpdir"/*.json
127
+ fi
128
+ }
129
+
130
+ # --- Main ---
131
+
132
+ global_found="false"
133
+ global_count=0
134
+ global_skills="[]"
135
+
136
+ if [[ -d "$GLOBAL_DIR" ]]; then
137
+ global_found="true"
138
+ global_skills=$(scan_dir_to_json "$GLOBAL_DIR")
139
+ global_count=$(echo "$global_skills" | jq 'length')
140
+ fi
141
+
142
+ project_found="false"
143
+ project_path=""
144
+ project_count=0
145
+ project_skills="[]"
146
+
147
+ if [[ -n "$CWD_SKILLS_DIR" && -d "$CWD_SKILLS_DIR" ]]; then
148
+ project_found="true"
149
+ project_path="$CWD_SKILLS_DIR"
150
+ project_skills=$(scan_dir_to_json "$CWD_SKILLS_DIR")
151
+ project_count=$(echo "$project_skills" | jq 'length')
152
+ fi
153
+
154
+ # Merge global + project skills into one array
155
+ all_skills=$(jq -s 'add' <(echo "$global_skills") <(echo "$project_skills"))
156
+
157
+ jq -n \
158
+ --arg global_found "$global_found" \
159
+ --argjson global_count "$global_count" \
160
+ --arg project_found "$project_found" \
161
+ --arg project_path "$project_path" \
162
+ --argjson project_count "$project_count" \
163
+ --argjson skills "$all_skills" \
164
+ '{
165
+ scan_summary: {
166
+ global: { found: ($global_found == "true"), count: $global_count },
167
+ project: { found: ($project_found == "true"), path: $project_path, count: $project_count }
168
+ },
169
+ skills: $skills
170
+ }'