@yandy-r/ycc-opencode 6.1.1 → 6.2.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.
Files changed (119) hide show
  1. package/README.md +7 -3
  2. package/agents/code-researcher.md +3 -3
  3. package/agents/feature-researcher.md +1 -1
  4. package/agents/implementor.md +4 -4
  5. package/agents/pr-comment-fixer.md +1 -1
  6. package/agents/release-fix-applier.md +1 -1
  7. package/agents/review-fixer.md +1 -1
  8. package/package.json +1 -1
  9. package/shared/references/artifact-store.md +613 -0
  10. package/shared/references/branch-prep.md +2 -0
  11. package/shared/references/forge-detection.md +3 -2
  12. package/shared/references/review-artifact-format.md +13 -6
  13. package/shared/references/review-checklist.md +3 -2
  14. package/shared/references/review-dispatch.md +15 -10
  15. package/shared/references/target-capability-matrix.md +42 -6
  16. package/shared/references/visual-mode.md +19 -13
  17. package/shared/references/worktree-strategy.md +12 -8
  18. package/shared/scripts/artifact-body.sh +71 -0
  19. package/shared/scripts/artifact-store-pointer.sh +245 -0
  20. package/shared/scripts/ci-monitor.sh +9 -4
  21. package/shared/scripts/collect-linear-keys.sh +77 -0
  22. package/shared/scripts/lib/ci-classify.sh +13 -10
  23. package/shared/scripts/lib/forge.sh +13 -4
  24. package/shared/scripts/prepare-feature-branch.sh +96 -10
  25. package/shared/scripts/release-ci-monitor.sh +2 -2
  26. package/shared/scripts/report-bundle-drift.sh +1 -1
  27. package/shared/scripts/resolve-artifact-store.sh +636 -0
  28. package/shared/scripts/validate-file-paths.sh +11 -4
  29. package/skills/blueprint/SKILL.md +48 -13
  30. package/skills/clean/SKILL.md +1 -1
  31. package/skills/clean/scripts/detect-project-type.sh +2 -2
  32. package/skills/clean/scripts/generate-report.sh +34 -5
  33. package/skills/clean/scripts/validate-safety.sh +9 -6
  34. package/skills/code-report/SKILL.md +26 -14
  35. package/skills/code-report/scripts/check-prerequisites.sh +72 -12
  36. package/skills/code-report/templates/report-structure.md +1 -1
  37. package/skills/code-review/SKILL.md +68 -17
  38. package/skills/code-review/references/pr-procedure.md +28 -15
  39. package/skills/compatibility-audit/scripts/audit-target-features.sh +1 -1
  40. package/skills/deep-research/SKILL.md +28 -5
  41. package/skills/deep-research/references/completion-summary-template.md +3 -2
  42. package/skills/deep-research/scripts/validate-research.sh +8 -2
  43. package/skills/feature-research/SKILL.md +48 -25
  44. package/skills/feature-research/scripts/validate-research.sh +51 -12
  45. package/skills/feature-research/scripts/validate-spec.sh +53 -22
  46. package/skills/feature-research/templates/research-agents.md +15 -14
  47. package/skills/feature-research/templates/spec-structure.md +5 -0
  48. package/skills/formatters/scripts/apply-aliases.sh +3 -1
  49. package/skills/formatters/scripts/apply-ci.sh +3 -1
  50. package/skills/git-workflow/SKILL.md +2 -1
  51. package/skills/git-workflow/references/pr-creation.md +10 -0
  52. package/skills/git-workflow/scripts/analyze-changes.sh +21 -11
  53. package/skills/git-workflow/scripts/create-pr.sh +51 -6
  54. package/skills/git-workflow/scripts/validate-commit.sh +26 -14
  55. package/skills/hooks-workflow/scripts/verify-hooks.sh +1 -1
  56. package/skills/implement-plan/SKILL.md +35 -16
  57. package/skills/implement-plan/references/agent-task-prompt.md +8 -5
  58. package/skills/implement-plan/references/linear-sync.md +20 -0
  59. package/skills/implement-plan/references/output-formats.md +17 -2
  60. package/skills/implement-plan/references/plan-inputs.md +23 -4
  61. package/skills/implement-plan/scripts/check-prerequisites.sh +95 -49
  62. package/skills/implement-plan/scripts/parse-dependencies.sh +10 -10
  63. package/skills/init/SKILL.md +77 -42
  64. package/skills/init/references/flag-reference.md +41 -17
  65. package/skills/init/references/project-profile-heuristics.md +3 -0
  66. package/skills/init/references/template-library.md +15 -5
  67. package/skills/init/scripts/profile-project.sh +26 -0
  68. package/skills/init/scripts/render-template.py +2 -2
  69. package/skills/init/templates/AGENTS.md.tmpl +6 -0
  70. package/skills/init/templates/git/gitignore.tmpl +5 -0
  71. package/skills/orchestrate/SKILL.md +17 -2
  72. package/skills/parallel-plan/SKILL.md +14 -8
  73. package/skills/plan/SKILL.md +18 -2
  74. package/skills/plan/references/planning-tracks.md +1 -1
  75. package/skills/plan-workflow/SKILL.md +67 -32
  76. package/skills/plan-workflow/references/checkpoint-messages.md +23 -14
  77. package/skills/plan-workflow/references/plan-structure.md +1 -1
  78. package/skills/plan-workflow/references/planning-agents.md +11 -9
  79. package/skills/plan-workflow/references/research-agents-optimized.md +12 -10
  80. package/skills/plan-workflow/references/research-agents.md +11 -10
  81. package/skills/plan-workflow/scripts/check-prerequisites.sh +50 -11
  82. package/skills/plan-workflow/scripts/check-state.sh +53 -9
  83. package/skills/plan-workflow/scripts/persist-or-fail.sh +21 -7
  84. package/skills/plan-workflow/scripts/validate-analysis-artifacts.sh +28 -14
  85. package/skills/plan-workflow/scripts/validate-research-artifacts.sh +35 -10
  86. package/skills/plan-workflow/scripts/validate-shared.sh +56 -15
  87. package/skills/plan-workflow/scripts/validate-workflow-plan.sh +48 -17
  88. package/skills/pr-autofix/SKILL.md +19 -4
  89. package/skills/pr-autofix/references/output-templates.md +3 -2
  90. package/skills/pr-autofix/scripts/fetch-pr-comments.sh +1 -2
  91. package/skills/pr-autofix/scripts/post-summary.sh +1 -2
  92. package/skills/pr-autofix/scripts/resolve-thread.sh +3 -4
  93. package/skills/prp-implement/SKILL.md +31 -16
  94. package/skills/prp-implement/references/agent-task-prompt.md +5 -2
  95. package/skills/prp-implement/references/detection.md +4 -1
  96. package/skills/prp-implement/references/linear-sync.md +25 -0
  97. package/skills/prp-implement/references/report-output.md +15 -2
  98. package/skills/prp-plan/SKILL.md +62 -30
  99. package/skills/prp-plan/references/enhanced-researchers.md +8 -9
  100. package/skills/prp-plan/scripts/validate-prp-plan.sh +42 -18
  101. package/skills/prp-pr/SKILL.md +14 -1
  102. package/skills/prp-prd/SKILL.md +21 -9
  103. package/skills/prp-spec/SKILL.md +30 -20
  104. package/skills/quick-fix/SKILL.md +6 -4
  105. package/skills/quick-review/SKILL.md +62 -25
  106. package/skills/release-model/scripts/collect-signals.sh +9 -3
  107. package/skills/releaser/scripts/publish-release.sh +6 -3
  108. package/skills/research-to-issues/SKILL.md +33 -14
  109. package/skills/research-to-issues/scripts/validate-prerequisites.sh +45 -23
  110. package/skills/research-to-issues/templates/task-issue.md +4 -0
  111. package/skills/research-to-issues/templates/tracking-issue.md +3 -0
  112. package/skills/review-fix/SKILL.md +96 -14
  113. package/skills/review-fix/references/fix-report.md +10 -10
  114. package/skills/review-fix/references/plan.md +5 -2
  115. package/skills/shared-context/SKILL.md +14 -11
  116. package/skills/visual-plan/SKILL.md +26 -8
  117. package/skills/visual-recap/SKILL.md +1 -1
  118. package/skills/write-docs/scripts/audit-documentation.sh +44 -10
  119. package/skills/write-docs/scripts/generate-doc-index.sh +10 -3
@@ -5,12 +5,15 @@
5
5
  set -euo pipefail
6
6
 
7
7
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
8
- RESOLVER="${SCRIPT_DIR}/../../../shared/scripts/resolve-plans-dir.sh"
8
+ RESOLVER="${SCRIPT_DIR}/../../../shared/scripts/resolve-artifact-store.sh"
9
9
 
10
- # Source resolver to get PLANS_ROOT for path resolution
10
+ # Source resolver to get PLANS_ROOT/ARTIFACT_ROOT for path resolution and the
11
+ # artifact_body helper for frontmatter-skipping heading checks.
11
12
  if [[ -f "$RESOLVER" ]]; then
12
- # shellcheck source=../../../shared/scripts/resolve-plans-dir.sh
13
+ # shellcheck source=../../../shared/scripts/resolve-artifact-store.sh
13
14
  source "$RESOLVER"
15
+ # shellcheck source=../../../shared/scripts/artifact-body.sh
16
+ source "${SCRIPT_DIR}/../../../shared/scripts/artifact-body.sh"
14
17
  fi
15
18
 
16
19
  RED='\033[0;31m'
@@ -38,7 +41,9 @@ log_success() {
38
41
  require_heading() {
39
42
  local file="$1"
40
43
  local heading="$2"
41
- if grep -q "^${heading}" "$file"; then
44
+ # Match against the body only: identity frontmatter is not content
45
+ # (see _shared/references/artifact-store.md, Frontmatter).
46
+ if grep -q "^${heading}" < <(artifact_body "$file"); then
42
47
  log_success "$(basename "$file"): found ${heading}"
43
48
  else
44
49
  log_error "$(basename "$file"): missing required heading ${heading}"
@@ -53,7 +58,8 @@ require_any_heading() {
53
58
  local found=false
54
59
  local heading
55
60
  for heading in "$@"; do
56
- if grep -q "^${heading}" "$file"; then
61
+ # Body-only match: identity frontmatter is not content.
62
+ if grep -q "^${heading}" < <(artifact_body "$file"); then
57
63
  found=true
58
64
  break
59
65
  fi
@@ -66,16 +72,43 @@ require_any_heading() {
66
72
  fi
67
73
  }
68
74
 
69
- if [[ $# -lt 1 ]]; then
70
- echo "Usage: $0 <feature-dir>"
71
- exit 1
75
+ feature_dir=""
76
+ store_flag=""
77
+
78
+ while [[ $# -gt 0 ]]; do
79
+ case "$1" in
80
+ --store=*)
81
+ store_flag="$1"
82
+ ;;
83
+ *)
84
+ if [[ -z "$feature_dir" ]]; then
85
+ feature_dir="$1"
86
+ else
87
+ echo "Usage: $0 <feature-dir> [--store=linear|local]" >&2
88
+ exit 1
89
+ fi
90
+ ;;
91
+ esac
92
+ shift
93
+ done
94
+
95
+ if [[ -n "$store_flag" ]]; then
96
+ # shellcheck disable=SC2086
97
+ resolve_artifact_store "$PWD" "$store_flag" || {
98
+ echo -e "${RED}ERROR:${NC} invalid ${store_flag#--}" >&2
99
+ exit 1
100
+ }
72
101
  fi
73
102
 
74
- feature_dir="$1"
103
+ if [[ -z "$feature_dir" ]]; then
104
+ echo "Usage: $0 <feature-dir> [--store=linear|local]"
105
+ exit 1
106
+ fi
75
107
 
76
- # Always resolve relative paths against PLANS_ROOT
77
- if [[ "$feature_dir" != /* && -n "${PLANS_ROOT:-}" ]]; then
78
- feature_dir="${PLANS_ROOT}/${feature_dir}"
108
+ # Resolve relative paths against the active artifact root: PLANS_ROOT in local
109
+ # mode, ARTIFACT_ROOT in linear mode.
110
+ if [[ "$feature_dir" != /* && -n "${ARTIFACT_ROOT:-${PLANS_ROOT:-}}" ]]; then
111
+ feature_dir="${ARTIFACT_ROOT:-$PLANS_ROOT}/${feature_dir}"
79
112
  fi
80
113
 
81
114
  if [[ ! -d "$feature_dir" ]]; then
@@ -99,6 +132,12 @@ echo "=========================================="
99
132
  for file in "${files[@]}"; do
100
133
  path="${feature_dir}/${file}"
101
134
 
135
+ # Research files live directly in the feature dir (local layout) or in its
136
+ # research/ subdir (linear layout). An existing research/ directory wins.
137
+ if [[ "$file" == research-* && -d "${feature_dir}/research" ]]; then
138
+ path="${feature_dir}/research/${file}"
139
+ fi
140
+
102
141
  if [[ ! -f "$path" ]]; then
103
142
  log_error "${file}: file not found"
104
143
  continue
@@ -5,12 +5,15 @@
5
5
  set -euo pipefail
6
6
 
7
7
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
8
- RESOLVER="${SCRIPT_DIR}/../../../shared/scripts/resolve-plans-dir.sh"
8
+ RESOLVER="${SCRIPT_DIR}/../../../shared/scripts/resolve-artifact-store.sh"
9
9
 
10
- # Source resolver to get PLANS_ROOT for path resolution
10
+ # Source resolver to get PLANS_ROOT/ARTIFACT_ROOT for path resolution and the
11
+ # artifact_body helper for frontmatter-skipping content checks.
11
12
  if [[ -f "$RESOLVER" ]]; then
12
- # shellcheck source=../../../shared/scripts/resolve-plans-dir.sh
13
+ # shellcheck source=../../../shared/scripts/resolve-artifact-store.sh
13
14
  source "$RESOLVER"
15
+ # shellcheck source=../../../shared/scripts/artifact-body.sh
16
+ source "${SCRIPT_DIR}/../../../shared/scripts/artifact-body.sh"
14
17
  fi
15
18
 
16
19
  # Colors for output
@@ -69,16 +72,43 @@ log_info() {
69
72
  }
70
73
 
71
74
  # Check if file exists
72
- if [[ $# -lt 1 ]]; then
73
- echo "Usage: $0 <path-to-feature-spec.md>"
74
- exit 1
75
+ SPEC_FILE=""
76
+ store_flag=""
77
+
78
+ while [[ $# -gt 0 ]]; do
79
+ case "$1" in
80
+ --store=*)
81
+ store_flag="$1"
82
+ ;;
83
+ *)
84
+ if [[ -z "$SPEC_FILE" ]]; then
85
+ SPEC_FILE="$1"
86
+ else
87
+ echo "Usage: $0 <path-to-feature-spec.md> [--store=linear|local]" >&2
88
+ exit 1
89
+ fi
90
+ ;;
91
+ esac
92
+ shift
93
+ done
94
+
95
+ if [[ -n "$store_flag" ]]; then
96
+ # shellcheck disable=SC2086
97
+ resolve_artifact_store "$PWD" "$store_flag" || {
98
+ echo -e "${RED}ERROR:${NC} invalid ${store_flag#--}" >&2
99
+ exit 1
100
+ }
75
101
  fi
76
102
 
77
- SPEC_FILE="$1"
103
+ if [[ -z "$SPEC_FILE" ]]; then
104
+ echo "Usage: $0 <path-to-feature-spec.md> [--store=linear|local]"
105
+ exit 1
106
+ fi
78
107
 
79
- # Always resolve relative paths against PLANS_ROOT
80
- if [[ "$SPEC_FILE" != /* && -n "${PLANS_ROOT:-}" ]]; then
81
- SPEC_FILE="${PLANS_ROOT}/${SPEC_FILE}"
108
+ # Resolve relative paths against the active artifact root: PLANS_ROOT in local
109
+ # mode, ARTIFACT_ROOT in linear mode.
110
+ if [[ "$SPEC_FILE" != /* && -n "${ARTIFACT_ROOT:-${PLANS_ROOT:-}}" ]]; then
111
+ SPEC_FILE="${ARTIFACT_ROOT:-$PLANS_ROOT}/${SPEC_FILE}"
82
112
  fi
83
113
 
84
114
  if [[ ! -f "$SPEC_FILE" ]]; then
@@ -86,14 +116,15 @@ if [[ ! -f "$SPEC_FILE" ]]; then
86
116
  exit 1
87
117
  fi
88
118
 
89
- echo "Validating: $SPEC_FILE"
90
- echo "=========================================="
91
-
92
- # Read file content
93
- CONTENT=$(cat "$SPEC_FILE")
119
+ # Read file content minus any leading frontmatter block (linear-mode identity
120
+ # metadata is not body; see _shared/references/artifact-store.md, Frontmatter).
121
+ # Match against it with here-strings, not `echo | grep -q`: under pipefail an
122
+ # early-exiting reader SIGPIPEs the echo writer and a present section reads as
123
+ # missing (YAN-1587).
124
+ CONTENT=$(artifact_body "$SPEC_FILE")
94
125
 
95
126
  # Check for title
96
- if echo "$CONTENT" | grep -q "^# Feature Spec:"; then
127
+ if grep -q "^# Feature Spec:" <<<"$CONTENT"; then
97
128
  log_success "Title present"
98
129
  else
99
130
  log_error "Missing title (should start with '# Feature Spec: [Name]')"
@@ -103,7 +134,7 @@ fi
103
134
  echo ""
104
135
  echo "Checking required sections..."
105
136
  for section in "${REQUIRED_SECTIONS[@]}"; do
106
- if echo "$CONTENT" | grep -q "^${section}"; then
137
+ if grep -q "^${section}" <<<"$CONTENT"; then
107
138
  log_success "Found: $section"
108
139
  else
109
140
  log_error "Missing required section: $section"
@@ -114,7 +145,7 @@ done
114
145
  echo ""
115
146
  echo "Checking recommended sections..."
116
147
  for section in "${RECOMMENDED_SECTIONS[@]}"; do
117
- if echo "$CONTENT" | grep -q "^${section}"; then
148
+ if grep -q "^${section}" <<<"$CONTENT"; then
118
149
  log_success "Found: $section"
119
150
  else
120
151
  log_warning "Missing recommended section: $section"
@@ -132,7 +163,7 @@ for check in "${SUBSECTION_CHECKS[@]}"; do
132
163
  found=false
133
164
  IFS='|' read -ra SUBS <<< "$subsections"
134
165
  for sub in "${SUBS[@]}"; do
135
- if echo "$CONTENT" | grep -q "^${sub}"; then
166
+ if grep -q "^${sub}" <<<"$CONTENT"; then
136
167
  found=true
137
168
  break
138
169
  fi
@@ -197,7 +228,7 @@ placeholders=(
197
228
  )
198
229
 
199
230
  for placeholder in "${placeholders[@]}"; do
200
- if echo "$CONTENT" | grep -qi "$placeholder"; then
231
+ if grep -qi "$placeholder" <<<"$CONTENT"; then
201
232
  log_warning "Found potential placeholder text: $placeholder"
202
233
  fi
203
234
  done
@@ -231,12 +262,12 @@ fi
231
262
  # Check for links
232
263
  echo ""
233
264
  echo "Checking links..."
234
- links=$(echo "$CONTENT" | grep -oE '\[([^\]]+)\]\(([^\)]+)\)' | wc -l | tr -d ' ')
265
+ links=$(grep -oE '\[[^]]+\]\([^)]+\)' <<<"$CONTENT" | wc -l | tr -d ' ' || true)
235
266
  if [[ $links -gt 0 ]]; then
236
267
  log_success "Found $links links"
237
268
 
238
269
  # Check for broken internal links to research files
239
- research_links=$(echo "$CONTENT" | grep -oE '\./research-[a-z]+\.md' || true)
270
+ research_links=$(echo "$CONTENT" | grep -oE '\./(research/)?research-[a-z-]+\.md' || true)
240
271
  if [[ -n "$research_links" ]]; then
241
272
  dir=$(dirname "$SPEC_FILE")
242
273
  while IFS= read -r link; do
@@ -6,7 +6,8 @@ These prompts deploy research sub-agents for comprehensive feature research incl
6
6
 
7
7
  Apply this contract to every sub-agent prompt in this file:
8
8
 
9
- - Write only your assigned output file under `{{FEATURE_DIR}}`.
9
+ - Write only your assigned `{{RESEARCH_<LENS>_FILE}}`; the orchestrator resolves it with the artifact-store `research-<lens>` kind.
10
+ - When replacing an existing file in linear mode, preserve its frontmatter and replace only the body. The orchestrator performs the Linear Save; do not call Linear yourself.
10
11
  - Do not edit any other files.
11
12
  - **Do NOT invoke any skills or slash commands** (e.g., `/ycc:deep-research`, `/ycc:feature-research`, or any other skill). Perform all research directly using your own tools: WebSearch, WebFetch, Read, Grep, Glob. You are a focused research agent — do your work yourself, do not delegate to other workflows.
12
13
  - **Share key findings** with relevant sub-agents using re-dispatch the affected sub-agent with the needed guidance.
@@ -52,7 +53,7 @@ Use web search and documentation to research:
52
53
 
53
54
  ## Output Format
54
55
 
55
- Write your findings to: {{FEATURE_DIR}}/research-external.md
56
+ Write your findings to: {{RESEARCH_EXTERNAL_FILE}}
56
57
 
57
58
  Structure with: Executive Summary, Primary APIs (with docs URLs, auth, endpoints, rate limits, pricing), Libraries and SDKs, Integration Patterns, Constraints and Gotchas, Code Examples, Open Questions.
58
59
 
@@ -98,7 +99,7 @@ Research and document:
98
99
 
99
100
  ## Output Format
100
101
 
101
- Write your findings to: {{FEATURE_DIR}}/research-business.md
102
+ Write your findings to: {{RESEARCH_BUSINESS_FILE}}
102
103
 
103
104
  Structure with: Executive Summary, User Stories, Business Rules (core rules + edge cases), Workflows (primary + error recovery), Domain Model (entities + state transitions), Existing Codebase Integration, Success Criteria, Open Questions.
104
105
 
@@ -144,7 +145,7 @@ Research and design:
144
145
 
145
146
  ## Output Format
146
147
 
147
- Write your findings to: {{FEATURE_DIR}}/research-technical.md
148
+ Write your findings to: {{RESEARCH_TECHNICAL_FILE}}
148
149
 
149
150
  Structure with: Executive Summary, Architecture Design (component diagram, new components, integration points), Data Models (tables with columns/types/constraints, indexes, migrations), API Design (endpoints with request/response/errors), System Constraints (performance, security, scalability), Codebase Changes (files to create/modify, dependencies), Technical Decisions (options + recommendation + rationale), Open Questions.
150
151
 
@@ -192,7 +193,7 @@ Research and document:
192
193
 
193
194
  ## Output Format
194
195
 
195
- Write your findings to: {{FEATURE_DIR}}/research-ux.md
196
+ Write your findings to: {{RESEARCH_UX_FILE}}
196
197
 
197
198
  Structure with: Executive Summary, User Workflows (primary + alternative flows), UI/UX Best Practices (industry standards, accessibility, responsive), Error Handling (error states table, validation patterns), Performance UX (loading states, optimistic updates, offline), Competitive Analysis, Recommendations (must have, should have, nice to have), Open Questions.
198
199
 
@@ -280,7 +281,7 @@ When a sub-agent proposes something with security implications, respond with the
280
281
 
281
282
  ## Output Format
282
283
 
283
- Write your findings to: {{FEATURE_DIR}}/research-security.md
284
+ Write your findings to: {{RESEARCH_SECURITY_FILE}}
284
285
 
285
286
  Structure with:
286
287
 
@@ -406,7 +407,7 @@ When recommending modularity changes, always explain the concrete benefit. "This
406
407
 
407
408
  ## Output Format
408
409
 
409
- Write your findings to: {{FEATURE_DIR}}/research-practices.md
410
+ Write your findings to: {{RESEARCH_PRACTICES_FILE}}
410
411
 
411
412
  Structure with:
412
413
 
@@ -526,7 +527,7 @@ Explore the codebase and generate:
526
527
 
527
528
  **CRITICAL**: You MUST write your findings to the specified file. This is not optional.
528
529
 
529
- **Output File**: {{FEATURE_DIR}}/research-recommendations.md
530
+ **Output File**: {{RESEARCH_RECOMMENDATIONS_FILE}}
530
531
 
531
532
  Structure with: Executive Summary, Implementation Recommendations (approach, technology choices, phasing, quick wins), Improvement Ideas (related features, enhancements, integrations), Risk Assessment (technical risks table, integration challenges, performance, security), Alternative Approaches (options with pros/cons/effort, recommendation), Task Breakdown Preview (phases with task groups, estimated complexity), Key Decisions Needed, Open Questions.
532
533
 
@@ -542,7 +543,7 @@ When spawning research sub-agents:
542
543
  1. **Read this file** to get the prompt templates
543
544
  2. **Substitute variables**:
544
545
  - `{{FEATURE_NAME}}` - The feature directory name (e.g., `plex-integration`)
545
- - `{{FEATURE_DIR}}` - Full output directory (e.g., `docs/plans/plex-integration`)
546
+ - `{{RESEARCH_<LENS>_FILE}}` - Absolute output path resolved for kind `research-<lens>` (local example: `docs/plans/plex-integration/research-<lens>.md`)
546
547
  - `{{FEATURE_DESCRIPTION}}` - Description provided by user (or feature name if none)
547
548
  3. **Register tasks** - Use track the task for all 7 research tasks
548
549
  4. **Create tasks** - Use track the task to create 7 research tasks
@@ -553,11 +554,11 @@ When spawning research sub-agents:
553
554
 
554
555
  ## Variable Reference
555
556
 
556
- | Variable | Description | Example |
557
- | ------------------------- | ------------------------------ | -------------------------------------------------------------------- |
558
- | `{{FEATURE_NAME}}` | Feature directory name | `plex-integration` |
559
- | `{{FEATURE_DIR}}` | Full research output directory | `docs/plans/plex-integration` |
560
- | `{{FEATURE_DESCRIPTION}}` | User-provided description | `Advanced Plex media library integration with filters and playlists` |
557
+ | Variable | Description | Example |
558
+ | -------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
559
+ | `{{FEATURE_NAME}}` | Feature directory name | `plex-integration` |
560
+ | `{{RESEARCH_<LENS>_FILE}}` | Absolute research output path | Local: `docs/plans/plex-integration/research-<lens>.md`; linear: `.ycc/artifacts/plex-integration/research/research-<lens>.md` |
561
+ | `{{FEATURE_DESCRIPTION}}` | User-provided description | `Advanced Plex media library integration with filters and playlists` |
561
562
 
562
563
  ## Expected Output
563
564
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  This template defines the structure for `feature-spec.md` - the consolidated research document that serves as input for plan-workflow.
4
4
 
5
+ Resolve research links for the active store: in linear mode (default) use `./research/research-<lens>.md`; in local mode use `./research-<lens>.md`.
6
+
5
7
  ---
6
8
 
7
9
  ## Complete Example Format
@@ -307,6 +309,9 @@ For detailed findings, see:
307
309
  - [research-practices.md](./research-practices.md): Engineering practices (modularity, reuse, KISS)
308
310
  - [research-recommendations.md](./research-recommendations.md): Full recommendations
309
311
 
312
+ In linear mode use the nested research path for every reference, for example:
313
+ - [research-ux.md](./research/research-ux.md): UX research
314
+
310
315
  ````
311
316
 
312
317
  ---
@@ -113,8 +113,10 @@ apply_package_json() {
113
113
  format format:modified format:staged format:unstaged
114
114
  )
115
115
  local conflicts=()
116
+ # Here-string, not `printf | grep -q`: under pipefail the early-exiting
117
+ # grep can SIGPIPE the writer and a present key reads as absent (YAN-1607).
116
118
  for key in "${template_keys[@]}"; do
117
- if printf '%s\n' "$existing" | grep -Fxq "$key"; then
119
+ if grep -Fxq -- "$key" <<<"$existing"; then
118
120
  conflicts+=("$key")
119
121
  fi
120
122
  done
@@ -118,7 +118,9 @@ PYEOF
118
118
 
119
119
  if $dry_run; then
120
120
  info "[dry-run] would write $dest"
121
- printf '%s' "$rendered" | head -20
121
+ # Print the preview from a here-string, not `printf | head`: under
122
+ # pipefail the early-exiting head SIGPIPEs the writer (YAN-1587).
123
+ head -n 20 <<<"$rendered"
122
124
  return 0
123
125
  fi
124
126
 
@@ -105,6 +105,7 @@ Only when `pr ∈ actions`. Read `references/pr-creation.md` before Step 22. Dec
105
105
  - Step 22b: resolve `$BASE`, run the sync-check guard (exit 3: no PR, stop), offer backport, per `{{package-root}}/shared/references/pr-base-and-backport.md`. Exit 2 (malformed `RELEASING.md`) stops with the parse error and `/ycc:release-model --audit`.
106
106
  - Step 23: read `templates/pr-template.md`.
107
107
  - Step 25: PR title must be Conventional Commit format and pass `validate-commit.sh`.
108
+ - Step 26a: link Linear and GitHub issues in `## Related Issues` per `references/pr-creation.md` (contract: artifact-store.md PR linking).
108
109
  - Step 28: MCP `mcp__github__create_pull_request` first, `gh pr create` fallback; forge routing via `{{package-root}}/shared/references/forge-detection.md` (`tea` for forgejo/gitea).
109
110
  - Step 27: draft when work is incomplete or feedback is wanted; honor `--draft`.
110
111
 
@@ -129,4 +130,4 @@ Read `references/examples-and-troubleshooting.md` for the commit/docs/agent/PR/o
129
130
  - `references/examples-and-troubleshooting.md` — read for checklists, examples, or when a step fails.
130
131
  - `templates/commit-types.md`, `templates/documentation-decision.md`, `templates/agent-prompts.md`, `templates/pr-template.md` — read at Steps 8, 6, 14, 23.
131
132
  - `scripts/analyze-changes.sh` (Step 2), `scripts/validate-commit.sh` (Steps 10, 18, 25, 36), `scripts/create-pr.sh` (Step 24; `--analyze --base "$BASE"`; defensive existing-PR check).
132
- - Shared: `{{package-root}}/shared/references/{forge-detection,pr-base-and-backport,ci-monitoring,goal-pairing}.md`, `{{package-root}}/shared/scripts/{pr-guard,ci-monitor}.sh`. `branch-prep.md` does not apply: this skill never creates branches.
133
+ - Shared: `{{package-root}}/shared/references/{forge-detection,pr-base-and-backport,ci-monitoring,goal-pairing,artifact-store}.md`, `{{package-root}}/shared/scripts/{pr-guard,ci-monitor,collect-linear-keys}.sh`. `branch-prep.md` does not apply: this skill never creates branches.
@@ -7,6 +7,7 @@
7
7
  - Step 22b: base, sync guard, backport
8
8
  - Steps 23–24: template and context
9
9
  - Step 25: PR title
10
+ - Step 26a: link Linear and GitHub issues
10
11
  - Step 26: PR description
11
12
  - Step 27: draft vs ready
12
13
  - Step 28: create the PR (MCP, then CLI)
@@ -92,6 +93,15 @@ docs: update API documentation and examples
92
93
  refactor(database): migrate to new query builder pattern
93
94
  ```
94
95
 
96
+ ## Step 26a: Link Linear and GitHub issues
97
+
98
+ Contract (collection, verification, keywords, skip message): `{{package-root}}/shared/references/artifact-store.md` § PR linking. Applies in both store modes.
99
+
100
+ 2. Add the `linear.issue` from the leading frontmatter of the cached plan implemented on this branch as a `closes` candidate: use the cache path known in the session, else `.ycc/artifacts/<slug>/{parallel-plan,prp-plan}.md` where `<slug>` is the branch name without a leading `feat/`. Check the current checkout, then the main checkout (parent of `git rev-parse --path-format=absolute --git-common-dir`), per the contract's step 1.
101
+ 3. Verify, then emit `Closes` for `closes` keys and `Refs` for `refs`-only keys, plus `Closes #<n>` for linked GitHub issues, under `## Related Issues`; never duplicate a line already present in the body or repository template (Step 31). Use the contract's skip message when no team or MCP can verify.
102
+
103
+ `create-pr.sh --create` applies the same team filter without MCP verification and keeps the bare `Closes #` placeholder when nothing qualifies.
104
+
95
105
  ## Step 26: PR description
96
106
 
97
107
  ```markdown
@@ -83,17 +83,17 @@ categorize_file() {
83
83
  local file="$1"
84
84
 
85
85
  # Test files
86
- if echo "$file" | grep -qE '(test|spec|__tests__|\.test\.|\.spec\.)'; then
86
+ if grep -qE '(test|spec|__tests__|\.test\.|\.spec\.)' <<<"$file"; then
87
87
  return 1
88
88
  fi
89
89
 
90
90
  # Documentation files
91
- if echo "$file" | grep -qE '\.(md|txt|rst|adoc)$|^docs/'; then
91
+ if grep -qE '\.(md|txt|rst|adoc)$|^docs/' <<<"$file"; then
92
92
  return 2
93
93
  fi
94
94
 
95
95
  # Config files
96
- if echo "$file" | grep -qE '\.(json|yaml|yml|toml|ini|conf|config)$|^\.|package\.json|tsconfig|eslint|prettier'; then
96
+ if grep -qE '\.(json|yaml|yml|toml|ini|conf|config)$|^\.|package\.json|tsconfig|eslint|prettier' <<<"$file"; then
97
97
  return 3
98
98
  fi
99
99
 
@@ -111,8 +111,9 @@ ALL_CHANGED_FILES=$(
111
111
  # Categorize each file
112
112
  while IFS= read -r file; do
113
113
  if [ -n "$file" ]; then
114
- categorize_file "$file"
115
- case $? in
114
+ rc=0
115
+ categorize_file "$file" || rc=$?
116
+ case "$rc" in
116
117
  0) SOURCE_FILES=$((SOURCE_FILES + 1)) ;;
117
118
  1) TEST_FILES=$((TEST_FILES + 1)) ;;
118
119
  2) DOC_FILES=$((DOC_FILES + 1)) ;;
@@ -157,7 +158,10 @@ echo ""
157
158
  if [ "$UNIQUE_DIRS" -gt 0 ]; then
158
159
  echo -e "${GREEN}Changed Directories:${NC}"
159
160
  echo "$ALL_CHANGED_FILES" | grep -v '^$' | xargs -r dirname | sort -u | while IFS= read -r dir; do
160
- file_count=$(echo "$ALL_CHANGED_FILES" | grep -c "^${dir}/" || echo "0")
161
+ # Count by fixed-string prefix: dir comes from the filesystem and may
162
+ # contain regex metacharacters (e.g. app/[[...slug]]), so grep would
163
+ # either miscount or fail with exit 2. awk index() cannot fail.
164
+ file_count=$(awk -v p="${dir}/" 'index($0, p) == 1 {n++} END {print n + 0}' <<<"$ALL_CHANGED_FILES")
161
165
  echo " - $dir/ ($file_count files)"
162
166
  done
163
167
  echo ""
@@ -176,14 +180,17 @@ fi
176
180
  show_files_by_category() {
177
181
  local category="$1"
178
182
  local pattern="$2"
179
- local files
183
+ local files rc
180
184
 
181
185
  if [ "$category" = "Source" ]; then
182
186
  # Source files are those that don't match other patterns
183
187
  files=$(echo "$ALL_CHANGED_FILES" | while IFS= read -r file; do
184
188
  if [ -n "$file" ]; then
185
- categorize_file "$file"
186
- [ $? -eq 0 ] && echo "$file"
189
+ rc=0
190
+ categorize_file "$file" || rc=$?
191
+ if [ "$rc" -eq 0 ]; then
192
+ echo "$file"
193
+ fi
187
194
  fi
188
195
  done)
189
196
  else
@@ -239,14 +246,17 @@ else
239
246
  echo "Potential agent scopes:"
240
247
  echo "$ALL_CHANGED_FILES" | grep -v '^$' | xargs -r dirname | sort | uniq -c | sort -rn | head -5 | while read -r count dir; do
241
248
  scope=$(basename "$dir")
242
- [ "$scope" != "." ] && echo " - Agent for: $scope ($count files)"
249
+ if [ "$scope" != "." ]; then
250
+ echo " - Agent for: $scope ($count files)"
251
+ fi
243
252
  done
244
253
  echo ""
245
254
  fi
246
255
 
247
256
  # Check for common patterns that might need documentation
248
257
  NEEDS_DOCS=false
249
- if echo "$ALL_CHANGED_FILES" | grep -qE '^(src/|lib/|app/)'; then
258
+ # A here-string avoids SIGPIPE from an early grep match under pipefail.
259
+ if grep -qE '^(src/|lib/|app/)' <<<"$ALL_CHANGED_FILES"; then
250
260
  if [ "$SOURCE_FILES" -ge 3 ]; then
251
261
  NEEDS_DOCS=true
252
262
  fi
@@ -61,11 +61,9 @@ fi
61
61
  # Detect the forge provider and select the matching CLI (gh / tea / glab).
62
62
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
63
63
  FORGE_LIB="${SCRIPT_DIR}/../../../shared/scripts/lib/forge.sh"
64
- [[ -f "$FORGE_LIB" ]] || FORGE_LIB="${SCRIPT_DIR}/../../../shared/scripts/lib/forge.sh"
65
64
  # shellcheck source=/dev/null
66
65
  source "$FORGE_LIB"
67
66
  PR_GUARD="${SCRIPT_DIR}/../../../shared/scripts/pr-guard.sh"
68
- [[ -f "$PR_GUARD" ]] || PR_GUARD="${SCRIPT_DIR}/../../../shared/scripts/pr-guard.sh"
69
67
 
70
68
  PROVIDER="$(forge_detect_provider origin)"
71
69
  FORGE_CLI="$(forge_cli "$PROVIDER")"
@@ -220,7 +218,7 @@ else
220
218
  # Try to extract type and scope from first commit
221
219
  FIRST_COMMIT=$(git log --format=%s -n1 HEAD)
222
220
 
223
- if echo "$FIRST_COMMIT" | grep -qE '^[a-z]+(\([a-z0-9-]+\))?:'; then
221
+ if grep -qE '^[a-z]+(\([a-z0-9-]+\))?:' <<<"$FIRST_COMMIT"; then
224
222
  TYPE=$(echo "$FIRST_COMMIT" | grep -oE '^[a-z]+')
225
223
  SCOPE=$(echo "$FIRST_COMMIT" | grep -oE '\([a-z0-9-]+\)' | tr -d '()' || echo "")
226
224
 
@@ -256,9 +254,13 @@ else
256
254
  fi
257
255
  echo ""
258
256
 
259
- # Check for breaking changes in commits
257
+ # Check for breaking changes in commits. Capture git log output first and
258
+ # match with a here-string, not `git log | grep -q`: under pipefail the
259
+ # early-exiting grep SIGPIPEs git once the log exceeds the pipe buffer and a
260
+ # present BREAKING CHANGE reads as absent (YAN-1587).
261
+ COMMIT_MESSAGES=$(git log --format=%B "$MERGE_BASE..HEAD")
260
262
  echo -e "${GREEN}Breaking Changes:${NC}"
261
- if git log --format=%B "$MERGE_BASE..HEAD" | grep -qE 'BREAKING CHANGE:|^[a-z]+(\([a-z0-9-]+\))?!:'; then
263
+ if grep -qE 'BREAKING CHANGE:|^[a-z]+(\([a-z0-9-]+\))?!:' <<<"$COMMIT_MESSAGES"; then
262
264
  echo " ⚠ Breaking changes detected in commits"
263
265
  { git log --format=%s "$MERGE_BASE..HEAD" | grep -E '^[a-z]+(\([a-z0-9-]+\))?!:' || true; } | while IFS= read -r line; do
264
266
  echo " - $line"
@@ -335,6 +337,49 @@ else
335
337
  echo ""
336
338
  fi
337
339
 
340
+ # Related issues: Linear branch hints and commit keys from the shared helper,
341
+ # filtered by ARTIFACT_LINEAR_TEAM, plus GitHub issues referenced in commits.
342
+ # See _shared/references/artifact-store.md "PR linking". Missing or failing
343
+ # helpers never prevent PR creation; session-aware plan links are added by callers.
344
+ LINEAR_KEYS_SCRIPT="${SCRIPT_DIR}/../../../shared/scripts/collect-linear-keys.sh"
345
+ RESOLVE_STORE_SCRIPT="${SCRIPT_DIR}/../../../shared/scripts/resolve-artifact-store.sh"
346
+
347
+ LINEAR_TEAM="${ARTIFACT_LINEAR_TEAM:-}"
348
+ if [ -z "$LINEAR_TEAM" ] && [ -f "$RESOLVE_STORE_SCRIPT" ]; then
349
+ LINEAR_TEAM=$(bash "$RESOLVE_STORE_SCRIPT" --shell 2>/dev/null | awk '
350
+ /^ARTIFACT_LINEAR_TEAM=/ { sub(/^ARTIFACT_LINEAR_TEAM=/, ""); if ($0 != "\047\047") print }
351
+ ' || true)
352
+ fi
353
+
354
+ RELATED_ISSUES=""
355
+ if [ -f "$LINEAR_KEYS_SCRIPT" ]; then
356
+ if [ -n "$LINEAR_TEAM" ]; then
357
+ while IFS=$'\t' read -r LINEAR_KEY _LINEAR_SRC LINEAR_ACTION; do
358
+ [ -n "$LINEAR_KEY" ] || continue
359
+ case "$LINEAR_ACTION" in
360
+ closes) LINEAR_VERB=Closes ;;
361
+ refs) LINEAR_VERB=Refs ;;
362
+ *) continue ;;
363
+ esac
364
+ RELATED_ISSUES="${RELATED_ISSUES:+${RELATED_ISSUES}
365
+ }${LINEAR_VERB} ${LINEAR_KEY}"
366
+ done <<<"$LINEAR_KEYS_OUT"
367
+ elif [ -n "$LINEAR_KEYS_OUT" ]; then
368
+ echo 'Skipping Linear issue links: no ARTIFACT_LINEAR_TEAM configured and no Linear MCP to verify keys.' >&2
369
+ fi
370
+ fi
371
+
372
+ # GitHub issues referenced in commit messages (Closes/Fixes/Resolves #n).
373
+ GH_REFS=$(grep -oiE '(closes|fixes|resolves) #[0-9]+' <<<"$COMMIT_MESSAGES" 2>/dev/null | grep -oE '#[0-9]+' | awk '!seen[$0]++' || true)
374
+ while IFS= read -r GH_REF; do
375
+ [ -n "$GH_REF" ] || continue
376
+ RELATED_ISSUES="${RELATED_ISSUES:+${RELATED_ISSUES}
377
+ }Closes ${GH_REF}"
378
+ done <<<"$GH_REFS"
379
+
380
+ # No linked issues: keep the bare placeholder for the author to fill in.
381
+ [ -n "$RELATED_ISSUES" ] || RELATED_ISSUES="Closes #"
382
+
338
383
  # Create description based on commits
339
384
  PR_DESCRIPTION="## Summary
340
385
 
@@ -375,7 +420,7 @@ PR_DESCRIPTION="${PR_DESCRIPTION}
375
420
 
376
421
  ## Related Issues
377
422
 
378
- Closes #
423
+ ${RELATED_ISSUES}
379
424
 
380
425
  ## Breaking Changes
381
426