cohorte 3.0.0-dev.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1532 -0
- package/README.md +316 -62
- package/bin/cli.js +212 -0
- package/bin/report.js +141 -0
- package/core/agents/cohorte-profile-reader.md +50 -0
- package/core/agents/cohorte-release.md +58 -0
- package/core/agents/cohorte-review.md +174 -0
- package/core/agents/implementer.template.md +146 -0
- package/core/commands/cohorte-align-ds.md +33 -0
- package/core/commands/cohorte-audit.md +67 -0
- package/core/commands/cohorte-brainstorm.md +73 -0
- package/core/commands/cohorte-build.md +241 -0
- package/core/commands/cohorte-doctor.md +133 -0
- package/core/commands/cohorte-fix.md +80 -0
- package/core/commands/cohorte-fleet.md +111 -0
- package/core/commands/cohorte-init-pipeline.md +30 -0
- package/core/commands/cohorte-intake.md +92 -0
- package/core/commands/cohorte-patch.md +118 -0
- package/core/commands/cohorte-refactor.md +57 -0
- package/core/commands/cohorte-retro.md +85 -0
- package/core/commands/cohorte-review.md +224 -0
- package/core/commands/cohorte-ship.md +155 -0
- package/core/commands/cohorte-spec.md +105 -0
- package/core/commands/cohorte-update-pipeline.md +115 -0
- package/core/hooks/gate.py +2931 -0
- package/core/templates/agent-handoff.md +34 -0
- package/core/templates/brainstorm-return.md +42 -0
- package/core/templates/decisions.template.md +42 -0
- package/core/templates/design-brief.md +37 -0
- package/core/templates/patch.template.md +86 -0
- package/core/templates/pr-body.md +25 -0
- package/core/templates/review-feedback.md +46 -0
- package/core/templates/spec.template.md +88 -0
- package/core/templates/steps/init-pipeline/01-detect-stack.md +44 -0
- package/core/templates/steps/init-pipeline/02-interview-gaps.md +55 -0
- package/core/templates/steps/init-pipeline/03-draft-profile.md +9 -0
- package/core/templates/steps/init-pipeline/04-write-render.md +91 -0
- package/core/templates/steps/init-pipeline/05-report.md +11 -0
- package/core/templates/steps/review-pr/01-pr-mode.md +54 -0
- package/core/workflows/audit.js +306 -0
- package/core/workflows/loop.js +687 -0
- package/core/workflows/refactor.js +291 -0
- package/core/workflows/review.js +491 -0
- package/install.ps1 +72 -0
- package/install.sh +69 -0
- package/lib/doctor.js +472 -0
- package/lib/install.js +377 -0
- package/lib/project.js +322 -0
- package/lib/render.js +121 -0
- package/lib/versions.js +145 -0
- package/lib/yaml.js +174 -0
- package/package.json +36 -17
- package/profile/PIPELINE.template.md +250 -0
- package/profile/SCHEMA.md +749 -0
- package/profile/cohorte.config.template.yaml +43 -0
- package/scripts/feature-diff.sh +118 -0
- package/scripts/kanban-move.sh +307 -0
- package/scripts/metrics/collect.mjs +542 -0
- package/scripts/metrics/prices.json +42 -0
- package/scripts/new-feature.sh.template +122 -0
- package/scripts/preflight.sh +114 -0
- package/scripts/remove-feature.sh.template +56 -0
- package/assets/manifest.json +0 -203
- package/assets/migrations/config/README.md +0 -12
- package/assets/migrations/state/0001_init.sql +0 -154
- package/assets/prompts/README.md +0 -11
- package/assets/prompts/agents/brainstormer.md +0 -3
- package/assets/prompts/agents/fixer.md +0 -7
- package/assets/prompts/agents/implementer.md +0 -12
- package/assets/prompts/agents/reviewer.md +0 -8
- package/assets/prompts/agents/security-reviewer.md +0 -7
- package/assets/prompts/agents/spec-author.md +0 -3
- package/assets/prompts/phases/build.md +0 -5
- package/assets/prompts/phases/review.md +0 -5
- package/assets/prompts/phases/test.md +0 -5
- package/assets/prompts/system.md +0 -11
- package/assets/schemas/agent-output.schema.json +0 -225
- package/assets/schemas/auth-status.schema.json +0 -87
- package/assets/schemas/command-result.schema.json +0 -192
- package/assets/schemas/commands.schema.json +0 -959
- package/assets/schemas/config.schema.json +0 -2281
- package/assets/schemas/doctor-report.schema.json +0 -104
- package/assets/schemas/events.schema.json +0 -8514
- package/assets/schemas/fake-script.schema.json +0 -549
- package/assets/schemas/inspect.schema.json +0 -3133
- package/assets/schemas/manifest.schema.json +0 -79
- package/assets/schemas/ownership.schema.json +0 -52
- package/assets/schemas/policy-verdict.schema.json +0 -282
- package/assets/schemas/project-model.schema.json +0 -783
- package/assets/schemas/project-status.schema.json +0 -217
- package/assets/schemas/reconcile-plan.schema.json +0 -154
- package/assets/schemas/run-diff.schema.json +0 -177
- package/assets/schemas/run-snapshot-manifest.schema.json +0 -2104
- package/assets/schemas/run-state.schema.json +0 -1755
- package/assets/schemas/runtime-capabilities.schema.json +0 -1545
- package/assets/schemas/sandbox-capabilities.schema.json +0 -116
- package/assets/schemas/skill.schema.json +0 -87
- package/assets/schemas/spec.schema.json +0 -202
- package/assets/schemas/tool-catalogue.schema.json +0 -655
- package/assets/schemas/trust-record.schema.json +0 -38
- package/assets/skills/README.md +0 -9
- package/assets/skills/inspect-surface.md +0 -4
- package/dist/agent-host.mjs +0 -2187
- package/dist/agent-host.mjs.map +0 -1
- package/dist/bundle-manifest.json +0 -128
- package/dist/chunks/__host-DgGPyco9.mjs +0 -18
- package/dist/chunks/__host-DgGPyco9.mjs.map +0 -1
- package/dist/chunks/align-ds-r_X_1aQ_.mjs +0 -93
- package/dist/chunks/align-ds-r_X_1aQ_.mjs.map +0 -1
- package/dist/chunks/approve-Cv135UqI.mjs +0 -19
- package/dist/chunks/approve-Cv135UqI.mjs.map +0 -1
- package/dist/chunks/audit-B4ZWQ_DI.mjs +0 -179
- package/dist/chunks/audit-B4ZWQ_DI.mjs.map +0 -1
- package/dist/chunks/auth-BT5oVp76.mjs +0 -132
- package/dist/chunks/auth-BT5oVp76.mjs.map +0 -1
- package/dist/chunks/auth-Dnlksuo5.mjs +0 -141
- package/dist/chunks/auth-Dnlksuo5.mjs.map +0 -1
- package/dist/chunks/brainstorm-SJwOIEif.mjs +0 -123
- package/dist/chunks/brainstorm-SJwOIEif.mjs.map +0 -1
- package/dist/chunks/build-C_-mbZfD.mjs +0 -19
- package/dist/chunks/build-C_-mbZfD.mjs.map +0 -1
- package/dist/chunks/cancel-KV_cpsqS.mjs +0 -15
- package/dist/chunks/cancel-KV_cpsqS.mjs.map +0 -1
- package/dist/chunks/canonical-C8UxeEmB.mjs +0 -57
- package/dist/chunks/canonical-C8UxeEmB.mjs.map +0 -1
- package/dist/chunks/catalogue-IaCJdfB8.mjs +0 -1549
- package/dist/chunks/catalogue-IaCJdfB8.mjs.map +0 -1
- package/dist/chunks/compose-DRKjQcn0.mjs +0 -7333
- package/dist/chunks/compose-DRKjQcn0.mjs.map +0 -1
- package/dist/chunks/config-Cqu5XQoP.mjs +0 -96
- package/dist/chunks/config-Cqu5XQoP.mjs.map +0 -1
- package/dist/chunks/contract-DjssDPpS.mjs +0 -335
- package/dist/chunks/contract-DjssDPpS.mjs.map +0 -1
- package/dist/chunks/contract-bQ9FJl4N.mjs +0 -123
- package/dist/chunks/contract-bQ9FJl4N.mjs.map +0 -1
- package/dist/chunks/deny-ClTxSvHJ.mjs +0 -15
- package/dist/chunks/deny-ClTxSvHJ.mjs.map +0 -1
- package/dist/chunks/diff-Qw0II0sj.mjs +0 -101
- package/dist/chunks/diff-Qw0II0sj.mjs.map +0 -1
- package/dist/chunks/discover-BZPolSZG.mjs +0 -21
- package/dist/chunks/discover-BZPolSZG.mjs.map +0 -1
- package/dist/chunks/doctor-DcDFPvQM.mjs +0 -222
- package/dist/chunks/doctor-DcDFPvQM.mjs.map +0 -1
- package/dist/chunks/fix-C9roGiQz.mjs +0 -82
- package/dist/chunks/fix-C9roGiQz.mjs.map +0 -1
- package/dist/chunks/fleet-yWHQY2ya.mjs +0 -297
- package/dist/chunks/fleet-yWHQY2ya.mjs.map +0 -1
- package/dist/chunks/gc-BBXlBF5w.mjs +0 -161
- package/dist/chunks/gc-BBXlBF5w.mjs.map +0 -1
- package/dist/chunks/init--FxxkrcT.mjs +0 -63
- package/dist/chunks/init--FxxkrcT.mjs.map +0 -1
- package/dist/chunks/inspect-Buby4cQD.mjs +0 -22
- package/dist/chunks/inspect-Buby4cQD.mjs.map +0 -1
- package/dist/chunks/intake-C1pesxCJ.mjs +0 -12
- package/dist/chunks/intake-C1pesxCJ.mjs.map +0 -1
- package/dist/chunks/logs-Giq5sUau.mjs +0 -25
- package/dist/chunks/logs-Giq5sUau.mjs.map +0 -1
- package/dist/chunks/loop-BWsUpyus.mjs +0 -212
- package/dist/chunks/loop-BWsUpyus.mjs.map +0 -1
- package/dist/chunks/migrate-DuYCAbE3.mjs +0 -33
- package/dist/chunks/migrate-DuYCAbE3.mjs.map +0 -1
- package/dist/chunks/models-Btp6X2YZ.mjs +0 -24
- package/dist/chunks/models-Btp6X2YZ.mjs.map +0 -1
- package/dist/chunks/obsidian-BHLkXx_H.mjs +0 -235
- package/dist/chunks/obsidian-BHLkXx_H.mjs.map +0 -1
- package/dist/chunks/patch-sAgVqjpx.mjs +0 -50
- package/dist/chunks/patch-sAgVqjpx.mjs.map +0 -1
- package/dist/chunks/pause-BASBfKLO.mjs +0 -16
- package/dist/chunks/pause-BASBfKLO.mjs.map +0 -1
- package/dist/chunks/policy-Du7WVBFX.mjs +0 -139
- package/dist/chunks/policy-Du7WVBFX.mjs.map +0 -1
- package/dist/chunks/providers-Dx78imKj.mjs +0 -19
- package/dist/chunks/providers-Dx78imKj.mjs.map +0 -1
- package/dist/chunks/reconcile-BHn66X3C.mjs +0 -50
- package/dist/chunks/reconcile-BHn66X3C.mjs.map +0 -1
- package/dist/chunks/refactor-DV3RfGjk.mjs +0 -153
- package/dist/chunks/refactor-DV3RfGjk.mjs.map +0 -1
- package/dist/chunks/render-DyZr5Lgi.mjs +0 -53
- package/dist/chunks/render-DyZr5Lgi.mjs.map +0 -1
- package/dist/chunks/resume-GJQRb2Eb.mjs +0 -15
- package/dist/chunks/resume-GJQRb2Eb.mjs.map +0 -1
- package/dist/chunks/retro-Dr-2RTNN.mjs +0 -78
- package/dist/chunks/retro-Dr-2RTNN.mjs.map +0 -1
- package/dist/chunks/retry-CLrUem1H.mjs +0 -15
- package/dist/chunks/retry-CLrUem1H.mjs.map +0 -1
- package/dist/chunks/review-ZsBqp3vZ.mjs +0 -35
- package/dist/chunks/review-ZsBqp3vZ.mjs.map +0 -1
- package/dist/chunks/run-BGabwbDL.mjs +0 -109
- package/dist/chunks/run-BGabwbDL.mjs.map +0 -1
- package/dist/chunks/run-tool-C3rAv4XF.mjs +0 -26
- package/dist/chunks/run-tool-C3rAv4XF.mjs.map +0 -1
- package/dist/chunks/scan-C5uDr7Yq.mjs +0 -167
- package/dist/chunks/scan-C5uDr7Yq.mjs.map +0 -1
- package/dist/chunks/schema-Bq9qtgsd.mjs +0 -583
- package/dist/chunks/schema-Bq9qtgsd.mjs.map +0 -1
- package/dist/chunks/send-BdnJ85Nz.mjs +0 -19
- package/dist/chunks/send-BdnJ85Nz.mjs.map +0 -1
- package/dist/chunks/ship-BizfUe62.mjs +0 -140
- package/dist/chunks/ship-BizfUe62.mjs.map +0 -1
- package/dist/chunks/shutdown-BM92Iyv2.mjs +0 -15
- package/dist/chunks/shutdown-BM92Iyv2.mjs.map +0 -1
- package/dist/chunks/skip-DZG5kpcH.mjs +0 -18
- package/dist/chunks/skip-DZG5kpcH.mjs.map +0 -1
- package/dist/chunks/spec-C2h3U64g.mjs +0 -65
- package/dist/chunks/spec-C2h3U64g.mjs.map +0 -1
- package/dist/chunks/spec-path-tptqR7W8.mjs +0 -10
- package/dist/chunks/spec-path-tptqR7W8.mjs.map +0 -1
- package/dist/chunks/src-Bfr1yzsn.mjs +0 -1689
- package/dist/chunks/src-Bfr1yzsn.mjs.map +0 -1
- package/dist/chunks/src-CPW2_Ons.mjs +0 -5487
- package/dist/chunks/src-CPW2_Ons.mjs.map +0 -1
- package/dist/chunks/src-Cu3TxNob.mjs +0 -783
- package/dist/chunks/src-Cu3TxNob.mjs.map +0 -1
- package/dist/chunks/src-DNsLSxgm.mjs +0 -928
- package/dist/chunks/src-DNsLSxgm.mjs.map +0 -1
- package/dist/chunks/src-DbS9gkJy.mjs +0 -117
- package/dist/chunks/src-DbS9gkJy.mjs.map +0 -1
- package/dist/chunks/src-yi5whv3n.mjs +0 -2118
- package/dist/chunks/src-yi5whv3n.mjs.map +0 -1
- package/dist/chunks/status-SMjiOMYy.mjs +0 -29
- package/dist/chunks/status-SMjiOMYy.mjs.map +0 -1
- package/dist/chunks/tail-BuhT-2PH.mjs +0 -25
- package/dist/chunks/tail-BuhT-2PH.mjs.map +0 -1
- package/dist/chunks/update-BXIppsbi.mjs +0 -16
- package/dist/chunks/update-BXIppsbi.mjs.map +0 -1
- package/dist/chunks/update-pipeline-Du-Gu1Pl.mjs +0 -56
- package/dist/chunks/update-pipeline-Du-Gu1Pl.mjs.map +0 -1
- package/dist/cli.mjs +0 -186
- package/dist/cli.mjs.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# ~/.claude/cohorte.config.yaml — GLOBAL, user-scoped config for the Cohorte
|
|
2
|
+
# pipeline capabilities. One machine, every project. NOT tied to any project's PIPELINE.md.
|
|
3
|
+
#
|
|
4
|
+
# Seeded once by the installer (cohorte install) and never clobbered on update. Wired
|
|
5
|
+
# interactively by /cohorte-init-pipeline (new project) and /cohorte-update-pipeline (existing project) —
|
|
6
|
+
# you should never need to hand-edit it.
|
|
7
|
+
#
|
|
8
|
+
# The `# cfg:<key>` markers below are anchors the installer's interactive prompts write to;
|
|
9
|
+
# leave them in place.
|
|
10
|
+
|
|
11
|
+
enabled: true # cfg:enabled — master switch; false disables every capability below
|
|
12
|
+
|
|
13
|
+
# ── obsidian ──────────────────────────────────────────────────────────────────
|
|
14
|
+
# Local vault used by the kanban mirror — defined here ONCE so no capability ever duplicates
|
|
15
|
+
# the path. Absolute path to the folder you open in Obsidian.
|
|
16
|
+
obsidian:
|
|
17
|
+
vault_path: "" # cfg:vault_path
|
|
18
|
+
|
|
19
|
+
# ── kanban (dev pipeline mirror) ─────────────────────────────────────────────
|
|
20
|
+
# Mirrors /cohorte-brainstorm…/cohorte-ship onto an Obsidian Kanban board — one board per project. The
|
|
21
|
+
# board path points at your PERSONAL vault, so it is machine-specific and lives here (never
|
|
22
|
+
# committed in a repo's PIPELINE.md). /cohorte-init-pipeline + /cohorte-update-pipeline write `boards` for you.
|
|
23
|
+
# See SCHEMA.md §Kanban.
|
|
24
|
+
kanban:
|
|
25
|
+
enabled: false # cfg:kanban_enabled — master switch for the kanban mirror
|
|
26
|
+
# Default column mapping: pipeline stage → the EXACT board column heading. Shared by every
|
|
27
|
+
# board; a board may override its own `columns` inside boards[] below.
|
|
28
|
+
columns:
|
|
29
|
+
ideas: "Ideas"
|
|
30
|
+
brainstorm: "Brainstorm"
|
|
31
|
+
spec: "Spec"
|
|
32
|
+
ready: "Ready to build"
|
|
33
|
+
building: "Building"
|
|
34
|
+
review: "Review"
|
|
35
|
+
fix: "Fix"
|
|
36
|
+
ship: "Ship"
|
|
37
|
+
shipped: "Shipped"
|
|
38
|
+
# One entry per project, keyed by the project's PIPELINE.md `name` (e.g. SAMO). `board` is a
|
|
39
|
+
# path RELATIVE to obsidian.vault_path. Written by /cohorte-init-pipeline + /cohorte-update-pipeline.
|
|
40
|
+
boards: {}
|
|
41
|
+
# SAMO:
|
|
42
|
+
# board: "Samo/Tasks.md"
|
|
43
|
+
# # columns: { ideas: "Idées", ... } # optional per-board override of the defaults above
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
#
|
|
3
|
+
# feature-diff.sh — the ONE way the pipeline computes "what this feature changed".
|
|
4
|
+
#
|
|
5
|
+
# feature-diff.sh --default <branch> <mode> [-- <pathspec>...]
|
|
6
|
+
# feature-diff.sh --base <sha> <mode> [-- <pathspec>...]
|
|
7
|
+
#
|
|
8
|
+
# modes: --base-only print the resolved base sha and nothing else
|
|
9
|
+
# --numstat `<added>\t<deleted>\t<path>` per changed file (full paths, no
|
|
10
|
+
# abbreviation — group by surface prefix on this, never on --stat)
|
|
11
|
+
# --name-only one changed path per line
|
|
12
|
+
# --patch the full patch (redirect it to a file; never into a context)
|
|
13
|
+
# --digest 16 hex chars of sha256 over the patch — the freshness stamp
|
|
14
|
+
#
|
|
15
|
+
# Two facts make a plain `git diff <default_branch>` wrong for a pipeline review, and this
|
|
16
|
+
# script exists to get both right in one place instead of in six prompts:
|
|
17
|
+
#
|
|
18
|
+
# 1. Feature work stays UNCOMMITTED until /cohorte-ship, and `git diff <ref>` ignores
|
|
19
|
+
# untracked files. Every new module a feature adds escaped review; a feature that only
|
|
20
|
+
# added files produced an EMPTY diff, which scored SHIP with nothing reviewed. So the
|
|
21
|
+
# diff is taken from a THROWAWAY index: seeded from the real one, `git add -A` run on
|
|
22
|
+
# the copy, `git diff --cached <base>` read from it. The human's real index — and
|
|
23
|
+
# whatever they staged in it — is never touched.
|
|
24
|
+
# 2. The base is the MERGE-BASE with the default branch, not its tip: the moment the
|
|
25
|
+
# default branch advances, a tip diff shows every file it gained as "deleted by the
|
|
26
|
+
# feature". Both the local `<branch>` and `origin/<branch>` are considered (worktrees
|
|
27
|
+
# from new-feature.sh branch off the remote ref, and the local one can lag it); the
|
|
28
|
+
# newer of the two merge-bases wins.
|
|
29
|
+
#
|
|
30
|
+
# `.claude` (pipeline state, rendered agents) and `specs` (the spec, its DoD ticks, the
|
|
31
|
+
# report buffer) are ALWAYS excluded — the pipeline writes those itself between a review
|
|
32
|
+
# and a ship, and they are not feature code. Gitignored files never enter (`git add -A`
|
|
33
|
+
# honours .gitignore). Pathspecs are repo-root relative; the script cds to the top level.
|
|
34
|
+
#
|
|
35
|
+
# Exit codes: 0 ok (an empty diff is a legitimate, empty answer) · 2 usage · 3 the base
|
|
36
|
+
# cannot be resolved (no such branch, no common history). A non-zero exit means NO diff
|
|
37
|
+
# was computed — a caller must stop, never fall back to a plain `git diff`, which is the
|
|
38
|
+
# exact bug this script replaces.
|
|
39
|
+
|
|
40
|
+
set -u
|
|
41
|
+
|
|
42
|
+
usage() {
|
|
43
|
+
echo "usage: feature-diff.sh (--default <branch> | --base <sha>) (--base-only|--numstat|--name-only|--patch|--digest) [-- <pathspec>...]" >&2
|
|
44
|
+
exit 2
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
default=""
|
|
48
|
+
base=""
|
|
49
|
+
mode=""
|
|
50
|
+
while [ $# -gt 0 ]; do
|
|
51
|
+
case "$1" in
|
|
52
|
+
--default) [ $# -ge 2 ] || usage; default=$2; shift 2 ;;
|
|
53
|
+
--base) [ $# -ge 2 ] || usage; base=$2; shift 2 ;;
|
|
54
|
+
--base-only|--numstat|--name-only|--patch|--digest)
|
|
55
|
+
[ -z "$mode" ] || usage; mode=$1; shift ;;
|
|
56
|
+
--) shift; break ;;
|
|
57
|
+
*) echo "feature-diff: unknown argument $1" >&2; usage ;;
|
|
58
|
+
esac
|
|
59
|
+
done
|
|
60
|
+
[ -n "$mode" ] || usage
|
|
61
|
+
{ [ -n "$default" ] && [ -z "$base" ]; } || { [ -z "$default" ] && [ -n "$base" ]; } || usage
|
|
62
|
+
|
|
63
|
+
top=$(git rev-parse --show-toplevel 2>/dev/null) || { echo "feature-diff: not inside a git work tree" >&2; exit 3; }
|
|
64
|
+
cd "$top" || exit 3
|
|
65
|
+
|
|
66
|
+
if [ -n "$default" ]; then
|
|
67
|
+
mb_local=""; mb_remote=""
|
|
68
|
+
git rev-parse --verify -q "$default^{commit}" >/dev/null 2>&1 \
|
|
69
|
+
&& mb_local=$(git merge-base "$default" HEAD 2>/dev/null || echo "")
|
|
70
|
+
git rev-parse --verify -q "origin/$default^{commit}" >/dev/null 2>&1 \
|
|
71
|
+
&& mb_remote=$(git merge-base "origin/$default" HEAD 2>/dev/null || echo "")
|
|
72
|
+
if [ -n "$mb_local" ] && [ -n "$mb_remote" ]; then
|
|
73
|
+
# The newer merge-base is the one the other is an ancestor of.
|
|
74
|
+
if git merge-base --is-ancestor "$mb_local" "$mb_remote" 2>/dev/null; then base=$mb_remote; else base=$mb_local; fi
|
|
75
|
+
else
|
|
76
|
+
base="${mb_local:-$mb_remote}"
|
|
77
|
+
fi
|
|
78
|
+
[ -n "$base" ] || { echo "feature-diff: no merge-base between HEAD and $default (nor origin/$default)" >&2; exit 3; }
|
|
79
|
+
else
|
|
80
|
+
base=$(git rev-parse --verify -q "$base^{commit}" 2>/dev/null) \
|
|
81
|
+
|| { echo "feature-diff: base $base is not a commit in this repo" >&2; exit 3; }
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
if [ "$mode" = --base-only ]; then echo "$base"; exit 0; fi
|
|
85
|
+
|
|
86
|
+
[ $# -gt 0 ] || set -- .
|
|
87
|
+
set -- "$@" ':(exclude).claude' ':(exclude)specs'
|
|
88
|
+
|
|
89
|
+
# A path INSIDE a fresh temp dir, not `mktemp` itself: a 0-byte file is a corrupt index to git.
|
|
90
|
+
tmpd=$(mktemp -d 2>/dev/null) || { echo "feature-diff: mktemp -d failed" >&2; exit 3; }
|
|
91
|
+
trap 'rm -rf "$tmpd"' EXIT INT TERM
|
|
92
|
+
idx="$tmpd/index"
|
|
93
|
+
real=$(git rev-parse --git-path index 2>/dev/null || echo "")
|
|
94
|
+
if [ -n "$real" ] && [ -f "$real" ]; then
|
|
95
|
+
# `cp -p` keeps the stat cache (only changed files get re-hashed) AND the index file's
|
|
96
|
+
# mtime, which is what git's racy-entry check compares against — so the copy trusts
|
|
97
|
+
# exactly the entries the real index would, no more.
|
|
98
|
+
cp -p "$real" "$idx" || { echo "feature-diff: cannot copy the index" >&2; exit 3; }
|
|
99
|
+
elif git rev-parse --verify -q HEAD >/dev/null 2>&1; then
|
|
100
|
+
GIT_INDEX_FILE="$idx" git read-tree HEAD || exit 3
|
|
101
|
+
else
|
|
102
|
+
GIT_INDEX_FILE="$idx" git read-tree --empty || exit 3
|
|
103
|
+
fi
|
|
104
|
+
# The WHOLE tree goes into the copy; the caller's pathspec only narrows the diff below. (Adding
|
|
105
|
+
# just the pathspec fails outright on a surface path that does not exist yet.)
|
|
106
|
+
GIT_INDEX_FILE="$idx" git add -A -- . ':(exclude).claude' ':(exclude)specs' >/dev/null 2>&1 \
|
|
107
|
+
|| { echo "feature-diff: git add into the temporary index failed" >&2; exit 3; }
|
|
108
|
+
|
|
109
|
+
d() { GIT_INDEX_FILE="$idx" git -c core.quotepath=off diff --cached --no-color --no-ext-diff "$@"; }
|
|
110
|
+
case "$mode" in
|
|
111
|
+
--numstat) d --no-renames --numstat "$base" -- "$@" ;;
|
|
112
|
+
--name-only) d --no-renames --name-only "$base" -- "$@" ;;
|
|
113
|
+
--patch) d --binary "$base" -- "$@" ;;
|
|
114
|
+
--digest)
|
|
115
|
+
out=$(d --binary --no-renames "$base" -- "$@" | { sha256sum 2>/dev/null || shasum -a 256; } | cut -c1-16)
|
|
116
|
+
[ -n "$out" ] || exit 3
|
|
117
|
+
echo "$out" ;;
|
|
118
|
+
esac
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# kanban-move.sh — move a feature card on an Obsidian Kanban board without
|
|
3
|
+
# loading the board into an agent's context (SCHEMA.md §Kanban "Move a card").
|
|
4
|
+
#
|
|
5
|
+
# kanban-move.sh <board.md|auto> <feature-id> <column|stage> [options]
|
|
6
|
+
# kanban-move.sh --check resolve only: print the board this
|
|
7
|
+
# project maps to, or why it does not
|
|
8
|
+
#
|
|
9
|
+
# --pr <num> ensure the card line ends with ` — PR #<num>`
|
|
10
|
+
# --title <title> text to use when the card has to be created
|
|
11
|
+
# --project <name> profile name to look up in kanban.boards (default: read
|
|
12
|
+
# `name:` from ./PIPELINE.md)
|
|
13
|
+
# --profile <path> where to read that name from (default: ./PIPELINE.md)
|
|
14
|
+
#
|
|
15
|
+
# `auto` as the board resolves the board FROM THE CONFIG — vault path, this
|
|
16
|
+
# project's board file, and the stage→heading mapping — instead of making the
|
|
17
|
+
# caller do it. This exists because the callers are agents: told only "no-op
|
|
18
|
+
# silently if no board", a fresh session (every phase runs after a /clear)
|
|
19
|
+
# concluded "no board is configured" without ever opening the config, and the
|
|
20
|
+
# card silently stopped moving mid-pipeline. Resolution is not a judgment call,
|
|
21
|
+
# so it is not left to one. When nothing resolves the script says which link is
|
|
22
|
+
# missing on stdout and exits 0 — a no-op you can read, never one you infer.
|
|
23
|
+
#
|
|
24
|
+
# Behavior of the move itself (mirrors the documented manual op):
|
|
25
|
+
# - finds the list item tagged #<feature-id> (plus its indented sub-notes),
|
|
26
|
+
# removes it from its current column, appends it under `## <target-column>`
|
|
27
|
+
# - no card yet ⇒ creates `- [ ] <title|id> #<id>` in the target column
|
|
28
|
+
# - duplicates ⇒ keeps the first, drops the rest
|
|
29
|
+
# - never touches the front-matter or the trailing `%% kanban:settings %%` block
|
|
30
|
+
#
|
|
31
|
+
# Exit codes: 0 ok (incl. "kanban not configured" — and, under `auto`, a configured
|
|
32
|
+
# board file that is gone: `kanban: board file not found`) · 2 usage · 3 unknown
|
|
33
|
+
# column, or an EXPLICIT <board.md> path that does not exist. A board that resolved
|
|
34
|
+
# but cannot be moved is loud; an unconfigured one is quiet — the pipeline never
|
|
35
|
+
# blocks on the board. (SCHEMA.md §Kanban states the same contract.)
|
|
36
|
+
set -eu
|
|
37
|
+
|
|
38
|
+
usage='usage: kanban-move.sh <board.md|auto> <feature-id> <column|stage> [--pr <num>] [--title <title>] [--project <name>] [--profile <path>]
|
|
39
|
+
kanban-move.sh --check [--project <name>] [--profile <path>]'
|
|
40
|
+
check_only=false
|
|
41
|
+
if [ "${1-}" = --check ]; then
|
|
42
|
+
check_only=true; board=auto; id=""; col=""; shift
|
|
43
|
+
else
|
|
44
|
+
[ $# -ge 3 ] || { echo "$usage" >&2; exit 2; }
|
|
45
|
+
board="$1"; id="$2"; col="$3"; shift 3
|
|
46
|
+
fi
|
|
47
|
+
pr=""; title=""; project=""; profile="PIPELINE.md"
|
|
48
|
+
while [ $# -gt 0 ]; do
|
|
49
|
+
# A flag with no value must exit 2 (usage) like every other usage error — a bare
|
|
50
|
+
# `shift 2` fails under set -e with exit 1, outside the 0/2/3 contract callers branch on.
|
|
51
|
+
case "$1" in
|
|
52
|
+
--pr|--title|--project|--profile)
|
|
53
|
+
[ $# -ge 2 ] || { echo "error: $1 needs a value" >&2; echo "$usage" >&2; exit 2; } ;;
|
|
54
|
+
esac
|
|
55
|
+
case "$1" in
|
|
56
|
+
--pr) pr="$2"; shift 2 ;;
|
|
57
|
+
--title) title="$2"; shift 2 ;;
|
|
58
|
+
--project) project="$2"; shift 2 ;;
|
|
59
|
+
--profile) profile="$2"; shift 2 ;;
|
|
60
|
+
*) echo "error: unknown flag $1" >&2; echo "$usage" >&2; exit 2 ;;
|
|
61
|
+
esac
|
|
62
|
+
done
|
|
63
|
+
|
|
64
|
+
TAB=$(printf '\t')
|
|
65
|
+
# One config per human: `${CLAUDE_CONFIG_DIR:-~/.claude}/cohorte.config.yaml`. COHORTE_CONFIG
|
|
66
|
+
# overrides it (tests, or a second board set).
|
|
67
|
+
CONFIG="${COHORTE_CONFIG:-${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte.config.yaml}"
|
|
68
|
+
|
|
69
|
+
# The nine pipeline stages and their default headings. A stage key given as the
|
|
70
|
+
# target column is mapped through the config (per-board `columns` first, then the
|
|
71
|
+
# global `kanban.columns`) and falls back to these — so a stage key works even
|
|
72
|
+
# with an explicit board path and no config at all. Anything not in this list is
|
|
73
|
+
# taken as a literal heading, which keeps hand-written columns working.
|
|
74
|
+
default_heading() {
|
|
75
|
+
case "$1" in
|
|
76
|
+
ideas) echo "Ideas" ;;
|
|
77
|
+
brainstorm) echo "Brainstorm" ;;
|
|
78
|
+
spec) echo "Spec" ;;
|
|
79
|
+
ready) echo "Ready to build" ;;
|
|
80
|
+
building) echo "Building" ;;
|
|
81
|
+
review) echo "Review" ;;
|
|
82
|
+
fix) echo "Fix" ;;
|
|
83
|
+
ship) echo "Ship" ;;
|
|
84
|
+
shipped) echo "Shipped" ;;
|
|
85
|
+
*) echo "" ;;
|
|
86
|
+
esac
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# Read `name:` from the profile's `yaml pipeline-profile` block. Only the block —
|
|
90
|
+
# a `name:` under some other key (a surface, a persona) is not the project name.
|
|
91
|
+
read_project_name() {
|
|
92
|
+
[ -f "$1" ] || return 0
|
|
93
|
+
awk '
|
|
94
|
+
/^```[ \t]*yaml[ \t]+pipeline-profile/ { inblock = 1; next }
|
|
95
|
+
/^```/ { if (inblock) exit }
|
|
96
|
+
inblock && /^name:[ \t]/ {
|
|
97
|
+
v = $0; sub(/^name:[ \t]*/, "", v)
|
|
98
|
+
sub(/[ \t]+#.*$/, "", v); sub(/[ \t]+$/, "", v)
|
|
99
|
+
gsub(/^["\047]|["\047]$/, "", v)
|
|
100
|
+
print v; exit
|
|
101
|
+
}
|
|
102
|
+
' "$1"
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# Minimal YAML reader for the fixed shape the installer writes. Not a general
|
|
106
|
+
# parser: it walks an indent stack and emits only the handful of paths the kanban
|
|
107
|
+
# mirror needs, resolved against the project name we were given (so a name with a
|
|
108
|
+
# dot in it still matches — the comparison is on whole strings, not a joined key).
|
|
109
|
+
read_config() {
|
|
110
|
+
PROJ="$1" awk '
|
|
111
|
+
function clean(v, c, q, i, ch, out) {
|
|
112
|
+
sub(/^[ \t]+/, "", v)
|
|
113
|
+
if (v == "") return ""
|
|
114
|
+
c = substr(v, 1, 1)
|
|
115
|
+
if (c == "\"" || c == "\047") {
|
|
116
|
+
q = c; out = ""
|
|
117
|
+
for (i = 2; i <= length(v); i++) {
|
|
118
|
+
ch = substr(v, i, 1)
|
|
119
|
+
if (ch == q) break
|
|
120
|
+
out = out ch
|
|
121
|
+
}
|
|
122
|
+
return out
|
|
123
|
+
}
|
|
124
|
+
sub(/[ \t]+#.*$/, "", v); sub(/[ \t]+$/, "", v)
|
|
125
|
+
return v
|
|
126
|
+
}
|
|
127
|
+
# `columns: { ideas: "Idées", ready: "Prêt" }` — the flow form the config
|
|
128
|
+
# template documents for a per-board override.
|
|
129
|
+
function flow(path, v, n, i, parts, p, k) {
|
|
130
|
+
sub(/^\{[ \t]*/, "", v); sub(/[ \t]*\}[ \t]*$/, "", v)
|
|
131
|
+
n = split(v, parts, ",")
|
|
132
|
+
for (i = 1; i <= n; i++) {
|
|
133
|
+
p = index(parts[i], ":")
|
|
134
|
+
if (p == 0) continue
|
|
135
|
+
k = substr(parts[i], 1, p - 1)
|
|
136
|
+
gsub(/^[ \t]+|[ \t]+$/, "", k)
|
|
137
|
+
emit(path "." k, clean(substr(parts[i], p + 1)))
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function emit(path, v, stage) {
|
|
141
|
+
if (v == "") return
|
|
142
|
+
if (path == "enabled") { print "ENABLED\t" v; return }
|
|
143
|
+
if (path == "kanban.enabled") { print "KENABLED\t" v; return }
|
|
144
|
+
if (path == "obsidian.vault_path") { print "VAULT\t" v; return }
|
|
145
|
+
if (path == "kanban.boards." proj ".board") { print "BOARD\t" v; return }
|
|
146
|
+
if (index(path, "kanban.columns.") == 1) {
|
|
147
|
+
print "COL." substr(path, length("kanban.columns.") + 1) "\t" v; return
|
|
148
|
+
}
|
|
149
|
+
if (index(path, "kanban.boards." proj ".columns.") == 1) {
|
|
150
|
+
print "BCOL." substr(path, length("kanban.boards." proj ".columns.") + 1) "\t" v; return
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
BEGIN { proj = ENVIRON["PROJ"]; top = 0 }
|
|
154
|
+
{
|
|
155
|
+
line = $0; sub(/\r$/, "", line)
|
|
156
|
+
if (line ~ /^[ \t]*$/ || line ~ /^[ \t]*#/) next
|
|
157
|
+
match(line, /^[ ]*/); ind = RLENGTH
|
|
158
|
+
rest = substr(line, ind + 1)
|
|
159
|
+
if (rest ~ /^- /) next
|
|
160
|
+
p = index(rest, ":")
|
|
161
|
+
if (p == 0) next
|
|
162
|
+
key = substr(rest, 1, p - 1)
|
|
163
|
+
if (key ~ /[ \t]/) next
|
|
164
|
+
raw = substr(rest, p + 1)
|
|
165
|
+
while (top > 0 && indent[top] >= ind) top--
|
|
166
|
+
top++; indent[top] = ind; keyat[top] = key
|
|
167
|
+
path = ""
|
|
168
|
+
for (i = 1; i <= top; i++) path = path (i > 1 ? "." : "") keyat[i]
|
|
169
|
+
sub(/^[ \t]+/, "", raw)
|
|
170
|
+
if (substr(raw, 1, 1) == "{") { flow(path, raw); next }
|
|
171
|
+
emit(path, clean(raw))
|
|
172
|
+
}
|
|
173
|
+
' "$CONFIG"
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
off() { echo "kanban: $1"; exit 0; }
|
|
177
|
+
|
|
178
|
+
cfg=""
|
|
179
|
+
if [ "$board" = auto ] || [ -n "$(default_heading "$col")" ]; then
|
|
180
|
+
[ -n "$project" ] || project=$(read_project_name "$profile")
|
|
181
|
+
[ -f "$CONFIG" ] && cfg=$(read_config "$project") || cfg=""
|
|
182
|
+
fi
|
|
183
|
+
|
|
184
|
+
# ── resolve the board ───────────────────────────────────────────────────────
|
|
185
|
+
if [ "$board" = auto ]; then
|
|
186
|
+
[ -f "$CONFIG" ] || off "no config at $CONFIG — board mirror off"
|
|
187
|
+
vault=""; rel=""; enabled=""; kenabled=""
|
|
188
|
+
OLDIFS=$IFS; IFS=$TAB
|
|
189
|
+
while read -r k v; do
|
|
190
|
+
case "$k" in
|
|
191
|
+
ENABLED) enabled=$v ;;
|
|
192
|
+
KENABLED) kenabled=$v ;;
|
|
193
|
+
VAULT) vault=$v ;;
|
|
194
|
+
BOARD) rel=$v ;;
|
|
195
|
+
esac
|
|
196
|
+
done <<EOF
|
|
197
|
+
$cfg
|
|
198
|
+
EOF
|
|
199
|
+
IFS=$OLDIFS
|
|
200
|
+
[ "$enabled" != false ] || off "cohorte capabilities disabled (enabled: false in $CONFIG)"
|
|
201
|
+
[ "$kenabled" != false ] || off "disabled in $CONFIG (kanban.enabled: false)"
|
|
202
|
+
[ -n "$project" ] || off "no project name in $profile — cannot resolve a board"
|
|
203
|
+
[ -n "$rel" ] || off "no board configured for project \"$project\" in $CONFIG"
|
|
204
|
+
[ -n "$vault" ] || off "obsidian.vault_path not set in $CONFIG"
|
|
205
|
+
board="$vault/$rel"
|
|
206
|
+
[ -f "$board" ] || off "board file not found: $board"
|
|
207
|
+
if $check_only; then echo "kanban: project \"$project\" -> $board"; exit 0; fi
|
|
208
|
+
fi
|
|
209
|
+
|
|
210
|
+
# ── resolve the column ──────────────────────────────────────────────────────
|
|
211
|
+
# A stage key becomes a heading; a literal heading passes through untouched.
|
|
212
|
+
if [ -n "$(default_heading "$col")" ]; then
|
|
213
|
+
heading=""
|
|
214
|
+
OLDIFS=$IFS; IFS=$TAB
|
|
215
|
+
while read -r k v; do
|
|
216
|
+
case "$k" in
|
|
217
|
+
"BCOL.$col") heading=$v ;;
|
|
218
|
+
"COL.$col") [ -n "$heading" ] || heading=$v ;;
|
|
219
|
+
esac
|
|
220
|
+
done <<EOF
|
|
221
|
+
$cfg
|
|
222
|
+
EOF
|
|
223
|
+
IFS=$OLDIFS
|
|
224
|
+
[ -n "$heading" ] || heading=$(default_heading "$col")
|
|
225
|
+
col="$heading"
|
|
226
|
+
fi
|
|
227
|
+
|
|
228
|
+
[ -f "$board" ] || { echo "error: board not found: $board" >&2; exit 3; }
|
|
229
|
+
|
|
230
|
+
tmp="${board}.kanban-move.$$"
|
|
231
|
+
ID="$id" COL="$col" PR="$pr" TITLE="${title:-$id}" awk '
|
|
232
|
+
# Emit one line, collapsing runs of blank lines to a single one. Without this
|
|
233
|
+
# every move netted +1 blank line in the target column (the card is inserted
|
|
234
|
+
# with its own separator, right after the blank that already preceded the next
|
|
235
|
+
# heading) — ten moves of one card padded a board with fifteen blank lines.
|
|
236
|
+
function emit(s) {
|
|
237
|
+
if (s == "") { if (lastblank) return; lastblank = 1 } else lastblank = 0
|
|
238
|
+
print s
|
|
239
|
+
}
|
|
240
|
+
function put_card( k) {
|
|
241
|
+
emit(card)
|
|
242
|
+
for (k = 1; k <= sn; k++) emit(snote[k])
|
|
243
|
+
}
|
|
244
|
+
BEGIN {
|
|
245
|
+
id = ENVIRON["ID"]; col = tolower(ENVIRON["COL"])
|
|
246
|
+
pr = ENVIRON["PR"]; title = ENVIRON["TITLE"]
|
|
247
|
+
n = 0; card = ""; found = 0; colseen = 0; sn = 0; lastblank = 0
|
|
248
|
+
}
|
|
249
|
+
# Strip CR at capture: a CRLF board (Windows-synced vault) otherwise fails the
|
|
250
|
+
# `h == col` heading compare and exits 3 on a column that exists — while the
|
|
251
|
+
# config parser in this same script already strips \r. Emitting LF-only is fine
|
|
252
|
+
# (Obsidian reads both).
|
|
253
|
+
{ sub(/\r$/, ""); lines[++n] = $0 }
|
|
254
|
+
END {
|
|
255
|
+
# pass 1: extract the FIRST card block tagged #id; mark every block for removal
|
|
256
|
+
for (i = 1; i <= n; i++) {
|
|
257
|
+
l = lines[i]
|
|
258
|
+
if (l !~ /^- \[.\] /) continue
|
|
259
|
+
p = index(l, "#" id)
|
|
260
|
+
if (p == 0) continue
|
|
261
|
+
# word-boundary check: char after the tag must not extend the id
|
|
262
|
+
rest = substr(l, p + length(id) + 1, 1)
|
|
263
|
+
if (rest != "" && rest ~ /[A-Za-z0-9_-]/) continue
|
|
264
|
+
# Capture the sub-notes of the FIRST match only. Testing `card == lines[i]`
|
|
265
|
+
# instead also captured a later duplicate whose text happened to match.
|
|
266
|
+
isfirst = 0
|
|
267
|
+
if (!found) { found = 1; card = l; isfirst = 1 }
|
|
268
|
+
del[i] = 1
|
|
269
|
+
for (j = i + 1; j <= n && lines[j] ~ /^[ \t]/; j++) {
|
|
270
|
+
del[j] = 1
|
|
271
|
+
if (isfirst) snote[++sn] = lines[j]
|
|
272
|
+
}
|
|
273
|
+
i = j - 1
|
|
274
|
+
}
|
|
275
|
+
if (!found) card = "- [ ] " title " #" id
|
|
276
|
+
if (pr != "" && index(card, "PR #") == 0) card = card " — PR #" pr
|
|
277
|
+
|
|
278
|
+
# pass 2: emit, skipping removed blocks; append the card at the end of the
|
|
279
|
+
# target column (before the next ## heading / settings block / EOF)
|
|
280
|
+
intarget = 0; placed = 0
|
|
281
|
+
for (i = 1; i <= n; i++) {
|
|
282
|
+
if (del[i]) continue
|
|
283
|
+
l = lines[i]
|
|
284
|
+
atheading = (l ~ /^## /)
|
|
285
|
+
atsettings = (l ~ /^%% kanban:settings/)
|
|
286
|
+
if (intarget && (atheading || atsettings)) {
|
|
287
|
+
# can not back up over already-printed lines; place the card just before
|
|
288
|
+
# this boundary instead
|
|
289
|
+
put_card()
|
|
290
|
+
emit("")
|
|
291
|
+
intarget = 0; placed = 1
|
|
292
|
+
}
|
|
293
|
+
if (atheading) {
|
|
294
|
+
h = tolower(l); sub(/^## +/, "", h); gsub(/ +$/, "", h)
|
|
295
|
+
if (h == col) { intarget = 1; colseen = 1 }
|
|
296
|
+
}
|
|
297
|
+
emit(l)
|
|
298
|
+
}
|
|
299
|
+
if (intarget && !placed) {
|
|
300
|
+
put_card()
|
|
301
|
+
placed = 1
|
|
302
|
+
}
|
|
303
|
+
if (!colseen) exit 3
|
|
304
|
+
}
|
|
305
|
+
' "$board" > "$tmp" || { rc=$?; rm -f "$tmp"; [ "$rc" = 3 ] && echo "error: column \"$col\" not found in $board" >&2; exit "$rc"; }
|
|
306
|
+
mv "$tmp" "$board"
|
|
307
|
+
echo "moved #$id -> $col${pr:+ (PR #$pr)}"
|