cohorte 4.1.0 → 4.1.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ short, user-facing, most recent first. One `## <version> — <YYYY-MM-DD>` secti
7
7
  > They are history and are deliberately not rewritten — every command gained a `cohorte-` prefix
8
8
  > in 2.0.0.
9
9
 
10
+ ## 4.1.1 — 2026-11-24
11
+
12
+ - **A malformed profile no longer switches checks off.** When the profile reader returned each nested
13
+ field as a JSON string, `/cohorte-review`, `/cohorte-loop`, `/cohorte-audit` and `/cohorte-refactor` read
14
+ `commands` and `contract` as plain text: preflight ran no check and the contract gate was off, with no
15
+ error. Those fields are now decoded.
16
+ - **No more gate denials on `<core>` scripts.** Workflow agents now resolve the core path once and write it
17
+ out literally, instead of running a command name held in a shell expression, which the gate refuses.
18
+
10
19
  ## 4.1.0 — 2026-11-20
11
20
 
12
21
  - **New project, from `cohorte ui`.** Start a project that does not exist yet — no terminal, no
@@ -71,17 +71,24 @@ const PROFILE = {
71
71
  // return, or nested under a single wrapper field. Anything already shaped like a profile
72
72
  // (has `surfaces`, or is the documented `{error}` failure shape) passes through untouched.
73
73
  const unwrapProfile = p => {
74
- if (typeof p === 'string') { try { return JSON.parse(p) } catch { return null } }
75
- if (!p || typeof p !== 'object') return null
76
- if (Array.isArray(p.surfaces) || p.error) return p
77
- for (const v of Object.values(p)) {
78
- if (typeof v !== 'string') continue
74
+ // The reader may also serialize each nested value while keeping the top level.
75
+ const decode = o => Object.fromEntries(Object.entries(o).map(([k, v]) => {
76
+ if (typeof v !== 'string' || !/^\s*[[{]/.test(v)) return [k, v]
79
77
  try {
80
- const inner = JSON.parse(v)
81
- if (inner && typeof inner === 'object' && !Array.isArray(inner)) return inner
82
- } catch {}
78
+ const parsed = JSON.parse(v)
79
+ return [k, parsed && typeof parsed === 'object' ? parsed : v]
80
+ } catch { return [k, v] }
81
+ }))
82
+ if (typeof p === 'string') { try { p = JSON.parse(p) } catch { return null } }
83
+ if (!p || typeof p !== 'object' || Array.isArray(p)) return null
84
+ const flat = decode(p)
85
+ if (Array.isArray(flat.surfaces) || flat.error) return flat
86
+ for (const v of Object.values(flat)) {
87
+ if (!v || typeof v !== 'object' || Array.isArray(v)) continue
88
+ const inner = decode(v)
89
+ if (Array.isArray(inner.surfaces)) return inner
83
90
  }
84
- return p
91
+ return flat
85
92
  }
86
93
 
87
94
  const GATES = {
@@ -152,17 +152,24 @@ const PROFILE = {
152
152
  },
153
153
  }
154
154
  const unwrapProfile = p => {
155
- if (typeof p === 'string') { try { return JSON.parse(p) } catch { return null } }
156
- if (!p || typeof p !== 'object') return null
157
- if (Array.isArray(p.surfaces) || p.error) return p
158
- for (const v of Object.values(p)) {
159
- if (typeof v !== 'string') continue
155
+ // The reader may also serialize each nested value while keeping the top level.
156
+ const decode = o => Object.fromEntries(Object.entries(o).map(([k, v]) => {
157
+ if (typeof v !== 'string' || !/^\s*[[{]/.test(v)) return [k, v]
160
158
  try {
161
- const inner = JSON.parse(v)
162
- if (inner && typeof inner === 'object' && !Array.isArray(inner)) return inner
163
- } catch {}
159
+ const parsed = JSON.parse(v)
160
+ return [k, parsed && typeof parsed === 'object' ? parsed : v]
161
+ } catch { return [k, v] }
162
+ }))
163
+ if (typeof p === 'string') { try { p = JSON.parse(p) } catch { return null } }
164
+ if (!p || typeof p !== 'object' || Array.isArray(p)) return null
165
+ const flat = decode(p)
166
+ if (Array.isArray(flat.surfaces) || flat.error) return flat
167
+ for (const v of Object.values(flat)) {
168
+ if (!v || typeof v !== 'object' || Array.isArray(v)) continue
169
+ const inner = decode(v)
170
+ if (Array.isArray(inner.surfaces)) return inner
164
171
  }
165
- return p
172
+ return flat
166
173
  }
167
174
 
168
175
  // The precondition agent returns RAW FACTS (existence, mtimes, front-matter fields,
@@ -248,7 +255,7 @@ const spent = () => {
248
255
 
249
256
  // kanban-move.sh is optional infrastructure — every prompt that runs it defines <core>
250
257
  // and tolerates its absence, per profile/schema/kanban.md.
251
- const CORE_DEF = '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte" — ' +
258
+ const CORE_DEF = '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable — ' +
252
259
  'script absent ⇒ skip the kanban step, the board is optional.)'
253
260
  const METRICS_PATH = '$(dirname "$(git rev-parse --git-common-dir)")/.claude/pipeline-metrics.jsonl'
254
261
 
@@ -87,17 +87,24 @@ const PROFILE = {
87
87
  // return, or nested under a single wrapper field. Anything already shaped like a profile
88
88
  // (has `surfaces`, or is the documented `{error}` failure shape) passes through untouched.
89
89
  const unwrapProfile = p => {
90
- if (typeof p === 'string') { try { return JSON.parse(p) } catch { return null } }
91
- if (!p || typeof p !== 'object') return null
92
- if (Array.isArray(p.surfaces) || p.error) return p
93
- for (const v of Object.values(p)) {
94
- if (typeof v !== 'string') continue
90
+ // The reader may also serialize each nested value while keeping the top level.
91
+ const decode = o => Object.fromEntries(Object.entries(o).map(([k, v]) => {
92
+ if (typeof v !== 'string' || !/^\s*[[{]/.test(v)) return [k, v]
95
93
  try {
96
- const inner = JSON.parse(v)
97
- if (inner && typeof inner === 'object' && !Array.isArray(inner)) return inner
98
- } catch {}
94
+ const parsed = JSON.parse(v)
95
+ return [k, parsed && typeof parsed === 'object' ? parsed : v]
96
+ } catch { return [k, v] }
97
+ }))
98
+ if (typeof p === 'string') { try { p = JSON.parse(p) } catch { return null } }
99
+ if (!p || typeof p !== 'object' || Array.isArray(p)) return null
100
+ const flat = decode(p)
101
+ if (Array.isArray(flat.surfaces) || flat.error) return flat
102
+ for (const v of Object.values(flat)) {
103
+ if (!v || typeof v !== 'object' || Array.isArray(v)) continue
104
+ const inner = decode(v)
105
+ if (Array.isArray(inner.surfaces)) return inner
99
106
  }
100
- return p
107
+ return flat
101
108
  }
102
109
 
103
110
  const OPEN = {
@@ -195,7 +202,7 @@ const implementPrompt = d =>
195
202
  'FIRST (pin current behavior / cover the entry points), watch them pass, THEN refactor to clear each ' +
196
203
  'item. Preserve current public behavior unless an item marks it a bug. Migrations stay additive. ' +
197
204
  `Need the current state of your tree? Compute it yourself: <core>/pipeline/scripts/feature-diff.sh --default ${base} --patch -- <your surface path> ` +
198
- '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"; never a bare git diff — it hides files you created). ' +
205
+ '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable; never a bare git diff — it hides files you created). ' +
199
206
  'Lint + format before handoff; return the handoff in the format your agent instructions define. ' +
200
207
  'Backlog items for YOUR surface (self-contained — clear exactly these, reading only the files they name):\n' +
201
208
  d.items.join('\n')
@@ -351,7 +358,7 @@ if (wantSpec) {
351
358
  `3. \`git rev-parse --abbrev-ref HEAD\`: on ${base} ⇒ \`git switch -c ${prefix}ID\` (uncommitted work carries over); ` +
352
359
  `already on ${prefix}ID ⇒ keep it; any other branch ⇒ leave it and report it. ` +
353
360
  `4. \`<core>/pipeline/scripts/kanban-move.sh auto ID ready --title "[refactor] ${slug}"\` ` +
354
- '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"). ' +
361
+ '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable). ' +
355
362
  'Return id (ID), branch (checked out now) and kanban (the line the script printed).\n' +
356
363
  `<<<SPEC\n${specText}SPEC`,
357
364
  { model: 'haiku', label: 'write-spec', schema: SPEC, effort: 'low' },
@@ -92,17 +92,24 @@ const PROFILE = {
92
92
  // return, or nested under a single wrapper field. Anything already shaped like a profile
93
93
  // (has `surfaces`, or is the documented `{error}` failure shape) passes through untouched.
94
94
  const unwrapProfile = p => {
95
- if (typeof p === 'string') { try { return JSON.parse(p) } catch { return null } }
96
- if (!p || typeof p !== 'object') return null
97
- if (Array.isArray(p.surfaces) || p.error) return p
98
- for (const v of Object.values(p)) {
99
- if (typeof v !== 'string') continue
95
+ // The reader may also serialize each nested value while keeping the top level.
96
+ const decode = o => Object.fromEntries(Object.entries(o).map(([k, v]) => {
97
+ if (typeof v !== 'string' || !/^\s*[[{]/.test(v)) return [k, v]
100
98
  try {
101
- const inner = JSON.parse(v)
102
- if (inner && typeof inner === 'object' && !Array.isArray(inner)) return inner
103
- } catch {}
99
+ const parsed = JSON.parse(v)
100
+ return [k, parsed && typeof parsed === 'object' ? parsed : v]
101
+ } catch { return [k, v] }
102
+ }))
103
+ if (typeof p === 'string') { try { p = JSON.parse(p) } catch { return null } }
104
+ if (!p || typeof p !== 'object' || Array.isArray(p)) return null
105
+ const flat = decode(p)
106
+ if (Array.isArray(flat.surfaces) || flat.error) return flat
107
+ for (const v of Object.values(flat)) {
108
+ if (!v || typeof v !== 'object' || Array.isArray(v)) continue
109
+ const inner = decode(v)
110
+ if (Array.isArray(inner.surfaces)) return inner
104
111
  }
105
- return p
112
+ return flat
106
113
  }
107
114
 
108
115
  const PREFLIGHT = {
@@ -221,7 +228,7 @@ const pre = await agent(
221
228
  '`date +%s` (return that number as `epoch` — the run\'s wall-clock origin for the metrics line):\n' +
222
229
  `<core>/pipeline/scripts/preflight.sh ${preflightReport} ` +
223
230
  checks.map(shq).join(' ') + '\n' +
224
- '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte". ' +
231
+ '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable. ' +
225
232
  'Script absent: run the quoted commands yourself, each appended to the same report file, stopping at the first failure.) ' +
226
233
  'Return pass=true only on a fully green run. On failure set pass=false, put the raw last 40 lines of the report ' +
227
234
  'in `tail` — verbatim, no summarizing — and in the same Bash call write the degraded machine verdict the ' +
@@ -250,7 +257,7 @@ const surfaceList = surfaces.map(s => `${s.key} → ${s.path}`).join(' · ') ||
250
257
  const FD = `<core>/pipeline/scripts/feature-diff.sh --default ${base}`
251
258
  const staged = await agent(
252
259
  `Stage the review inputs for cohorte feature ${feature}. Surfaces: ${surfaceList}. ` +
253
- '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte".) Never use a bare `git diff` — it misses untracked files.\n' +
260
+ '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable.) Never use a bare `git diff` — it misses untracked files.\n' +
254
261
  `1. ONE call: ${FD} --numstat > specs/reports/${feature}.stat.txt — never print it. Non-zero exit or script ` +
255
262
  'absent ⇒ return `error` with its stderr line and an empty surfaces array, and do nothing else.\n' +
256
263
  '2. Group the changed paths (3rd tab-separated column) by surface path prefix with one awk; paths under no surface are the `shared` remainder — attach them to the most relevant surface.\n' +
@@ -426,7 +433,7 @@ const verdictJson = JSON.stringify({
426
433
  })
427
434
  const staging = await agent(
428
435
  `Stage a cohorte review report and its metrics, mechanically ` +
429
- '(<core> = "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"):\n' +
436
+ '(<core> = the absolute path printed by `printf %s "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/cohorte"`. Run that lookup alone first (it does not count as any "one Bash call" below), then write the path out literally in every command: the gate denies a command name held in a variable):\n' +
430
437
  `1. Write EXACTLY this content to specs/reports/${feature}.md (overwrite):\n<<<REPORT\n${reportBody}\nREPORT\n` +
431
438
  `2. Write EXACTLY this to specs/reports/${feature}.verdict.json (overwrite), substituting <ISO now> with ` +
432
439
  '`date -u +%Y-%m-%dT%H:%M:%SZ` and <FP> with the fingerprint — computed in Bash, never by hand: ' +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cohorte",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "Multi-agent development pipeline for Claude Code — install it once, run /cohorte-init-pipeline in a repo, and it adapts to that project's stack.",
5
5
  "bin": {
6
6
  "cohorte": "bin/cli.js"