cohorte 3.0.0-dev.8 → 3.1.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 +1637 -0
- package/README.md +322 -62
- package/bin/cli.js +213 -0
- package/bin/report.js +141 -0
- package/core/agents/cohorte-profile-reader.md +40 -0
- package/core/agents/cohorte-release.md +61 -0
- package/core/agents/cohorte-review.md +200 -0
- package/core/agents/implementer.template.md +154 -0
- package/core/commands/cohorte-align-ds.md +33 -0
- package/core/commands/cohorte-audit.md +74 -0
- package/core/commands/cohorte-brainstorm.md +73 -0
- package/core/commands/cohorte-build.md +248 -0
- package/core/commands/cohorte-doctor.md +135 -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 +122 -0
- package/core/commands/cohorte-retro.md +85 -0
- package/core/commands/cohorte-revert.md +104 -0
- package/core/commands/cohorte-review.md +239 -0
- package/core/commands/cohorte-ship.md +167 -0
- package/core/commands/cohorte-spec.md +114 -0
- package/core/commands/cohorte-update-pipeline.md +119 -0
- package/core/commands/cohorte-verify.md +106 -0
- package/core/hooks/gate.py +3236 -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 +95 -0
- package/core/templates/pr-body.md +25 -0
- package/core/templates/review-feedback.md +46 -0
- package/core/templates/spec.template.md +109 -0
- package/core/templates/steps/init-pipeline/01-detect-stack.md +53 -0
- package/core/templates/steps/init-pipeline/02-interview-gaps.md +78 -0
- package/core/templates/steps/init-pipeline/03-draft-profile.md +10 -0
- package/core/templates/steps/init-pipeline/04-write-render.md +95 -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 +311 -0
- package/core/workflows/loop.js +692 -0
- package/core/workflows/refactor.js +398 -0
- package/core/workflows/review.js +505 -0
- package/install.ps1 +72 -0
- package/install.sh +69 -0
- package/lib/doctor.js +506 -0
- package/lib/install.js +386 -0
- package/lib/project.js +359 -0
- package/lib/render.js +121 -0
- package/lib/versions.js +145 -0
- package/lib/yaml.js +183 -0
- package/package.json +36 -17
- package/profile/PIPELINE.template.md +288 -0
- package/profile/SCHEMA.md +30 -0
- package/profile/cohorte.config.template.yaml +43 -0
- package/profile/schema/dead-agents.md +29 -0
- package/profile/schema/decisions.md +23 -0
- package/profile/schema/deferred.md +22 -0
- package/profile/schema/feature-diff.md +20 -0
- package/profile/schema/kanban.md +95 -0
- package/profile/schema/metrics.md +23 -0
- package/profile/schema/output-discipline.md +21 -0
- package/profile/schema/preflight.md +81 -0
- package/profile/schema/profile-block.md +103 -0
- package/profile/schema/project-kinds.md +89 -0
- package/profile/schema/readiness.md +17 -0
- package/profile/schema/reconcile.md +64 -0
- package/profile/schema/release-notes.md +29 -0
- package/profile/schema/rendering.md +48 -0
- package/profile/schema/retrieval.md +58 -0
- package/profile/schema/spec-status.md +79 -0
- package/profile/schema/specialization.md +41 -0
- package/profile/schema/verify.md +115 -0
- package/profile/schema/workflows.md +78 -0
- package/scripts/feature-diff.sh +118 -0
- package/scripts/kanban-move.sh +349 -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/scripts/verify-run.sh +509 -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,349 @@
|
|
|
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/kanban.md "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 · 4 the board stayed locked
|
|
34
|
+
# by another move for ~30 s (moves are serialized). A board that resolved
|
|
35
|
+
# but cannot be moved is loud; an unconfigured one is quiet — the pipeline never
|
|
36
|
+
# blocks on the board. (schema/kanban.md states the same contract.)
|
|
37
|
+
set -eu
|
|
38
|
+
|
|
39
|
+
usage='usage: kanban-move.sh <board.md|auto> <feature-id> <column|stage> [--pr <num>] [--title <title>] [--project <name>] [--profile <path>]
|
|
40
|
+
kanban-move.sh --check [--project <name>] [--profile <path>]'
|
|
41
|
+
check_only=false
|
|
42
|
+
if [ "${1-}" = --check ]; then
|
|
43
|
+
check_only=true; board=auto; id=""; col=""; shift
|
|
44
|
+
else
|
|
45
|
+
[ $# -ge 3 ] || { echo "$usage" >&2; exit 2; }
|
|
46
|
+
board="$1"; id="$2"; col="$3"; shift 3
|
|
47
|
+
fi
|
|
48
|
+
pr=""; title=""; project=""; profile="PIPELINE.md"
|
|
49
|
+
while [ $# -gt 0 ]; do
|
|
50
|
+
# A flag with no value must exit 2 (usage) like every other usage error — a bare
|
|
51
|
+
# `shift 2` fails under set -e with exit 1, outside the 0/2/3 contract callers branch on.
|
|
52
|
+
case "$1" in
|
|
53
|
+
--pr|--title|--project|--profile)
|
|
54
|
+
[ $# -ge 2 ] || { echo "error: $1 needs a value" >&2; echo "$usage" >&2; exit 2; } ;;
|
|
55
|
+
esac
|
|
56
|
+
case "$1" in
|
|
57
|
+
--pr) pr="$2"; shift 2 ;;
|
|
58
|
+
--title) title="$2"; shift 2 ;;
|
|
59
|
+
--project) project="$2"; shift 2 ;;
|
|
60
|
+
--profile) profile="$2"; shift 2 ;;
|
|
61
|
+
*) echo "error: unknown flag $1" >&2; echo "$usage" >&2; exit 2 ;;
|
|
62
|
+
esac
|
|
63
|
+
done
|
|
64
|
+
|
|
65
|
+
TAB=$(printf '\t')
|
|
66
|
+
# One config per human: `${CLAUDE_CONFIG_DIR:-~/.claude}/cohorte.config.yaml`. COHORTE_CONFIG
|
|
67
|
+
# overrides it (tests, or a second board set).
|
|
68
|
+
CONFIG="${COHORTE_CONFIG:-${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte.config.yaml}"
|
|
69
|
+
|
|
70
|
+
# The nine pipeline stages and their default headings. A stage key given as the
|
|
71
|
+
# target column is mapped through the config (per-board `columns` first, then the
|
|
72
|
+
# global `kanban.columns`) and falls back to these — so a stage key works even
|
|
73
|
+
# with an explicit board path and no config at all. Anything not in this list is
|
|
74
|
+
# taken as a literal heading, which keeps hand-written columns working.
|
|
75
|
+
default_heading() {
|
|
76
|
+
case "$1" in
|
|
77
|
+
ideas) echo "Ideas" ;;
|
|
78
|
+
brainstorm) echo "Brainstorm" ;;
|
|
79
|
+
spec) echo "Spec" ;;
|
|
80
|
+
ready) echo "Ready to build" ;;
|
|
81
|
+
building) echo "Building" ;;
|
|
82
|
+
review) echo "Review" ;;
|
|
83
|
+
fix) echo "Fix" ;;
|
|
84
|
+
ship) echo "Ship" ;;
|
|
85
|
+
shipped) echo "Shipped" ;;
|
|
86
|
+
*) echo "" ;;
|
|
87
|
+
esac
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
# Read `name:` from the profile's `yaml pipeline-profile` block. Only the block —
|
|
91
|
+
# a `name:` under some other key (a surface, a persona) is not the project name.
|
|
92
|
+
read_project_name() {
|
|
93
|
+
[ -f "$1" ] || return 0
|
|
94
|
+
awk '
|
|
95
|
+
/^```[ \t]*yaml[ \t]+pipeline-profile/ { inblock = 1; next }
|
|
96
|
+
/^```/ { if (inblock) exit }
|
|
97
|
+
inblock && /^name:[ \t]/ {
|
|
98
|
+
v = $0; sub(/^name:[ \t]*/, "", v)
|
|
99
|
+
sub(/[ \t]+#.*$/, "", v); sub(/[ \t]+$/, "", v)
|
|
100
|
+
gsub(/^["\047]|["\047]$/, "", v)
|
|
101
|
+
print v; exit
|
|
102
|
+
}
|
|
103
|
+
' "$1"
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# Minimal YAML reader for the fixed shape the installer writes. Not a general
|
|
107
|
+
# parser: it walks an indent stack and emits only the handful of paths the kanban
|
|
108
|
+
# mirror needs, resolved against the project name we were given (so a name with a
|
|
109
|
+
# dot in it still matches — the comparison is on whole strings, not a joined key).
|
|
110
|
+
read_config() {
|
|
111
|
+
PROJ="$1" awk '
|
|
112
|
+
function clean(v, c, q, i, ch, out) {
|
|
113
|
+
sub(/^[ \t]+/, "", v)
|
|
114
|
+
if (v == "") return ""
|
|
115
|
+
c = substr(v, 1, 1)
|
|
116
|
+
if (c == "\"" || c == "\047") {
|
|
117
|
+
q = c; out = ""
|
|
118
|
+
for (i = 2; i <= length(v); i++) {
|
|
119
|
+
ch = substr(v, i, 1)
|
|
120
|
+
if (ch == q) break
|
|
121
|
+
out = out ch
|
|
122
|
+
}
|
|
123
|
+
return out
|
|
124
|
+
}
|
|
125
|
+
sub(/[ \t]+#.*$/, "", v); sub(/[ \t]+$/, "", v)
|
|
126
|
+
return v
|
|
127
|
+
}
|
|
128
|
+
# `columns: { ideas: "Idées", ready: "Prêt" }` — the flow form the config
|
|
129
|
+
# template documents for a per-board override.
|
|
130
|
+
function flow(path, v, n, i, parts, p, k) {
|
|
131
|
+
sub(/^\{[ \t]*/, "", v); sub(/[ \t]*\}[ \t]*$/, "", v)
|
|
132
|
+
n = split(v, parts, ",")
|
|
133
|
+
for (i = 1; i <= n; i++) {
|
|
134
|
+
p = index(parts[i], ":")
|
|
135
|
+
if (p == 0) continue
|
|
136
|
+
k = substr(parts[i], 1, p - 1)
|
|
137
|
+
gsub(/^[ \t]+|[ \t]+$/, "", k)
|
|
138
|
+
emit(path "." k, clean(substr(parts[i], p + 1)))
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function emit(path, v, stage) {
|
|
142
|
+
if (v == "") return
|
|
143
|
+
if (path == "enabled") { print "ENABLED\t" v; return }
|
|
144
|
+
if (path == "kanban.enabled") { print "KENABLED\t" v; return }
|
|
145
|
+
if (path == "obsidian.vault_path") { print "VAULT\t" v; return }
|
|
146
|
+
if (path == "kanban.boards." proj ".board") { print "BOARD\t" v; return }
|
|
147
|
+
if (index(path, "kanban.columns.") == 1) {
|
|
148
|
+
print "COL." substr(path, length("kanban.columns.") + 1) "\t" v; return
|
|
149
|
+
}
|
|
150
|
+
if (index(path, "kanban.boards." proj ".columns.") == 1) {
|
|
151
|
+
print "BCOL." substr(path, length("kanban.boards." proj ".columns.") + 1) "\t" v; return
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
BEGIN { proj = ENVIRON["PROJ"]; top = 0 }
|
|
155
|
+
{
|
|
156
|
+
line = $0; sub(/\r$/, "", line)
|
|
157
|
+
if (line ~ /^[ \t]*$/ || line ~ /^[ \t]*#/) next
|
|
158
|
+
match(line, /^[ ]*/); ind = RLENGTH
|
|
159
|
+
rest = substr(line, ind + 1)
|
|
160
|
+
if (rest ~ /^- /) next
|
|
161
|
+
p = index(rest, ":")
|
|
162
|
+
if (p == 0) next
|
|
163
|
+
key = substr(rest, 1, p - 1)
|
|
164
|
+
if (key ~ /[ \t]/) next
|
|
165
|
+
raw = substr(rest, p + 1)
|
|
166
|
+
while (top > 0 && indent[top] >= ind) top--
|
|
167
|
+
top++; indent[top] = ind; keyat[top] = key
|
|
168
|
+
path = ""
|
|
169
|
+
for (i = 1; i <= top; i++) path = path (i > 1 ? "." : "") keyat[i]
|
|
170
|
+
sub(/^[ \t]+/, "", raw)
|
|
171
|
+
if (substr(raw, 1, 1) == "{") { flow(path, raw); next }
|
|
172
|
+
emit(path, clean(raw))
|
|
173
|
+
}
|
|
174
|
+
' "$CONFIG"
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
off() { echo "kanban: $1"; exit 0; }
|
|
178
|
+
|
|
179
|
+
cfg=""
|
|
180
|
+
if [ "$board" = auto ] || [ -n "$(default_heading "$col")" ]; then
|
|
181
|
+
[ -n "$project" ] || project=$(read_project_name "$profile")
|
|
182
|
+
[ -f "$CONFIG" ] && cfg=$(read_config "$project") || cfg=""
|
|
183
|
+
fi
|
|
184
|
+
|
|
185
|
+
# ── resolve the board ───────────────────────────────────────────────────────
|
|
186
|
+
if [ "$board" = auto ]; then
|
|
187
|
+
[ -f "$CONFIG" ] || off "no config at $CONFIG — board mirror off"
|
|
188
|
+
vault=""; rel=""; enabled=""; kenabled=""
|
|
189
|
+
OLDIFS=$IFS; IFS=$TAB
|
|
190
|
+
while read -r k v; do
|
|
191
|
+
case "$k" in
|
|
192
|
+
ENABLED) enabled=$v ;;
|
|
193
|
+
KENABLED) kenabled=$v ;;
|
|
194
|
+
VAULT) vault=$v ;;
|
|
195
|
+
BOARD) rel=$v ;;
|
|
196
|
+
esac
|
|
197
|
+
done <<EOF
|
|
198
|
+
$cfg
|
|
199
|
+
EOF
|
|
200
|
+
IFS=$OLDIFS
|
|
201
|
+
[ "$enabled" != false ] || off "cohorte capabilities disabled (enabled: false in $CONFIG)"
|
|
202
|
+
[ "$kenabled" != false ] || off "disabled in $CONFIG (kanban.enabled: false)"
|
|
203
|
+
[ -n "$project" ] || off "no project name in $profile — cannot resolve a board"
|
|
204
|
+
[ -n "$rel" ] || off "no board configured for project \"$project\" in $CONFIG"
|
|
205
|
+
[ -n "$vault" ] || off "obsidian.vault_path not set in $CONFIG"
|
|
206
|
+
board="$vault/$rel"
|
|
207
|
+
[ -f "$board" ] || off "board file not found: $board"
|
|
208
|
+
if $check_only; then echo "kanban: project \"$project\" -> $board"; exit 0; fi
|
|
209
|
+
fi
|
|
210
|
+
|
|
211
|
+
# ── resolve the column ──────────────────────────────────────────────────────
|
|
212
|
+
# A stage key becomes a heading; a literal heading passes through untouched.
|
|
213
|
+
if [ -n "$(default_heading "$col")" ]; then
|
|
214
|
+
heading=""
|
|
215
|
+
OLDIFS=$IFS; IFS=$TAB
|
|
216
|
+
while read -r k v; do
|
|
217
|
+
case "$k" in
|
|
218
|
+
"BCOL.$col") heading=$v ;;
|
|
219
|
+
"COL.$col") [ -n "$heading" ] || heading=$v ;;
|
|
220
|
+
esac
|
|
221
|
+
done <<EOF
|
|
222
|
+
$cfg
|
|
223
|
+
EOF
|
|
224
|
+
IFS=$OLDIFS
|
|
225
|
+
[ -n "$heading" ] || heading=$(default_heading "$col")
|
|
226
|
+
col="$heading"
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
[ -f "$board" ] || { echo "error: board not found: $board" >&2; exit 3; }
|
|
230
|
+
|
|
231
|
+
# Serialize the read-modify-write: parallel worktrees (/cohorte-fleet, the loop workflow) move
|
|
232
|
+
# cards on ONE board, and two concurrent rewrites used to lose one of the moves.
|
|
233
|
+
# Where flock(1) exists (Linux), the kernel holds the lock and drops it if we die; the lock file
|
|
234
|
+
# lives in $TMPDIR keyed by the board's path, never next to the board in the human's vault.
|
|
235
|
+
# Elsewhere (macOS has no flock) an atomic `mkdir` is the lock and the holder's PID marks it: a
|
|
236
|
+
# lock is stale only when that process is gone, never by age. COHORTE_KANBAN_NO_FLOCK=1 forces
|
|
237
|
+
# the fallback (tests).
|
|
238
|
+
lock="${board}.lock"
|
|
239
|
+
if [ -z "${COHORTE_KANBAN_NO_FLOCK:-}" ] && command -v flock >/dev/null 2>&1; then
|
|
240
|
+
flockfile="${TMPDIR:-/tmp}/cohorte-kanban-$(printf '%s' "$board" | cksum | cut -d' ' -f1).lock"
|
|
241
|
+
exec 9>"$flockfile"
|
|
242
|
+
if ! flock -w 30 9; then
|
|
243
|
+
echo "error: board is locked by another move ($flockfile) — retry" >&2
|
|
244
|
+
exit 4
|
|
245
|
+
fi
|
|
246
|
+
else
|
|
247
|
+
waited=0
|
|
248
|
+
until mkdir "$lock" 2>/dev/null; do
|
|
249
|
+
holder=$(cat "$lock/pid" 2>/dev/null || true)
|
|
250
|
+
if [ -n "$holder" ] && ! kill -0 "$holder" 2>/dev/null; then
|
|
251
|
+
# Dead holder. Remove only if it is still THAT lock (another waiter may have replaced it).
|
|
252
|
+
if [ "$(cat "$lock/pid" 2>/dev/null || true)" = "$holder" ]; then
|
|
253
|
+
rm -f "$lock/pid"; rmdir "$lock" 2>/dev/null || true
|
|
254
|
+
fi
|
|
255
|
+
continue
|
|
256
|
+
fi
|
|
257
|
+
waited=$((waited + 1))
|
|
258
|
+
if [ "$waited" -gt 300 ]; then
|
|
259
|
+
echo "error: board is locked by another move ($lock, pid ${holder:-?}) — retry, or remove the lock if no move is running" >&2
|
|
260
|
+
exit 4
|
|
261
|
+
fi
|
|
262
|
+
sleep 0.1 2>/dev/null || sleep 1
|
|
263
|
+
done
|
|
264
|
+
echo $$ > "$lock/pid"
|
|
265
|
+
# Release only our own lock, and never let the release change the exit status.
|
|
266
|
+
release() { [ "$(cat "$lock/pid" 2>/dev/null || true)" = "$$" ] && { rm -f "$lock/pid"; rmdir "$lock" 2>/dev/null; }; return 0; }
|
|
267
|
+
trap release EXIT
|
|
268
|
+
trap 'exit 130' INT
|
|
269
|
+
trap 'exit 143' TERM
|
|
270
|
+
fi
|
|
271
|
+
|
|
272
|
+
tmp="${board}.kanban-move.$$"
|
|
273
|
+
ID="$id" COL="$col" PR="$pr" TITLE="${title:-$id}" awk '
|
|
274
|
+
# Emit one line, collapsing runs of blank lines to a single one. Without this
|
|
275
|
+
# every move netted +1 blank line in the target column (the card is inserted
|
|
276
|
+
# with its own separator, right after the blank that already preceded the next
|
|
277
|
+
# heading) — ten moves of one card padded a board with fifteen blank lines.
|
|
278
|
+
function emit(s) {
|
|
279
|
+
if (s == "") { if (lastblank) return; lastblank = 1 } else lastblank = 0
|
|
280
|
+
print s
|
|
281
|
+
}
|
|
282
|
+
function put_card( k) {
|
|
283
|
+
emit(card)
|
|
284
|
+
for (k = 1; k <= sn; k++) emit(snote[k])
|
|
285
|
+
}
|
|
286
|
+
BEGIN {
|
|
287
|
+
id = ENVIRON["ID"]; col = tolower(ENVIRON["COL"])
|
|
288
|
+
pr = ENVIRON["PR"]; title = ENVIRON["TITLE"]
|
|
289
|
+
n = 0; card = ""; found = 0; colseen = 0; sn = 0; lastblank = 0
|
|
290
|
+
}
|
|
291
|
+
# Strip CR at capture: a CRLF board (Windows-synced vault) otherwise fails the
|
|
292
|
+
# `h == col` heading compare and exits 3 on a column that exists — while the
|
|
293
|
+
# config parser in this same script already strips \r. Emitting LF-only is fine
|
|
294
|
+
# (Obsidian reads both).
|
|
295
|
+
{ sub(/\r$/, ""); lines[++n] = $0 }
|
|
296
|
+
END {
|
|
297
|
+
# pass 1: extract the FIRST card block tagged #id; mark every block for removal
|
|
298
|
+
for (i = 1; i <= n; i++) {
|
|
299
|
+
l = lines[i]
|
|
300
|
+
if (l !~ /^- \[.\] /) continue
|
|
301
|
+
p = index(l, "#" id)
|
|
302
|
+
if (p == 0) continue
|
|
303
|
+
# word-boundary check: char after the tag must not extend the id
|
|
304
|
+
rest = substr(l, p + length(id) + 1, 1)
|
|
305
|
+
if (rest != "" && rest ~ /[A-Za-z0-9_-]/) continue
|
|
306
|
+
# Capture the sub-notes of the FIRST match only. Testing `card == lines[i]`
|
|
307
|
+
# instead also captured a later duplicate whose text happened to match.
|
|
308
|
+
isfirst = 0
|
|
309
|
+
if (!found) { found = 1; card = l; isfirst = 1 }
|
|
310
|
+
del[i] = 1
|
|
311
|
+
for (j = i + 1; j <= n && lines[j] ~ /^[ \t]/; j++) {
|
|
312
|
+
del[j] = 1
|
|
313
|
+
if (isfirst) snote[++sn] = lines[j]
|
|
314
|
+
}
|
|
315
|
+
i = j - 1
|
|
316
|
+
}
|
|
317
|
+
if (!found) card = "- [ ] " title " #" id
|
|
318
|
+
if (pr != "" && index(card, "PR #") == 0) card = card " — PR #" pr
|
|
319
|
+
|
|
320
|
+
# pass 2: emit, skipping removed blocks; append the card at the end of the
|
|
321
|
+
# target column (before the next ## heading / settings block / EOF)
|
|
322
|
+
intarget = 0; placed = 0
|
|
323
|
+
for (i = 1; i <= n; i++) {
|
|
324
|
+
if (del[i]) continue
|
|
325
|
+
l = lines[i]
|
|
326
|
+
atheading = (l ~ /^## /)
|
|
327
|
+
atsettings = (l ~ /^%% kanban:settings/)
|
|
328
|
+
if (intarget && (atheading || atsettings)) {
|
|
329
|
+
# can not back up over already-printed lines; place the card just before
|
|
330
|
+
# this boundary instead
|
|
331
|
+
put_card()
|
|
332
|
+
emit("")
|
|
333
|
+
intarget = 0; placed = 1
|
|
334
|
+
}
|
|
335
|
+
if (atheading) {
|
|
336
|
+
h = tolower(l); sub(/^## +/, "", h); gsub(/ +$/, "", h)
|
|
337
|
+
if (h == col) { intarget = 1; colseen = 1 }
|
|
338
|
+
}
|
|
339
|
+
emit(l)
|
|
340
|
+
}
|
|
341
|
+
if (intarget && !placed) {
|
|
342
|
+
put_card()
|
|
343
|
+
placed = 1
|
|
344
|
+
}
|
|
345
|
+
if (!colseen) exit 3
|
|
346
|
+
}
|
|
347
|
+
' "$board" > "$tmp" || { rc=$?; rm -f "$tmp"; [ "$rc" = 3 ] && echo "error: column \"$col\" not found in $board" >&2; exit "$rc"; }
|
|
348
|
+
mv "$tmp" "$board"
|
|
349
|
+
echo "moved #$id -> $col${pr:+ (PR #$pr)}"
|