@yandy-r/ycc-opencode 6.1.1 → 6.2.1

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 (126) 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/index.js +146 -95
  9. package/package.json +1 -1
  10. package/registration.json +0 -4
  11. package/shared/references/artifact-store.md +613 -0
  12. package/shared/references/branch-prep.md +2 -0
  13. package/shared/references/forge-detection.md +3 -2
  14. package/shared/references/review-artifact-format.md +13 -6
  15. package/shared/references/review-checklist.md +3 -2
  16. package/shared/references/review-dispatch.md +15 -10
  17. package/shared/references/target-capability-matrix.md +140 -32
  18. package/shared/references/visual-mode.md +19 -13
  19. package/shared/references/worktree-strategy.md +12 -8
  20. package/shared/scripts/artifact-body.sh +71 -0
  21. package/shared/scripts/artifact-store-pointer.sh +245 -0
  22. package/shared/scripts/ci-monitor.sh +9 -4
  23. package/shared/scripts/collect-linear-keys.sh +77 -0
  24. package/shared/scripts/lib/ci-classify.sh +13 -10
  25. package/shared/scripts/lib/forge.sh +13 -4
  26. package/shared/scripts/prepare-feature-branch.sh +118 -10
  27. package/shared/scripts/release-ci-monitor.sh +2 -2
  28. package/shared/scripts/report-bundle-drift.sh +1 -1
  29. package/shared/scripts/resolve-artifact-store.sh +636 -0
  30. package/shared/scripts/validate-file-paths.sh +11 -4
  31. package/skills/blueprint/SKILL.md +48 -13
  32. package/skills/bundle-release/scripts/draft-notes.sh +1 -1
  33. package/skills/bundle-release/scripts/release_versions.py +9 -1
  34. package/skills/clean/SKILL.md +1 -1
  35. package/skills/clean/scripts/detect-project-type.sh +2 -2
  36. package/skills/clean/scripts/generate-report.sh +34 -5
  37. package/skills/clean/scripts/validate-safety.sh +9 -6
  38. package/skills/code-report/SKILL.md +26 -14
  39. package/skills/code-report/scripts/check-prerequisites.sh +72 -12
  40. package/skills/code-report/templates/report-structure.md +1 -1
  41. package/skills/code-review/SKILL.md +68 -17
  42. package/skills/code-review/references/pr-procedure.md +28 -15
  43. package/skills/compatibility-audit/SKILL.md +10 -5
  44. package/skills/compatibility-audit/references/reading-the-report.md +4 -1
  45. package/skills/compatibility-audit/scripts/audit-install-assumptions.sh +64 -7
  46. package/skills/compatibility-audit/scripts/audit-target-features.sh +13 -10
  47. package/skills/deep-research/SKILL.md +28 -5
  48. package/skills/deep-research/references/completion-summary-template.md +3 -2
  49. package/skills/deep-research/scripts/validate-research.sh +8 -2
  50. package/skills/feature-research/SKILL.md +48 -25
  51. package/skills/feature-research/scripts/validate-research.sh +51 -12
  52. package/skills/feature-research/scripts/validate-spec.sh +53 -22
  53. package/skills/feature-research/templates/research-agents.md +15 -14
  54. package/skills/feature-research/templates/spec-structure.md +5 -0
  55. package/skills/formatters/scripts/apply-aliases.sh +3 -1
  56. package/skills/formatters/scripts/apply-ci.sh +3 -1
  57. package/skills/git-workflow/SKILL.md +2 -1
  58. package/skills/git-workflow/references/pr-creation.md +10 -0
  59. package/skills/git-workflow/scripts/analyze-changes.sh +21 -11
  60. package/skills/git-workflow/scripts/create-pr.sh +51 -6
  61. package/skills/git-workflow/scripts/validate-commit.sh +26 -14
  62. package/skills/hooks-workflow/scripts/verify-hooks.sh +1 -1
  63. package/skills/implement-plan/SKILL.md +35 -16
  64. package/skills/implement-plan/references/agent-task-prompt.md +8 -5
  65. package/skills/implement-plan/references/linear-sync.md +20 -0
  66. package/skills/implement-plan/references/output-formats.md +17 -2
  67. package/skills/implement-plan/references/plan-inputs.md +23 -4
  68. package/skills/implement-plan/scripts/check-prerequisites.sh +95 -49
  69. package/skills/implement-plan/scripts/parse-dependencies.sh +10 -10
  70. package/skills/init/SKILL.md +77 -42
  71. package/skills/init/references/flag-reference.md +41 -17
  72. package/skills/init/references/project-profile-heuristics.md +3 -0
  73. package/skills/init/references/template-library.md +15 -5
  74. package/skills/init/scripts/profile-project.sh +26 -0
  75. package/skills/init/scripts/render-template.py +2 -2
  76. package/skills/init/templates/AGENTS.md.tmpl +6 -0
  77. package/skills/init/templates/git/gitignore.tmpl +5 -0
  78. package/skills/orchestrate/SKILL.md +17 -2
  79. package/skills/parallel-plan/SKILL.md +14 -8
  80. package/skills/plan/SKILL.md +18 -2
  81. package/skills/plan/references/planning-tracks.md +1 -1
  82. package/skills/plan-workflow/SKILL.md +67 -32
  83. package/skills/plan-workflow/references/checkpoint-messages.md +23 -14
  84. package/skills/plan-workflow/references/plan-structure.md +1 -1
  85. package/skills/plan-workflow/references/planning-agents.md +11 -9
  86. package/skills/plan-workflow/references/research-agents-optimized.md +12 -10
  87. package/skills/plan-workflow/references/research-agents.md +11 -10
  88. package/skills/plan-workflow/scripts/check-prerequisites.sh +50 -11
  89. package/skills/plan-workflow/scripts/check-state.sh +53 -9
  90. package/skills/plan-workflow/scripts/persist-or-fail.sh +21 -7
  91. package/skills/plan-workflow/scripts/validate-analysis-artifacts.sh +28 -14
  92. package/skills/plan-workflow/scripts/validate-research-artifacts.sh +35 -10
  93. package/skills/plan-workflow/scripts/validate-shared.sh +56 -15
  94. package/skills/plan-workflow/scripts/validate-workflow-plan.sh +48 -17
  95. package/skills/pr-autofix/SKILL.md +19 -4
  96. package/skills/pr-autofix/references/output-templates.md +3 -2
  97. package/skills/pr-autofix/scripts/fetch-pr-comments.sh +1 -2
  98. package/skills/pr-autofix/scripts/post-summary.sh +1 -2
  99. package/skills/pr-autofix/scripts/resolve-thread.sh +3 -4
  100. package/skills/prp-implement/SKILL.md +31 -16
  101. package/skills/prp-implement/references/agent-task-prompt.md +5 -2
  102. package/skills/prp-implement/references/detection.md +4 -1
  103. package/skills/prp-implement/references/linear-sync.md +25 -0
  104. package/skills/prp-implement/references/report-output.md +15 -2
  105. package/skills/prp-plan/SKILL.md +62 -30
  106. package/skills/prp-plan/references/enhanced-researchers.md +8 -9
  107. package/skills/prp-plan/scripts/validate-prp-plan.sh +42 -18
  108. package/skills/prp-pr/SKILL.md +14 -1
  109. package/skills/prp-prd/SKILL.md +21 -9
  110. package/skills/prp-spec/SKILL.md +30 -20
  111. package/skills/quick-fix/SKILL.md +6 -4
  112. package/skills/quick-review/SKILL.md +62 -25
  113. package/skills/release-model/scripts/collect-signals.sh +9 -3
  114. package/skills/releaser/scripts/publish-release.sh +6 -3
  115. package/skills/research-to-issues/SKILL.md +33 -14
  116. package/skills/research-to-issues/scripts/validate-prerequisites.sh +45 -23
  117. package/skills/research-to-issues/templates/task-issue.md +4 -0
  118. package/skills/research-to-issues/templates/tracking-issue.md +3 -0
  119. package/skills/review-fix/SKILL.md +96 -14
  120. package/skills/review-fix/references/fix-report.md +10 -10
  121. package/skills/review-fix/references/plan.md +5 -2
  122. package/skills/shared-context/SKILL.md +14 -11
  123. package/skills/visual-plan/SKILL.md +26 -8
  124. package/skills/visual-recap/SKILL.md +1 -1
  125. package/skills/write-docs/scripts/audit-documentation.sh +44 -10
  126. package/skills/write-docs/scripts/generate-doc-index.sh +10 -3
@@ -0,0 +1,613 @@
1
+ # Artifact Store — Canonical Reference
2
+
3
+ ## Contents
4
+
5
+ - Status
6
+ - Kinds
7
+ - Planning skills
8
+ - Implementation skills
9
+ - Review and report skills
10
+ - PR linking
11
+ - Layout
12
+ - Frontmatter
13
+ - Sync
14
+ - Store resolution
15
+ - Helper API
16
+ - Repository mapping
17
+ - Worktrees
18
+ - Gitignore
19
+ - Fresh clone
20
+ - Lookup
21
+ - Local mode
22
+ - Size and diagrams
23
+
24
+ Single source of truth for where planning artifacts live and how skills save, load, and sync them. The shell helper resolves config and paths only. Linear MCP calls live in skill bodies, never in the helper.
25
+
26
+ Shared script:
27
+
28
+ ```bash
29
+ {{package-root}}/shared/scripts/resolve-artifact-store.sh
30
+ ```
31
+
32
+ It sources `resolve-plans-dir.sh` from its own directory. Sourcing resolves from the current directory; an explicit `resolve_artifact_store <dir>` re-exports `PLANS_DIR` and `PLANS_ROOT` for that directory as well as the `ARTIFACT_*` variables.
33
+
34
+ ## Status
35
+
36
+ Planning artifacts default to Linear storage. Local mode keeps the existing local paths; see Store resolution for opting out.
37
+
38
+ | Piece | Issue | State |
39
+ | ------------------------------------------- | -------- | -------------- |
40
+ | `resolve-artifact-store.sh` | YAN-1153 | Shipped |
41
+ | This reference | YAN-1152 | Shipped |
42
+ | Planning skills and validators | YAN-1154 | Migrated |
43
+ | Implementation skills and validators | YAN-1155 | Migrated |
44
+ | Review and report skills | YAN-1156 | Migrated |
45
+ | Generators, capability matrix, `init` | YAN-1157 | Shipped |
46
+ | Existing `docs/plans` and `docs/prps` trees | YAN-1158 | Leave in place |
47
+
48
+ ## Kinds
49
+
50
+ | Kind | Linear object | Cache file |
51
+ | ------------------------------ | ------------------------------------------------------------------- | ------------------------------- |
52
+ | prd | Document on the feature Project | `prd.md` |
53
+ | feature-research spec | Document on the feature Project | `feature-spec.md` |
54
+ | prp-spec | Document on the feature Project | `spec.md` |
55
+ | research | One Document per lens on the feature Project | `research/research-<lens>.md` |
56
+ | shared-context | Document on the feature Project | `shared.md` |
57
+ | plan-workflow / parallel-plan | Document, plus one Issue per task | `parallel-plan.md` |
58
+ | prp-plan / `plan --visual` | Document, plus one Issue per task | `prp-plan.md` |
59
+ | review | One Document per review, attached to the issue or feature Project | `reviews/<review-id>-review.md` |
60
+ | review-fixes | Document beside its review, with the same parent | `reviews/<review-id>-fixes.md` |
61
+ | report | Project status update, plus a Document when long | `report.md` |
62
+ | code-report | Document on the feature Project | `code-report.md` |
63
+ | pr-autofix-report | Local-only scratch; never pushed | `reports/pr-autofix-<id>.md` |
64
+ | analysis | Local-only scratch; never pushed | `analysis-*.md` |
65
+ | prp-plan research backstop | Local-only scratch; never pushed | `.prp-research/<role>.md` |
66
+ | blueprint | Document on the feature Project | `blueprint.md` |
67
+ | deep-research | Final report as research lens `deep-research`; scratch never pushed | `deep-research/` (scratch) |
68
+ | visual-recap | None: local-only by its privacy rule, outside the store | Its own local path |
69
+ | save-session / resume-session | None: user-global `~/.config/opencode/session-data/`, not a repo artifact | None |
70
+
71
+ Document titles are `<slug> · <kind>`. `<kind>` is the cache filename stem, omitting the conventional `research/` and `reviews/` directories: `shared` → `shared.md`, `parallel-plan` → `parallel-plan.md`, `prp-plan` → `prp-plan.md`, `feature-spec` → `feature-spec.md`, `report` → `report.md`, `code-report` → `code-report.md`, `research-<lens>` → `research/research-<lens>.md`, `<pr-N|local-<stamp>|quick-<stamp>>-review` → the matching `reviews/<review-id>-review.md`, and `<review-id>-fixes` → `reviews/<review-id>-fixes.md`. `prd` and `spec` map to their same-named files. Load maps that title suffix back to the cache filename. Each split part uses `<basename>-part-N` as its kind and filename stem.
72
+
73
+ Review routing, parents, and local-only kinds: see Review and report skills.
74
+
75
+ `prp-implement` `{plan}-report.md` (kind `prp-report`) and `implement-plan` (kind `report`) share the `report.md` cache file. Local mode resolves `prp-report` to `docs/prps/reports/<slug>-report.md` under the current checkout and `report` to `<PLANS_DIR>/<slug>/report.md`; linear mode resolves both to `.ycc/artifacts/<slug>/report.md`. Store the status-update id in `linear.statusUpdate`; a long report also has `linear.document`.
76
+
77
+ `code-report` uses its own kind `code-report` so it never replaces that run report, its `pending` sync record, or its status update. Local mode keeps `<PLANS_DIR>/<slug>/report.md`, as before; linear mode resolves `.ycc/artifacts/<slug>/code-report.md`, saved as Document `<slug> · code-report` on the feature Project. It never sets or changes `linear.statusUpdate`.
78
+
79
+ ### Plan task issues
80
+
81
+ - Plan tasks are sub-issues of one parent tracking issue. Use the verified branch-hint issue as parent when present; otherwise create one in the feature Project.
82
+ - `tasks` maps the literal task heading id (`1.1`, `Task 1`) to its Linear issue id. Warn that renumbering headings remaps ids and can associate issues with different tasks.
83
+ - The plan owns only each task issue's title, description, and `blocks` relations. Relations mirror dependency batches.
84
+ - Re-save updates mapped issues, creates only new task ids, and rebuilds a missing map from existing sub-issues by literal heading id before creating anything.
85
+ - Before updating a task issue, fetch its `updatedAt` and compare it with the timestamp stored under `tasks`. A mismatch, or no stored timestamp for an existing mapped issue, means Linear changed independently: skip the update and report it, or run Conflict. Never overwrite without resolving that state. After each successful update, re-stamp that task's `updatedAt`.
86
+ - Planning saves never change issue state except to cancel an **open** issue whose task was removed. Never cancel a Done or already-cancelled issue, and never delete an issue. Implementation skills move states only as in Implementation skills > Status sync.
87
+
88
+ ## Planning skills
89
+
90
+ Planning skills resolve artifact paths with the helper rather than constructing cache paths themselves. Shell state does not persist between tool calls; retain the printed mode and resolved absolute paths. Parse and strip any `--store=local|linear` flag first, retain it as `STORE_FLAG` (empty when absent), and pass `${STORE_FLAG}` to every resolver call.
91
+
92
+ 1. Resolve and **print** the mode; read `ARTIFACT_STORE=` from stdout:
93
+
94
+ ```bash
95
+ bash "{{package-root}}/shared/scripts/resolve-artifact-store.sh" ${STORE_FLAG} --shell
96
+ ```
97
+
98
+ 2. In linear mode only, apply the **Linear call gate** below before any write or `--ensure`. Dry runs stop before this step and only resolve paths without `--ensure`.
99
+ 3. Once writing is permitted, resolve the destination:
100
+
101
+ ```bash
102
+ OUT="$(bash "{{package-root}}/shared/scripts/resolve-artifact-store.sh" ${STORE_FLAG} --ensure --kind=<kind> --slug=<slug>)"
103
+ ```
104
+
105
+ In local mode, write `$OUT` at the existing local path, without identity frontmatter or Linear calls. In linear mode (the default), prepare identity as described below before writing, then Save.
106
+
107
+ | Skill | Kind or path operation |
108
+ | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
109
+ | `prp-prd` | `prd` |
110
+ | `prp-spec` | `spec` |
111
+ | `prp-plan` | `prp-plan`; research backstops use `prp-research` and remain local-only |
112
+ | `plan --visual` | Forced source plan uses `prp-plan` |
113
+ | `plan-workflow` | Research uses `research-<lens>`, shared context uses `shared`, analysis uses `analysis-<name>`, and the final plan uses `parallel-plan` |
114
+ | `parallel-plan` | `parallel-plan`; prerequisites use the same research/shared/analysis kinds as `plan-workflow` |
115
+ | `shared-context` | `shared`, with `research-<lens>` inputs |
116
+ | `feature-research` | `feature-spec` plus one `research-<lens>` document per research lens |
117
+ | `deep-research` | Linear working tree uses `deep-research`; save its final `report.md` as `research-deep-research` |
118
+ | `blueprint` | `blueprint`; derive the slug from `git rev-parse --path-format=absolute --git-common-dir`: its parent's basename when it is named `.git`, else its own basename minus `.git` (bare repo or submodule), else the current directory name outside Git; lowercase and sanitize it |
119
+ | `visual-plan` | Reads the caller-selected `prp-plan` or `parallel-plan`; generated visual files follow Size and diagrams and are not uploaded |
120
+
121
+ `get_artifact_path <kind> <slug>` prints an absolute path without creating anything. Its `--kind=... --slug=...` CLI form requires both options. With a kind and slug, `--ensure` in linear mode calls `ensure_artifact_dir` to create the cache base and repository gitignore rule; in local mode it creates only the returned file's parent directory (or the returned directory for directory kinds), never an unrelated `PLANS_DIR`. Without a kind, `--ensure` retains the `ensure_artifact_dir` behavior below. Repo-level local kinds `prd`, `spec`, `prp-plan`, `prp-research`, `blueprint`, and the review and pr-autofix kinds resolve under the current checkout's physical git toplevel, or the physical start directory outside git; feature kinds retain `PLANS_DIR`. Create any needed parent directory for the returned file when writing. An explicit deep-research `--output-dir` always wins. Local deep-research keeps `research/<subject>` and does not call `get_artifact_path deep-research`; its linear final Document is `<slug> · research-deep-research`, cached as `research/research-deep-research.md`.
122
+
123
+ For each uploaded planning document in linear mode:
124
+
125
+ 1. Resolve the feature Project, apply the Linear call gate, and run `--ensure` before any cache write or pull. Read cached identity. If no `linear.document` identity exists (or a plan has no `tasks` identity), run Lookup steps 3–6 now, before writing; on a hit, Load the object first and preserve its identity so the new body replaces it through Conflict rather than creating a duplicate.
126
+ 2. Write the body at the resolved path, preserving existing identity and non-identity frontmatter.
127
+ 3. Run Save from the Sync section, including Lookup whenever document/task identity is missing and Conflict when remote state differs. Use Document title `<slug> · <kind>`.
128
+ 4. For `prp-plan` and `parallel-plan`, also apply Plan task issues: create or update task sub-issues under the parent tracking issue and set `blocks` relations to mirror dependency batches and task dependencies. Keep task issue state and timestamp handling unchanged from that protocol.
129
+ 5. Push only uploaded kinds. Analysis files, PRP research backstops, deep-research scratch, and visual output remain local-only.
130
+
131
+ Validators inspect content through `artifact_body` so leading identity frontmatter cannot satisfy or hide body headings. Research lookup uses `<feature>/research/` when that directory exists and `<feature>/` otherwise. Local mode retains the flat research filenames; linear mode writes them under `research/`.
132
+
133
+ Linear planning artifacts belong to the current worktree's `.ycc/artifacts/` cache. Do not move them between worktrees; Load pulls remote changes into a clean cache. Local mode retains the existing committed-docs worktree behavior.
134
+
135
+ Completion messages in linear mode print the implementation command with the feature slug or the cached plan path; see Implementation skills.
136
+
137
+ ## Implementation skills
138
+
139
+ `implement-plan`, `prp-implement` and `orchestrate` consume planning artifacts through this store. The orchestrating skill alone talks to Linear; implementor subagents (`implementor`) read the hydrated cache file and never call a Linear MCP, tracker tool, or edit the plan or its frontmatter.
140
+
141
+ ### Inputs
142
+
143
+ Each skill accepts, in addition to today's input (feature name, plan path, task description):
144
+
145
+ - `--store=local|linear`, parsed, stripped and forwarded to every resolver call exactly as in Planning skills.
146
+ - A Linear reference: an issue key matching `^[A-Z][A-Z0-9]{1,9}-[0-9]+$` exactly (uppercase; when `ARTIFACT_LINEAR_TEAM` is set its prefix must equal that team), or a `linear.app` issue, Project or Document URL. A bare Project slug or Document id counts as a reference only with an explicit `--store=linear`.
147
+ - A path to a cached plan. A file is a linear plan when it lies under `${ARTIFACT_ROOT}/.ycc/artifacts/` or its leading frontmatter has a `linear:` block or `pending: true`; any other path keeps local behavior unchanged and is never treated as a reference.
148
+
149
+ A Linear reference or a linear plan path selects linear mode for the run: when `STORE_FLAG` is empty, set `STORE_FLAG=--store=linear` before the first resolver call and forward it to every later call. Combined with `--store=local`, abort with: `A Linear plan reference requires linear mode; drop --store=local.` Anything else (a feature name such as `oauth-2`, a local plan path) follows normal Store resolution, and an existing local `${PLANS_DIR}/<name>/` wins over reference parsing. Local mode keeps today's behavior byte-for-byte: same paths, archive, report, no Linear calls.
150
+
151
+ Existing local plans keep local mode. When `STORE_FLAG` is empty and the printed `ARTIFACT_STORE_SOURCE=default`, set `STORE_FLAG=--store=local` (and forward it) if the input is a plan path that is not a linear plan path, or if `"$(resolve-artifact-store.sh --store=local)/<name>/"` already exists. Print one line: `Using local plan at <path>; pin with store: local in .plans-config`.
152
+
153
+ ### Resolve and hydrate
154
+
155
+ In linear mode, before Git branch preparation:
156
+
157
+ 1. Resolve and print the mode (`--shell`), then apply the Linear call gate. A missing or unauthorized MCP stops the run with the gate message; there is no local fallback for a plan that exists only in Linear.
158
+ 2. Run Lookup for the plan kind (`parallel-plan` for `implement-plan`, `prp-plan` for `prp-implement`). Map the hit to a slug: the Document title prefix before `·`, else the feature Project name. An issue reference with sub-issues is the parent tracking issue; any other issue resolves through its parent. Either way the run covers the whole plan. Lookup step 7 asks; never report "no plan" before querying Linear.
159
+ 3. Hydrate once with Load into the current checkout's cache: `--ensure --kind=<kind> --slug=<slug>`, then pull the Document body and stamp identity. `implement-plan` also hydrates `shared` when that Document exists; a missing `shared` Document is a warning, like a missing local `shared.md`. Load's Conflict rule applies; never overwrite unpushed local edits.
160
+ 4. Use the absolute cache path as `PLAN_PATH` for parsing, prompts and validation. Linear-mode plans are never moved into the feature worktree (`move-plan-to-worktree.sh` is skipped); worktree tasks read the plan by absolute path. Derive `WT_FEATURE_SLUG` (and any team context) from the cache slug, never from the cache basename, sanitized for branch preparation: lowercase, replace `[^a-z0-9-]` with `-`, collapse runs, trim `-`, truncate to 40 characters. Resolver calls keep the unsanitized cache slug. The cache itself is gitignored; the only dirty path `--ensure` can leave is a `.gitignore` (at `ARTIFACT_ROOT`, which may be a package directory) whose sole change appends one `.ycc/artifacts/` rule line, possibly after a missing final newline, even when the committed file already has the rule; branch preparation accepts exactly that change, in the working tree, the index, or both (the working tree may match as raw bytes or, under `core.autocrlf` or `eol=crlf`, after Git turns its CRLF into LF), and carries it onto the feature branch.
161
+ 5. Read the `tasks` map from the plan's frontmatter. If it is missing, rebuild it in memory from the parent tracking issue's sub-issues by literal task heading id, as in Plan task issues, without creating issues or writing the map to the cache. A task with no issue still runs; list it as untracked in the report and suggest re-saving the plan with its planning skill.
162
+
163
+ ### Status sync
164
+
165
+ The orchestrator moves issues by state type, not team-specific state names:
166
+
167
+ | When | Change |
168
+ | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
169
+ | Run starts: immediately before the first dispatch | Replay pending transitions first (below). Parent tracking issue → `started` when `backlog`, `unstarted` or `triage`; Project → `started` when `backlog` or `planned` |
170
+ | Before a task or batch dispatches | Each task issue in it → `started` when `backlog`, `unstarted` or `triage` |
171
+ | Task passes its validation | Task issue → `completed`. `prp-implement` parallel runs mark a batch's issues after its between-batch checks pass |
172
+ | Task or batch fails | Leave the issue `started`; add one comment with the task id, the failing check and a short excerpt. Never paste secrets or full logs |
173
+ | All tasks pass final validation | Parent tracking issue → `completed`; post the report (below) |
174
+
175
+ - A task whose issue is already `completed` is treated as done and skipped, so a re-run resumes; a `canceled` issue's task is skipped as removed. Print both in the summary.
176
+ - Never move an issue backwards, reopen it, change its assignee, or touch issues outside the plan's `tasks` map and parent.
177
+ - Timestamps: before a transition or comment, fetch the issue's `updatedAt`. If it equals the stored `tasks.<id>.updatedAt`, re-stamp it from the response afterwards so a later planning re-save does not mistake the transition for an independent edit. If it differs, or no stamp is stored, apply the transition but leave the stored stamp unchanged so planning still sees the independent edit. Identity keys are outside `contentHash`, so re-stamping never marks the body dirty.
178
+ - `--dry-run` makes no Linear writes and no local writes: no `--ensure`, no cache write, no Load push or Conflict, and no branch or worktree preparation. It may run Lookup, reuse an existing cache file read-only, or parse a fetched body from a temporary file outside the repository, which then serves as `PLAN_PATH` for the dry-run output.
179
+
180
+ ### Report and completion
181
+
182
+ - Write the run report to kind `prp-report` (`prp-implement`) or `report` (`implement-plan`, `orchestrate` with a Project) and Save it on success and failure alike: one Project status update with health `onTrack` when every task passed and `atRisk` otherwise, plus a Document when the report exceeds the status-update size. Record `linear.statusUpdate`.
183
+ - Linear mode replaces `prp-implement`'s archive move. Instead, close the issues as above and complete the Project only when its name equals the plan slug, it carries `ARTIFACT_LINEAR_LABEL` when one is set, it is not `ARTIFACT_LINEAR_PROJECT`, and every issue in it is `completed` or `canceled`. Otherwise leave the Project open and say why.
184
+ - The Goal Signal `PLAN_ARCHIVED` keeps its name. Local mode: the plan moved to `completed/`. Linear mode: the parent tracking issue and every tracked task issue are `completed` (or `canceled`) and the Project status update was posted.
185
+ - If the MCP becomes unreachable mid-run, keep implementing. At the moment a transition fails, resolve the report path with `--ensure`, append the transition under `## Linear sync pending` in that file and set its `pending: true`, so an interrupted run still leaves the record; the final report merges into the same file. Print the list at the end. The next run on the same plan replays the pending transitions before dispatching, following Offline, and removes each one it applies.
186
+
187
+ ### Orchestrate
188
+
189
+ `orchestrate` builds its own decomposition. Its Linear behavior applies only when its input is a Linear issue reference (a `store: linear` config alone changes nothing): it reads that issue's title, description and sub-issues as the task description before deriving any slug, moves the issue to `started` immediately before the first dispatch, comments on failure, saves a `report` when the issue has a Project (on success and failure), and marks the issue `completed` only when the run's final verification passes. `--plan-only` keeps writing `docs/orchestration/`; that path is not an artifact-store kind.
190
+
191
+ ## Review and report skills
192
+
193
+ These skills follow Planning skills for `STORE_FLAG`, printing the mode, the Linear call gate, and `--ensure`, and resolve every path with the helper. Exception: local-only kinds (`pr-autofix-report-<id>`) make no Linear calls and therefore skip the Linear call gate; they still print the mode. `<N>` is a PR number ≥ 1; the helper rejects any other id. Local mode keeps today's paths and commits, anchored at the checkout toplevel even when run from a subdirectory; printed local paths and `/ycc:review-fix` commands use the toplevel-relative form (`docs/prps/...`), as before.
194
+
195
+ | Kind | Id | Linear cache | Local path |
196
+ | ------------------------ | -------------------------------------------------------------- | ----------------------------------- | --------------------------------------- |
197
+ | `review-<id>` | `pr-<N>`, `local-<YYYYMMDD-HHMMSS>`, `quick-<YYYYMMDD-HHMMSS>` | `<slug>/reviews/<id>-review.md` | `docs/prps/reviews/<id>-review.md` |
198
+ | `review-fixes-<id>` | Same as `review-<id>` | `<slug>/reviews/<id>-fixes.md` | `docs/prps/reviews/fixes/<id>-fixes.md` |
199
+ | `pr-autofix-report-<id>` | `<N>-<YYYY-MM-DD>T<HHMMSS>Z` | `<slug>/reports/pr-autofix-<id>.md` | `docs/prps/reports/pr-autofix-<id>.md` |
200
+
201
+ Local paths resolve under the start directory's checkout (`ARTIFACT_REPO_ROOT`), so pass the reviewed worktree as start-dir. In local mode the slug is validated but does not affect the path.
202
+
203
+ ### Reviews
204
+
205
+ - `code-review` (local and PR) and `quick-review` (`Save to file`, `Write file and apply fixes`) write kind `review-<id>`. Slug: Slugs rules 2–5; reviews have no feature name. A PR review takes its hint from the PR, never the local branch: the `headRefName` key (Branch hint rules), else a `Closes|Fixes|Resolves <KEY>` in the PR body (Lookup step 4); with neither, skip rules 2–3 and sanitize `headRefName` for rule 4.
206
+ - Linear: Save one Document `<slug> · <id>-review`. Parent: the verified PR-derived hint issue (local reviews: `ARTIFACT_LINEAR_HINT`) or cached `linear.issue`, recorded in `linear.issue`; else the feature Project; else keep the review local only with no push.
207
+ - The GitHub PR review comment is unchanged. Linear-mode reviews are gitignored cache; never commit them to the PR branch. Rule-only `.gitignore` check: run `git -C "$(git -C <checkout> rev-parse --show-toplevel)" status --porcelain -- .gitignore`; it holds when the status is `??` and the file's content is exactly `.ycc/artifacts/`, or status `M` (modified) and `git diff` of that file adds only the `.ycc/artifacts/` line. When it holds after `--ensure`, print a note naming `<checkout>/.gitignore` and tell the user to leave it out of PR commits and to commit fixes by explicit path, never `git add -A`.
208
+ - Linear `--ensure` creates only the cache root and its ignore rule; create the file's parent with `mkdir -p "$(dirname "$OUT")"` before writing.
209
+ - Scratch: `.review-scratch/<run-id>/` beside the resolved file (`$(dirname "$OUT")/.review-scratch/<run-id>/`, created with `mkdir -p`); local mode keeps `docs/prps/reviews/.review-scratch/<run-id>/`. Never pushed. Fan-out that runs before the gate and `--ensure` (quick-review) keeps linear-mode scratch outside the repository in `mktemp -d`.
210
+
211
+ ### Review fixes
212
+
213
+ `review-fix` resolves its input (`quick-fix` is artifact-free and never touches the store):
214
+
215
+ 1. A path ending `.md`: relative paths resolve against the current directory, then the checkout toplevel.
216
+ 2. Digits `N`: kind `review-pr-N` in the current mode. Linear: the current checkout cache, then the main checkout cache; if missing, Lookup and Load Document `<slug> · pr-N-review`, scoped to this repository: first the issue named by the PR (`headRefName` key, else a `Closes|Fixes|Resolves <KEY>` in its body) and that issue's Documents, then this repository's Projects (Lookup step 5), asking when neither yields it. Check the review's `**Branch**` head against the PR's `headRefName` before applying it.
217
+ 3. Blank: the newest `*-review.md` by mtime in the mode's review location (linear: `.ycc/artifacts/*/reviews/`), current checkout first, then the main checkout.
218
+
219
+ Existing local reviews keep local mode. When `STORE_FLAG` is empty and the printed `ARTIFACT_STORE_SOURCE=default`, set `STORE_FLAG=--store=local` (and forward it) if the input is a `.md` path that is not a linear review (not under `.ycc/artifacts/`, no leading `linear:` block), digits `N` whose `docs/prps/reviews/pr-<N>-review.md` exists and is newer by mtime than any linear cache `pr-<N>-review.md` in the current or main checkout, or blank input whose newest review lies under `docs/prps/reviews/`. Print one line: `Using local review at <path>; pin with store: local in .plans-config`. An explicit or configured linear mode with a local review path aborts: `A local review requires local mode; use --store=local.` A `--dry-run` reminder names the original selector (`N` or the review path), never a temporary copy.
220
+
221
+ Status edits on a linear review re-run Save for its Document when it has `linear.document` or `pending: true`; a review kept local only is not re-saved. Conflict applies. The fix report uses kind `review-fixes-<id>`, saved as Document `<slug> · <id>-fixes` with the review's parent. Linear mode never commits either file. A review id the helper rejects keeps the pre-store local report path `docs/prps/reviews/fixes/<source-name>-fixes.md`; linear mode aborts before writing.
222
+
223
+ ### Local-only reports
224
+
225
+ - `pr-autofix` writes kind `pr-autofix-report-<id>`: local-only in both modes, never pushed, and not committed in linear mode. It prints the mode and validates `STORE_FLAG` in Phase 0, before any commit or push, and skips the Linear call gate. When its `--ensure` adds the `.ycc/artifacts/` rule, the final output names the `.gitignore` edit. Its `~/.config/opencode/session-data/ci-watch/` audit log is unchanged.
226
+ - `visual-recap` stays outside the store under its privacy rule; its paths are unchanged.
227
+ - `save-session` and `resume-session` use user-global `~/.config/opencode/session-data/`, not a repository artifact; unchanged.
228
+
229
+ ### Research to issues
230
+
231
+ - `research-to-issues` strips `--store` into `STORE_FLAG`. A feature name resolves `parallel-plan`, `prp-plan`, `feature-spec`, or `prd` with `get_artifact_path`, first existing file in that order (the order Lookup uses for a Linear reference). A Linear issue, Project, or Document reference first hydrates the cache with Lookup and Load, as in Implementation skills > Inputs and Resolve and hydrate.
232
+ - It creates GitHub issues only; Linear task issues come from planning Save. When the plan frontmatter has a `tasks` map, each child GitHub issue for a mapped task adds `Refs <KEY>` for its Linear task issue, and the tracking issue references `linear.issue`. It never creates Linear issues.
233
+
234
+ ## PR linking
235
+
236
+ `prp-pr` and `git-workflow` add Linear and GitHub issue links to the PR body's related-issues section:
237
+
238
+ 1. Collect candidates with `collect-linear-keys.sh --base origin/<base>` (always the remote-tracking base, so commits already merged upstream are never scanned). It prints `<KEY>\t<source>\t<closes|refs>`: the branch hint (`branch`, `closes`) and commit keywords (`commit`; `Closes`/`Fixes`/`Resolves` → `closes`, `Refs` → `refs`; a key seen with both keeps `closes`). Also add the `linear.issue` of a linear plan implemented on this branch as `plan`, `closes`: 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/`, checking the current checkout and then the main checkout (parent of `git rev-parse --path-format=absolute --git-common-dir`).
239
+ 2. Verify each key in Linear when a Linear MCP is reachable; drop keys that do not resolve. Without an MCP, keep only keys whose team equals `ARTIFACT_LINEAR_TEAM`; with no team configured, keep none and print `Skipping Linear issue links: no ARTIFACT_LINEAR_TEAM configured and no Linear MCP to verify keys.` only when candidates existed, because unverified branch hints can be false positives (`fix/utf-8-…`).
240
+ 3. Emit `Closes <KEY>-<n>` for each verified `closes` issue and `Refs <KEY>-<n>` for each `refs`-only issue, plus `Closes #<n>` for each GitHub issue attached to a closed Linear issue (Linear attachment URLs `https://github.com/<owner>/<repo>/issues/<n>` matching `origin`) or closed by a commit (`Closes|Fixes|Resolves #<n>`). Never duplicate a line already in the body or template.
241
+ 4. In linear mode, link the Linear Project and plan Document URLs instead of `docs/prps` paths in the artifacts section.
242
+
243
+ This applies in both store modes: linking needs only the hint and, when available, the MCP.
244
+
245
+ ## Layout
246
+
247
+ Linear mode stores a gitignored cache:
248
+
249
+ ```text
250
+ .ycc/artifacts/<feature-slug>/
251
+ ├── prd.md
252
+ ├── feature-spec.md
253
+ ├── spec.md
254
+ ├── prp-plan.md
255
+ ├── parallel-plan.md
256
+ ├── shared.md
257
+ ├── report.md
258
+ ├── analysis-*.md
259
+ ├── reviews/
260
+ │ ├── pr-<N>-review.md
261
+ │ ├── local-<stamp>-review.md
262
+ │ ├── quick-<stamp>-review.md
263
+ │ ├── <review-id>-fixes.md
264
+ │ └── .review-scratch/<run-id>/
265
+ ├── reports/
266
+ │ └── pr-autofix-<id>.md
267
+ ├── research/
268
+ │ ├── research-business.md
269
+ │ ├── research-technical.md
270
+ │ ├── research-ux.md
271
+ │ ├── research-security.md
272
+ │ ├── research-practices.md
273
+ │ ├── research-external.md
274
+ │ ├── research-recommendations.md
275
+ │ └── research-deep-research.md
276
+ ├── blueprint.md
277
+ ├── deep-research/
278
+ │ └── report.md
279
+ └── .prp-research/
280
+ └── <role>.md
281
+
282
+ ```
283
+
284
+ `blueprint.md` is a sibling of `shared.md`. The `deep-research/` directory contains the skill's local-only objective, findings, synthesis, evidence, and working report; only the final report is uploaded as research lens `deep-research`.
285
+
286
+ `plan-workflow` and `parallel-plan` both write `parallel-plan.md`; there is no plan-workflow `plan.md`. `prp-plan` and the forced file from `plan --visual` use `prp-plan.md`. Feature-research and PRP specs remain distinct. Analysis files and PRP research backstops keep their current basenames under the slug directory but are never pushed.
287
+
288
+ | Cache file (linear) | Today's path (local) |
289
+ | ------------------------------------------------------- | --------------------------------------------------------------------- |
290
+ | `.ycc/artifacts/<slug>/prd.md` | `docs/prps/prds/<name>.prd.md` |
291
+ | `.ycc/artifacts/<slug>/feature-spec.md` | `docs/plans/<slug>/feature-spec.md` |
292
+ | `.ycc/artifacts/<slug>/spec.md` | `docs/prps/specs/<name>.spec.md` |
293
+ | `.ycc/artifacts/<slug>/prp-plan.md` | `docs/prps/plans/<name>.plan.md` |
294
+ | `.ycc/artifacts/<slug>/parallel-plan.md` | `docs/plans/<slug>/parallel-plan.md` |
295
+ | `.ycc/artifacts/<slug>/shared.md` | `docs/plans/<slug>/shared.md` |
296
+ | `.ycc/artifacts/<slug>/research/research-<lens>.md` | `docs/plans/<slug>/research-<lens>.md` |
297
+ | `.ycc/artifacts/<slug>/reviews/pr-<N>-review.md` | `docs/prps/reviews/pr-<N>-review.md` |
298
+ | `.ycc/artifacts/<slug>/reviews/local-<stamp>-review.md` | `docs/prps/reviews/local-<stamp>-review.md` |
299
+ | `.ycc/artifacts/<slug>/reviews/quick-<stamp>-review.md` | `docs/prps/reviews/quick-<stamp>-review.md` |
300
+ | `.ycc/artifacts/<slug>/reviews/<review-id>-fixes.md` | `docs/prps/reviews/fixes/<review-id>-fixes.md` |
301
+ | `.ycc/artifacts/<slug>/report.md` | `docs/plans/<slug>/report.md` or `docs/prps/reports/<plan>-report.md` |
302
+ | `.ycc/artifacts/<slug>/reports/pr-autofix-<id>.md` | `docs/prps/reports/pr-autofix-<id>.md` |
303
+ | `.ycc/artifacts/<slug>/analysis-*.md` | `docs/plans/<slug>/analysis-*.md` |
304
+ | `.ycc/artifacts/<slug>/.prp-research/<role>.md` | `docs/prps/plans/.prp-research/<slug>/<role>.md` |
305
+ | `.ycc/artifacts/<slug>/blueprint.md` | `docs/blueprint.md` |
306
+ | `.ycc/artifacts/<slug>/deep-research/` | `research/<subject>/` or the skill's explicit `--output-dir` |
307
+
308
+ ### Slugs
309
+
310
+ 1. Use the skill's feature name when it has one. In particular, `code-report` uses its supplied feature name.
311
+ 2. For an artifact with no feature name, verify `ARTIFACT_LINEAR_HINT` when set and first look for an existing cache directory whose frontmatter `linear.project` matches that issue's Project. Reuse its slug.
312
+ 3. Otherwise use lowercased `ARTIFACT_LINEAR_HINT` when set.
313
+ 4. Otherwise sanitize the branch name: lowercase it, replace `/` and every character outside `[a-z0-9._-]` with `-`, collapse repeated `-`, and trim leading/trailing separators.
314
+ 5. If no valid slug remains, ask the user.
315
+
316
+ `get_feature_artifact_dir` accepts only `^[A-Za-z0-9][A-Za-z0-9._-]*$` and rejects `/` and any `..` path part. This is stricter than `get_feature_plan_dir`; see Local mode for legacy names.
317
+
318
+ ## Frontmatter
319
+
320
+ In linear mode, merge identity keys into existing frontmatter as top-level keys; do not replace other keys or nest them under a namespace. Local mode writes no identity frontmatter.
321
+
322
+ | Field | Meaning |
323
+ | --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
324
+ | `linear.workspace` | Linear workspace slug |
325
+ | `linear.team` | Team key, for example `YAN` |
326
+ | `linear.project` | Feature Project id or slug |
327
+ | `linear.document` | Document id, empty when there is no Document |
328
+ | `linear.issue` | Parent tracking issue, reviewed issue when present, otherwise empty |
329
+ | `linear.statusUpdate` | Report status-update id, empty for other kinds |
330
+ | `tasks` | Literal plan task id → `{issue, updatedAt}` from the last successful sync; only on `parallel-plan.md` and `prp-plan.md` |
331
+ | `syncedAt` | Linear `updatedAt` observed at the last sync, stored verbatim in its ISO-8601 form |
332
+ | `contentHash` | Lowercase hex SHA-256 from the procedure below at the last successful push or pull |
333
+ | `pending` | `true` when a reachable Linear configuration is temporarily unreachable; otherwise omit or set `false` |
334
+
335
+ Compare `updatedAt` with `syncedAt` using **differs from**, not chronological ordering or timestamp normalization.
336
+
337
+ ```yaml
338
+ ---
339
+ title: Artifact store implementation plan
340
+ linear:
341
+ workspace: yandy-r
342
+ team: YAN
343
+ project: artifact-store
344
+ document: 7b1e3c0a-0000-4000-8000-000000000000
345
+ issue: YAN-1152
346
+ statusUpdate:
347
+ tasks:
348
+ '1.1':
349
+ issue: YAN-1153
350
+ updatedAt: '2026-10-26T00:00:00.000Z'
351
+ 'Task 2':
352
+ issue: YAN-1154
353
+ updatedAt: '2026-10-26T00:00:00.000Z'
354
+ syncedAt: '2026-10-26T00:00:00.000Z'
355
+ contentHash: '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'
356
+ pending: false
357
+ ---
358
+ ```
359
+
360
+ ### Body, hash, and push bytes
361
+
362
+ 1. Frontmatter exists only as a block starting with `---` at byte 0 and closed by a later `---` line (ignoring CR on delimiter lines), whose first non-blank line is a top-level YAML key: it matches `^[A-Za-z_][A-Za-z0-9_.-]*:([[:space:]]|$)`. Blank-only blocks also qualify. Leading `#` comment lines may precede that key only when the block also has a top-level identity key (`linear`, `syncedAt`, `contentHash`, `pending`, or `tasks`), so a hand-annotated cache keeps its identity. Otherwise the whole file is body, including a local artifact that opens with a thematic break, a heading, or a URL; a `---` anywhere else is body content.
363
+ 2. Start with the exact file bytes. Remove only the complete top-level `linear`, `syncedAt`, `contentHash`, `pending`, and `tasks` entries from that block. Do not re-serialize YAML or remove other keys.
364
+ 3. Normalize CRLF and CR line endings to LF. Do not trim the result or add/remove its trailing newline; preserve every other byte, including non-identity frontmatter.
365
+ 4. SHA-256 those bytes for `contentHash`. Push the same identity-stripped content to Linear: identity values are never pushed, while non-identity frontmatter remains in the pushed and hashed body. Apply the same procedure after pulls.
366
+
367
+ Validators that inspect headings or body structure must skip frontmatter (`artifact_body`).
368
+
369
+ ## Sync
370
+
371
+ Skills run these procedures; the helper never calls Linear.
372
+
373
+ ### Linear call gate
374
+
375
+ - Before any local write in linear mode, ensure a Linear MCP is installed and authorized. If not, stop and suggest local mode: `--store=local` for this run, `store: local` in the repo `.plans-config`, or `store: local` in `${XDG_CONFIG_HOME:-$HOME/.config}/ycc/config` for every repo. Do not create a cache, `.gitignore`, or perpetual pending file.
376
+ - Before any Linear call, confirm the connected workspace equals `ARTIFACT_LINEAR_WORKSPACE` when set. On mismatch, ask the user before proceeding.
377
+ - Only temporary unreachability of an installed, authorized MCP follows Offline.
378
+
379
+ ### Save
380
+
381
+ 1. Resolve the store and check `${ARTIFACT_STORE:-}`.
382
+ 2. In linear mode, apply the Linear call gate. Offer pointer setup when the repo-root `.plans-config` lacks an effective `store: linear` or is not tracked (`git --literal-pathspecs -C <repo-root> ls-files --error-unmatch -- .plans-config` fails), independently of `ARTIFACT_STORE_SOURCE`. Gather missing values like init: workspace slug from Linear MCP `get_workspace`, team from `ARTIFACT_LINEAR_TEAM` or `list_teams` (use the sole team, ask when several), and label `repo:<repo-name>` from the `origin` remote basename minus `.git`, falling back to the main checkout directory name (parent of `git rev-parse --path-format=absolute --git-common-dir`). Existing `ARTIFACT_LINEAR_*` hints override these defaults; a project hint replaces the label. Ask once whether to run `artifact-store-pointer.sh --store=linear --linear-workspace=… --linear-team=… (--linear-label=… | --linear-project=…)` so fresh clones find Linear. Headless runs, no answer, unresolved values, declining, or helper failure produce a one-line notice and continue; this offer never blocks Save. Then call `ensure_artifact_dir` before any cache write or pull and read cached identity. If the cache file is absent or has no `linear.document` identity (or, for a plan, no `tasks` identity), run Lookup steps 3–6 before creating anything; reuse its Document, status update, parent, and task issues rather than duplicating them. On a hit, Load first, preserve that identity, and use Conflict before replacing its body when no prior sync state exists.
383
+ 3. Write the new body. Local mode writes today's path without identity frontmatter and **stops here**. Linear mode preserves existing identity frontmatter, including `tasks`, and all non-identity keys; only the body is replaced.
384
+ 4. Before updating an existing object, fetch its `updatedAt`. If it differs from `syncedAt`, run Conflict and do not push until answered. A discovered existing object with no prior `syncedAt` also requires Conflict before its body is replaced.
385
+ 5. Create or update the object using the Kinds and naming rules. For plans, apply the task-issue rules above. On creation, record all returned ids.
386
+ 6. After a successful push, stamp `syncedAt` verbatim from the response, recompute `contentHash`, update `tasks` and `linear.statusUpdate` as applicable, and clear `pending`.
387
+
388
+ If the MCP fails during step 4 or 5, keep the local file and follow Offline.
389
+
390
+ ### Load
391
+
392
+ 1. An explicit path, URL, or id selects that object; otherwise run Lookup.
393
+ Before any pull writes the cache, apply the Linear call gate and resolve the selected kind and slug with `--ensure` (forwarding `STORE_FLAG`) to establish the safe cache and gitignore rule.
394
+ 2. If the local file is missing, pull it, write the cache file, and stamp identity frontmatter.
395
+ 3. If it exists, compute its current body hash and read `syncedAt`.
396
+ 4. If Linear `updatedAt` differs from `syncedAt` and the current hash equals `contentHash` with no pending edit, pull; Linear wins because the cache is clean.
397
+ 5. If Linear differs and the local hash differs from `contentHash` or `pending` is true, run Conflict; both sides changed.
398
+ 6. If Linear matches `syncedAt`, keep the local file. When `pending` is true or its hash differs from `contentHash`, run Save from step 4 to push it.
399
+
400
+ ### Conflict
401
+
402
+ 1. Ask the user to keep local, take Linear, or show a diff. After showing a diff, ask again until the user chooses keep or take.
403
+ 2. Keep local: push immediately against the acknowledged remote state, then stamp `syncedAt` and `contentHash` from the successful push. Do not prompt again for the same remote change.
404
+ 3. Take Linear: replace the body, then stamp `syncedAt` and `contentHash` from the successful pull.
405
+ 4. Never silently discard either side.
406
+
407
+ ### Offline
408
+
409
+ 1. For temporary MCP unreachability, warn once and continue locally.
410
+ 2. Keep the local body and set `pending: true`.
411
+ 3. On the next Load or Save that reaches Linear, push through the normal remote checks and clear `pending` after success.
412
+ 4. If the remote also differs, run Conflict; never push or pull over the other side silently.
413
+
414
+ ## Store resolution
415
+
416
+ `resolve_artifact_store` exports variables without writing files. First hit wins; accepted values are only `linear` and `local`.
417
+
418
+ 1. `--store=` argument → `ARTIFACT_STORE_SOURCE=flag`.
419
+ 2. Nearest in-scope `.plans-config` defining `store:` → `config`.
420
+ 3. `${XDG_CONFIG_HOME:-$HOME/.config}/ycc/config`, key `store:` → `global`.
421
+ 4. Default `linear` → `default`.
422
+
423
+ An invalid value at the selected level does not fall through. An explicit resolve prints an error and returns 1; sourced auto-resolution prints `WARNING`, unsets every `ARTIFACT_*` variable, and does not fail the caller.
424
+
425
+ The default is `linear`. Opt out with `--store=local`, `store: local` in `.plans-config`, or `store: local` in the global config; local mode needs no Linear MCP. Pin a repo to Linear for fresh clones with `init --artifact-store=linear` or `artifact-store-pointer.sh` (see Fresh clone). Resolution never writes files, whichever store is selected.
426
+
427
+ The `store` and `linear_*` walks compare physical paths (`pwd -P`) and stop after the start directory's physical Git toplevel, or physical `PLANS_ROOT` without Git. Symlinked paths therefore cannot escape the boundary. The original start directory still goes to `resolve_plans_dir`, whose upward/topmost `PLANS_*` behavior is unchanged.
428
+
429
+ Each hint inherits independently from the nearest in-scope `.plans-config` defining that key. Unset keys export as empty strings. The global file is consulted only for `store:`.
430
+
431
+ | Config key | Exported variable |
432
+ | ------------------ | --------------------------- |
433
+ | `linear_workspace` | `ARTIFACT_LINEAR_WORKSPACE` |
434
+ | `linear_team` | `ARTIFACT_LINEAR_TEAM` |
435
+ | `linear_project` | `ARTIFACT_LINEAR_PROJECT` |
436
+ | `linear_label` | `ARTIFACT_LINEAR_LABEL` |
437
+
438
+ In linear mode, `ARTIFACT_ROOT` is `PLANS_ROOT` unless `PLANS_ROOT` lies outside the start directory's Git toplevel; then it is that Git toplevel, keeping a nested worktree's cache in the worktree. In local mode, `ARTIFACT_ROOT` is `PLANS_ROOT` and `ARTIFACT_DIR` is `$PLANS_DIR`. In linear mode, `ARTIFACT_DIR` is `${ARTIFACT_ROOT}/.ycc/artifacts`.
439
+
440
+ ### Branch hint
441
+
442
+ `ARTIFACT_LINEAR_HINT` comes from `git -C <start-dir> branch --show-current`; it is empty for detached HEAD or no Git checkout. Skills verify the hint in Linear before using it.
443
+
444
+ - With a team, match only `<TEAM>-<digits>` case-insensitively. After uppercasing, the team must match `^[A-Z0-9]+$`; otherwise return an empty hint.
445
+ - Without a team, use prefix `[A-Za-z][A-Za-z0-9]{1,9}` with the same rules.
446
+ - The key must begin at the branch start or after `/`, `_`, or `-`, and end at `-`, `_`, `/`, or end of string.
447
+ - Use the first match and export it uppercased. `yramirez/yan-1152-foo` and `feat/YAN-1152-x` both yield `YAN-1152`.
448
+
449
+ ## Helper API
450
+
451
+ | Variable | Value |
452
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------ |
453
+ | `ARTIFACT_STORE` | `linear` or `local` |
454
+ | `ARTIFACT_STORE_SOURCE` | `flag`, `config`, `global`, or `default` |
455
+ | `ARTIFACT_ROOT` | Linear: `PLANS_ROOT`, or the start directory's Git toplevel when `PLANS_ROOT` lies outside it. Local: `PLANS_ROOT` |
456
+ | `ARTIFACT_DIR` | Linear: `${ARTIFACT_ROOT}/.ycc/artifacts`. Local: `$PLANS_DIR` |
457
+ | `ARTIFACT_LINEAR_WORKSPACE` | `linear_workspace`, or empty |
458
+ | `ARTIFACT_LINEAR_TEAM` | `linear_team`, or empty |
459
+ | `ARTIFACT_LINEAR_PROJECT` | `linear_project`, or empty |
460
+ | `ARTIFACT_LINEAR_LABEL` | `linear_label`, or empty |
461
+ | `ARTIFACT_LINEAR_HINT` | Branch issue-key hint, or empty; skills must verify it in Linear |
462
+
463
+ | Function | Behavior |
464
+ | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
465
+ | `resolve_artifact_store [--store=linear\|local] [start-dir]` | Export all variables and re-export `PLANS_DIR`/`PLANS_ROOT` for the start directory. No writes. Return 1 on invalid input. |
466
+ | `get_feature_artifact_dir <slug>` | Print `${ARTIFACT_DIR}/<slug>` after the slug validation above. Do not create it. |
467
+ | `get_artifact_path <kind> <slug>` | Print the kind's absolute local or linear path. Validate the slug like `get_feature_artifact_dir`, research/analysis suffixes as lowercase kebab-case, and review/pr-autofix ids as in Review kinds below. No writes. |
468
+ | `select_local_plan_store <name>` | Under `ARTIFACT_STORE_SOURCE=default` only, re-resolve with `--store=local` when the local feature directory (legacy names allowed) exists, printing the Inputs line. Used by the read-only planning checks. |
469
+ | `ensure_artifact_gitignore` | Linear: ensure the repository gitignore rule. Local: return 0 without writing. |
470
+ | `ensure_artifact_dir` | Run `ensure_artifact_gitignore`, then create `ARTIFACT_DIR` only on success; a refused or failed check creates no `.ycc/artifacts/`. The write-on-first-save entry point. |
471
+
472
+ Pointer writer (not sourced; see Fresh clone for the CLI and exit codes):
473
+
474
+ ```bash
475
+ bash "{{package-root}}/shared/scripts/artifact-store-pointer.sh" --store=linear|local [--linear-workspace=<slug>] [--linear-team=<KEY>] [--linear-label=<label> | --linear-project=<id-or-slug>] [--dry-run] [--no-commit] [--force] [<dir>]
476
+ ```
477
+
478
+ It sources `resolve-artifact-store.sh` for `ensure_artifact_gitignore` and writes only `.plans-config`, `.gitignore`, and a pathspec commit of those paths. The linear gitignore coverage check (dry runs included) also creates and removes a scratch directory under `TMPDIR`.
479
+
480
+ Executed form; default output is `ARTIFACT_DIR` only:
481
+
482
+ ```bash
483
+ bash "{{package-root}}/shared/scripts/resolve-artifact-store.sh" [--store=linear|local] [--debug] [--shell] [--kind=<kind> --slug=<slug>] [--ensure] [start-dir]
484
+ ```
485
+
486
+ - `--shell` prints every existing `ARTIFACT_*` mode/config variable using Bash `printf %q`; planning skills print it and read `ARTIFACT_STORE` from stdout rather than silently evaluating it. `ARTIFACT_REPO_ROOT` is used by sourced local path resolution but is not added to `--shell` output.
487
+ - `--help` prints usage. `--debug` or `PLANS_DEBUG=1` enables debug output.
488
+ - `--kind` and `--slug` together print `get_artifact_path`; without them, default output remains `ARTIFACT_DIR`. With both options, local `--ensure` creates only that file's parent or that directory itself; linear `--ensure` calls `ensure_artifact_dir` for the cache base and gitignore rule. Without kind/slug, `--ensure` calls `ensure_artifact_dir` unchanged.
489
+ - Report kinds: `report` resolves locally to `${PLANS_DIR}/<slug>/report.md`; `prp-report` resolves to `<repo>/docs/prps/reports/<slug>-report.md` under the current checkout. Both resolve to `.ycc/artifacts/<slug>/report.md` in linear mode. `code-report` resolves locally to the same `${PLANS_DIR}/<slug>/report.md` and in linear mode to `.ycc/artifacts/<slug>/code-report.md`. Local `--ensure` creates only the parent directory.
490
+ - Review kinds: `review-<id>` and `review-fixes-<id>` accept `pr-<N>`, `local-<YYYYMMDD-HHMMSS>`, or `quick-<YYYYMMDD-HHMMSS>`; `pr-autofix-report-<id>` accepts `<N>-<YYYY-MM-DD>T<HHMMSS>Z`, where `<N>` ≥ 1. Other ids fail. Paths: Review and report skills.
491
+ - Sourcing auto-resolves without `exit` or enabling `set -e`; check `${ARTIFACT_STORE:-}` before use. Call `resolve_artifact_store` explicitly to pass a flag/start directory or receive invalid-input status.
492
+
493
+ ```bash
494
+ # shellcheck source=/dev/null
495
+ source "{{package-root}}/shared/scripts/resolve-artifact-store.sh"
496
+ ```
497
+
498
+ For body-only validation, source or execute `artifact-body.sh`. It removes only a leading block that qualifies as frontmatter under rule 1 of Body, hash, and push bytes; CRLF delimiters are accepted. A leading thematic break, an unterminated block, and every other file are printed unchanged. Body bytes after the block are not normalized.
499
+
500
+ ```bash
501
+ # shellcheck source=/dev/null
502
+ source "{{package-root}}/shared/scripts/artifact-body.sh"
503
+ artifact_body path/to/artifact.md
504
+ bash "{{package-root}}/shared/scripts/artifact-body.sh" path/to/artifact.md
505
+ ```
506
+
507
+ For PR-linking candidates, run the read-only collector (it never calls Linear):
508
+
509
+
510
+
511
+ ## Repository mapping
512
+
513
+ Default: one Linear Project per feature, named exactly `<slug>`, inside `ARTIFACT_LINEAR_TEAM`, with `ARTIFACT_LINEAR_LABEL` applied. Reuse a matching Project or create it on first save.
514
+
515
+ Alternative: set `linear_project` to a fixed Project id/slug for repos using one Project with milestones. Lookup step 5 then uses that Project instead of label discovery.
516
+
517
+ A plan's parent tracking issue is the verified hint issue when present; otherwise create one in the feature Project. The helper only supplies hints; skills perform all verification and creation.
518
+
519
+ ## Worktrees
520
+
521
+ - Linear mode does not move plan files between worktrees. Planning skills use Load to pull into a worktree cache instead of following the committed-docs move in `worktree-strategy.md`; local mode retains that existing behavior. Implementation skills hydrate the plan once into the invoking checkout's cache and pass its absolute path to worktree tasks (see Implementation skills). Pushing from the main checkout does not refresh another worktree's clean cache: Load's differing-`updatedAt` rule pulls the new remote body there.
522
+ - Push every pending artifact before removing a worktree. Unpushed pending files block routine cleanup.
523
+ - Lookup step 2 checks both the current worktree cache and the main checkout cache, so per-worktree roots do not hide existing work.
524
+
525
+ ## Gitignore
526
+
527
+ Ignore `.ycc/artifacts/` only, never all of `.ycc/`; a committed pointer may live there later.
528
+
529
+ In linear mode, both `ensure_*` functions refuse when `ARTIFACT_ROOT` is outside a Git work tree. They also refuse symlinked `${ARTIFACT_ROOT}/.gitignore`, `${ARTIFACT_ROOT}/.ycc`, or `ARTIFACT_DIR` rather than writing through them. Local mode never edits Git metadata; CLI `--ensure --kind=... --slug=...` creates only the resolved parent/directory, while `ensure_artifact_dir` (or bare `--ensure`) creates `ARTIFACT_DIR`.
530
+
531
+ The linear gitignore check returns without editing when either condition holds:
532
+
533
+ - `${ARTIFACT_ROOT}/.gitignore` contains `.ycc/artifacts/`, `/.ycc/artifacts/`, `.ycc/artifacts`, or `/.ycc/artifacts` on a line after every `!` line in that file that can match the `.ycc/artifacts` directory itself (for example `!.ycc/artifacts/` or `!artifacts`). Git cannot re-include files under an excluded directory, so this line covers the cache; `!` lines for paths below it, such as `!.ycc/artifacts/keep/`, or for unrelated paths do not undo it.
534
+ - `git check-ignore -v --no-index`, consulting only this repository's `.gitignore` files, ignores `.ycc/artifacts/probe`, `.ycc/artifacts/probe-dir/probe`, and `.ycc/artifacts/feat/cache`, and no repository `.gitignore` from the Git root down to `ARTIFACT_ROOT`, in the working tree or the index, has a relevant `!` line.
535
+
536
+ A `!` line is relevant when it may re-include `.ycc/artifacts/**` paths the probes miss, such as `!.ycc/artifacts/my-feature/` or `!.ycc/artifacts/`. Unanchored negations (no `/` except a trailing one), patterns containing `\` or `(`, and bracket expressions spanning `/` (such as `!.ycc/artifact[s/]`) count as relevant. Otherwise segments are compared from the left: a segment with `**` makes the line relevant once every earlier segment has matched, and anchored negations whose leading segments cannot match the path from that file's directory to `.ycc/artifacts`, such as `!.vscode/settings.json`, are ignored. A relevant line makes probe coverage not count, so the rule is appended after it; the next check then finds the exact line last.
537
+
538
+ Matches from a global `core.excludesFile` or `.git/info/exclude` do not count because they are not portable; the repository rule is still appended. A negated (`!`) rule that re-includes one of those probe paths, from any source, refuses rather than being overridden. A `!` line in any `.gitignore` under `.ycc/`, in the working tree or the index (after an optional UTF-8 BOM), also refuses: `check-ignore` cannot attribute it, and the deeper file overrides the root rule.
539
+
540
+ Otherwise append `.ycc/artifacts/`, creating `.gitignore` if needed and adding a missing trailing newline before the entry. Skills call `--ensure` after the Linear gate and before the first cache write or pull; `artifact-store-pointer.sh` (run by `init --artifact-store=linear`) applies the same rule when it writes the committed pointer.
541
+
542
+ ## Fresh clone
543
+
544
+ A fresh clone finds Linear from committed `.plans-config`. Only the `store`/`linear_*` lookup is bounded to the repository; `resolve-plans-dir.sh` retains its existing unbounded upward/topmost config behavior for `PLANS_*`.
545
+
546
+ ```text
547
+ plans_dir: docs/plans
548
+ store: linear
549
+ linear_workspace: yandy-r
550
+ linear_team: YAN
551
+ linear_label: repo:ystack
552
+ ```
553
+
554
+ A fixed-Project repo uses `linear_project: <id-or-slug>` instead of `linear_label`. No `scope: local` is needed: a nested worktree uses its own Git toplevel for the linear cache even when a higher config determines `PLANS_ROOT`.
555
+
556
+ The generated `AGENTS.md` carries this section, rendered by `init` from the `IF_ARTIFACT_STORE` block of its `AGENTS.md.tmpl` when Phase 5.6 succeeds with a linear pointer (or the root pointer is already linear and tracked):
557
+
558
+ ```text
559
+ ## Planning artifacts
560
+
561
+ Planning artifacts live in Linear (see `.plans-config`); `.ycc/artifacts/` is a gitignored local cache. If it's missing, pull from Linear.
562
+ ```
563
+
564
+ The pointer is written and committed by `artifact-store-pointer.sh`, which `init --artifact-store=linear` runs once and Save offers when no committed pointer exists:
565
+
566
+ ```bash
567
+ bash "{{package-root}}/shared/scripts/artifact-store-pointer.sh" --store=linear|local [--linear-workspace=<slug>] [--linear-team=<KEY>] [--linear-label=<label> | --linear-project=<id-or-slug>] [--dry-run] [--no-commit] [--force] [<dir>]
568
+ ```
569
+
570
+ - `<dir>` defaults to `.`; the target is its physical git toplevel. `--store=linear` requires `--linear-workspace`, `--linear-team`, and one of `--linear-label` or `--linear-project`. Workspace, label, and project values must match `^[A-Za-z0-9][A-Za-z0-9._:/@+-]*$`; team keys must match `^[A-Z][A-Z0-9]{0,9}$`.
571
+ - Sets `store:` and each provided `linear_*` key in the root `.plans-config` in place, preserving every other line, comment, and key order; new keys are appended. A differing existing value, or switching from an existing `linear_project` to `--linear-label` (or vice versa), exits `3` unless `--force`; forcing a mapping switch removes the other key's line. Identical values without a final newline remain `pointer_change=unchanged`, without a rewrite or commit.
572
+ - All refusal checks happen before any write: invalid or unsafe values/paths, symlinks, conflicts, CRLF pointer files, an ignored `.plans-config` (for either store), and linear gitignore writability. CRLF exits `2` with `convert .plans-config to LF line endings`. When the root pointer is new, tracked or untracked nested `*/.plans-config` files without `scope: local` also refuse with exit `3`, naming each path, because a root pointer would move their plans directory; `--force` overrides this refusal. For linear the helper ensures the `.ycc/artifacts/` gitignore rule (`ensure_artifact_gitignore`) before writing the pointer; dry runs perform the same refusal checks without writing.
573
+ - Commits only the pointer paths with `chore(ycc): configure Linear artifact store` (`configure local artifact store` for local); `.gitignore` joins the commit only when its sole diff is the added rule. Other staged changes stay staged. Pre-existing unstaged or staged `.plans-config` changes versus HEAD cause a warning and `commit=skipped`. An untracked existing pointer is also treated as dirty when it contains keys other than `store` and `linear_*` (comments and blank lines are ignored). In either case files are still written and the helper exits `0`, preserving the user's commit boundary. `--no-commit` also skips the commit; `--dry-run` writes nothing and prints the planned `.plans-config`.
574
+ - Exit codes: `2` usage, invalid/unsafe value, not a git work tree, symlinked target, CRLF pointer, gitignore writability failure, a negated rule re-including `.ycc/artifacts/` paths, or a failed ignore-coverage probe (for example an unwritable `TMPDIR`); `3` existing value, label/project mapping, or new-root/nested-config conflicts (use `--force`); `4` `.plans-config` is gitignored; `5` commit failed (files stay written, but the paths staged by the helper are unstaged, including on an unborn branch).
575
+ - Stdout ends with `pointer=<abs path>`, `pointer_change=created|updated|unchanged`, `gitignore=added|present|skipped`, `commit=<short sha>|skipped|none`.
576
+
577
+ A user-level store override uses the same key format:
578
+
579
+ ```text
580
+ # ${XDG_CONFIG_HOME:-$HOME/.config}/ycc/config
581
+ store: local
582
+ ```
583
+
584
+ ## Lookup
585
+
586
+ In linear mode, stop at the first hit:
587
+
588
+ 1. Explicit path, URL, or Linear id argument.
589
+ 2. Current cache `.ycc/artifacts/<slug>/`, then the main checkout cache. Find the main root as the parent of `git rev-parse --git-common-dir` and check the same relative artifact path there.
590
+ 3. `ARTIFACT_LINEAR_HINT`: verify the issue in Linear, then open its Project, Documents, and any report status update.
591
+ 4. Open PR for the current branch (`gh pr view --json body` or GitHub MCP). Parse `(Closes|Fixes|Resolves) <TEAM>-<n>`, verify the issue in Linear, then open its Project and artifacts. Match keywords and keys case-insensitively. Without a configured team, accept the generic key prefix `[A-Za-z][A-Za-z0-9]{1,9}`.
592
+ 5. `ARTIFACT_LINEAR_PROJECT` when set; otherwise Projects in `ARTIFACT_LINEAR_TEAM` carrying `ARTIFACT_LINEAR_LABEL`, filtered by slug.
593
+ 6. Linear Document search by slug and title (`<slug> · <kind>`), plus the Project's report status updates.
594
+ 7. Ask the user for a path, URL, or id, listing everything tried and any step skipped for missing configuration.
595
+
596
+ Never conclude "no plan" without querying Linear and asking the user. If Linear is unreachable, say the lookup is unverified and ask; never report not-found. Local mode uses today's local discovery only and makes no Linear calls.
597
+
598
+ ## Local mode
599
+
600
+ `store: local` preserves today's paths and filenames, adds no identity frontmatter, and makes no Linear calls. Save stops after step 3 and Lookup uses today's local discovery only.
601
+
602
+ - `ARTIFACT_ROOT=PLANS_ROOT`, `ARTIFACT_DIR=PLANS_DIR`, and `get_feature_artifact_dir <slug>` prints `${PLANS_DIR}/<slug>`.
603
+ - Existing `docs/prps/` files stay there rather than moving under `docs/plans/`. Repo-level kinds resolve under `ARTIFACT_REPO_ROOT` (the physical current checkout git toplevel, or physical start directory outside git), independent of `PLANS_ROOT`.
604
+ - `ensure_artifact_gitignore` is a no-op; `ensure_artifact_dir` only creates `ARTIFACT_DIR`. CLI `--ensure --kind=... --slug=...` instead creates only the resolved file's parent or the resolved directory, never an unrelated plans directory.
605
+ - The new slug helper is stricter than `get_feature_plan_dir`. Existing names it rejects keep their existing paths rather than being silently renamed.
606
+
607
+ ## Size and diagrams
608
+
609
+ - Keep Mermaid in fenced code blocks; Linear renders Mermaid.
610
+ - Split a document over about 100 KB into `<basename>-part-N.md`. Each part is its own Linear Document with its own title and identity frontmatter. When content shrinks, delete stale local part files and their Linear Documents.
611
+ - Visual-plan writes `plan.mdx` (and any additional visual surfaces) under `.ycc/artifacts/<slug>/visual/` in linear mode. These files stay local-only and are not uploaded; visual-plan does not edit the source plan to reference them. Local mode keeps the existing `<plan-dir>/visual/` behavior.
612
+
613
+ Migration of existing `docs/plans` and `docs/prps` trees is YAN-1158. Leave them in place.