cohorte 3.3.0 → 4.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +23 -3
  3. package/core/agents/cohorte-review.md +11 -3
  4. package/core/agents/implementer.template.md +19 -1
  5. package/core/commands/cohorte-acceptance.md +35 -0
  6. package/core/commands/cohorte-build.md +17 -0
  7. package/core/commands/cohorte-fix.md +6 -0
  8. package/core/commands/cohorte-foundation.md +90 -0
  9. package/core/commands/cohorte-lead.md +90 -0
  10. package/core/commands/cohorte-learn.md +67 -0
  11. package/core/commands/cohorte-po.md +76 -0
  12. package/core/commands/cohorte-product-map.md +53 -0
  13. package/core/commands/cohorte-retro.md +44 -13
  14. package/core/commands/cohorte-scaffold.md +59 -0
  15. package/core/commands/cohorte-vision.md +80 -0
  16. package/lib/install.js +2 -0
  17. package/lib/project.js +1 -1
  18. package/lib/registry.js +4 -3
  19. package/package.json +2 -2
  20. package/profile/PIPELINE.template.md +3 -1
  21. package/profile/schema/kanban.md +23 -0
  22. package/scripts/kanban-move.sh +45 -11
  23. package/ui/dist-server/server/agents.js +100 -0
  24. package/ui/dist-server/server/decider.js +241 -0
  25. package/ui/dist-server/server/features.js +128 -0
  26. package/ui/dist-server/server/flow.js +934 -0
  27. package/ui/dist-server/server/founding.js +706 -0
  28. package/ui/dist-server/server/gitinfo.js +22 -0
  29. package/ui/dist-server/server/history.js +10 -3
  30. package/ui/dist-server/server/legacy.js +3 -1
  31. package/ui/dist-server/server/next.js +91 -0
  32. package/ui/dist-server/server/runs.js +73 -11
  33. package/ui/dist-server/server/server.js +222 -6
  34. package/ui/dist-server/server/settings.js +81 -0
  35. package/ui/dist-server/server/tracker.js +438 -0
  36. package/ui/dist-server/shared/blocks.js +165 -0
  37. package/ui/dist-web/assets/index-BfN944Jm.js +165 -0
  38. package/ui/dist-web/assets/{style-0oNNMjwU.css → style-BMfadlCl.css} +1 -1
  39. package/ui/dist-web/index.html +2 -2
  40. package/ui/dist-web/assets/index-Clp1YW4S.js +0 -152
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ // The company flow's agents never write tickets, plans or acceptance notes themselves: they put them in a fenced
3
+ // block of their reply, and the server — which owns the tracker and the checkpoints — reads it. This keeps the
4
+ // business-facing agents read-only, and makes every artifact a human validates something the server parsed and
5
+ // can show as-is.
6
+ //
7
+ // ```cohorte-ticket one ticket proposal (PO) → TicketProposal
8
+ // ```cohorte-plan the lead's plan, what CP1 validates → Plan
9
+ // ```cohorte-acceptance the PO's acceptance note (CP4) → AcceptanceNote (minus `at`)
10
+ // ```cohorte-vision a new product's vision (PO) → Vision
11
+ // ```cohorte-foundation a new project's stack (lead) → Foundation
12
+ // ```cohorte-scaffold the skeleton's report → ScaffoldReport
13
+ //
14
+ // Everything here is pure and total: malformed JSON or a missing field yields null or a default, never a throw.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.SIZES = exports.PRIORITIES = exports.TYPES = void 0;
17
+ exports.blocksOf = blocksOf;
18
+ exports.stripBlocks = stripBlocks;
19
+ exports.slug = slug;
20
+ exports.toProposal = toProposal;
21
+ exports.toPlan = toPlan;
22
+ exports.toAcceptance = toAcceptance;
23
+ exports.toVision = toVision;
24
+ exports.toFoundation = toFoundation;
25
+ exports.toScaffold = toScaffold;
26
+ exports.lastOf = lastOf;
27
+ exports.proposalsOf = proposalsOf;
28
+ /** Every ```<kind> block in `text`, parsed as JSON (blocks that do not parse are skipped). */
29
+ function blocksOf(text, kind) {
30
+ const out = [];
31
+ const re = new RegExp('```' + kind + '[^\\n]*\\n([\\s\\S]*?)\\n?```', 'g');
32
+ for (const m of text.matchAll(re)) {
33
+ try {
34
+ out.push(JSON.parse(m[1]));
35
+ }
36
+ catch { /* skipped: the chat still shows the text */ }
37
+ }
38
+ return out;
39
+ }
40
+ /** The text with its machine blocks removed — what a person reads in the chat. */
41
+ function stripBlocks(text) {
42
+ return text.replace(/```cohorte-(ticket|plan|acceptance|vision|foundation|scaffold)[^\n]*\n[\s\S]*?\n?```/g, '').replace(/\n{3,}/g, '\n\n').trim();
43
+ }
44
+ const str = (v, max = 4000) => (typeof v === 'string' ? v.trim().slice(0, max) : '');
45
+ const list = (v, max = 40) => (Array.isArray(v) ? v.map((x) => str(x, 1000)).filter(Boolean).slice(0, max) : []);
46
+ const oneOf = (v, all, dflt) => (typeof v === 'string' && all.includes(v) ? v : dflt);
47
+ exports.TYPES = ['feature', 'bug', 'tech'];
48
+ exports.PRIORITIES = ['high', 'medium', 'low'];
49
+ exports.SIZES = ['S', 'M', 'L', '?'];
50
+ function slug(s, max = 48) {
51
+ const out = s.normalize('NFKD').replace(/[̀-ͯ]/g, '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
52
+ return out.slice(0, max).replace(/-+$/, '') || 'ticket';
53
+ }
54
+ function toProposal(v) {
55
+ if (!v || typeof v !== 'object')
56
+ return null;
57
+ const o = v;
58
+ const title = str(o.title, 200);
59
+ if (!title)
60
+ return null;
61
+ return {
62
+ ref: slug(str(o.ref, 60) || title, 60), title, type: oneOf(o.type, exports.TYPES, 'feature'),
63
+ need: str(o.need), value: str(o.value), criteria: list(o.criteria), outOfScope: list(o.outOfScope ?? o.out_of_scope),
64
+ priority: oneOf(o.priority, exports.PRIORITIES, 'medium'), size: oneOf(o.size, exports.SIZES, '?'), parent: str(o.parent, 100) || null,
65
+ };
66
+ }
67
+ function toPlan(v) {
68
+ if (!v || typeof v !== 'object')
69
+ return null;
70
+ const o = v;
71
+ const summary = str(o.summary);
72
+ if (!summary)
73
+ return null;
74
+ const criteria = (Array.isArray(o.criteria) ? o.criteria : []).map((c, i) => {
75
+ if (typeof c === 'string')
76
+ return { id: `C${i + 1}`, text: c.trim() };
77
+ const r = (c || {});
78
+ return { id: str(r.id, 12) || `C${i + 1}`, text: str(r.text, 1000) };
79
+ }).filter((c) => c.text).slice(0, 40);
80
+ const surfaces = (Array.isArray(o.surfaces) ? o.surfaces : []).map((x) => {
81
+ const r = (x || {});
82
+ return { key: str(r.key, 60), tasks: list(r.tasks) };
83
+ }).filter((x) => x.key).slice(0, 20);
84
+ return { summary, criteria, contract: str(o.contract), surfaces, risks: list(o.risks), assumptions: list(o.assumptions), questions: list(o.questions), size: oneOf(o.size, exports.SIZES, '?') };
85
+ }
86
+ function toAcceptance(v) {
87
+ if (!v || typeof v !== 'object')
88
+ return null;
89
+ const o = v;
90
+ const summary = str(o.summary);
91
+ if (!summary)
92
+ return null;
93
+ return { summary, changes: list(o.changes), howToTest: list(o.howToTest ?? o.how_to_test), outOfScope: list(o.outOfScope ?? o.out_of_scope) };
94
+ }
95
+ function toVision(v) {
96
+ if (!v || typeof v !== 'object')
97
+ return null;
98
+ const o = v;
99
+ const pitch = str(o.pitch, 1000);
100
+ const firstVersion = list(o.firstVersion ?? o.first_version);
101
+ if (!pitch || !firstVersion.length)
102
+ return null;
103
+ return { name: str(o.name, 120), pitch, users: list(o.users), problem: str(o.problem), today: str(o.today), firstVersion, later: list(o.later),
104
+ success: str(o.success, 1000), constraints: list(o.constraints), language: str(o.language, 60) };
105
+ }
106
+ const cmd = (v) => str(v, 400).replace(/[\r\n]+/g, ' ');
107
+ function toFoundation(v) {
108
+ if (!v || typeof v !== 'object')
109
+ return null;
110
+ const o = v;
111
+ const summary = str(o.summary);
112
+ const surfaces = (Array.isArray(o.surfaces) ? o.surfaces : []).map((x) => {
113
+ const r = (x || {});
114
+ const raw = str(r.key, 40);
115
+ const key = raw ? slug(raw, 40) : '';
116
+ return { key, path: str(r.path, 120).replace(/^\.?\/+/, '') || key, stack: str(r.stack, 300), generate: cmd(r.generate) || null,
117
+ packageManager: str(r.packageManager ?? r.package_manager, 20), test: cmd(r.test), lint: cmd(r.lint), build: cmd(r.build) };
118
+ }).filter((x) => x.key).slice(0, 12);
119
+ if (!summary || !surfaces.length)
120
+ return null;
121
+ return { summary, surfaces, data: str(o.data, 1000), auth: str(o.auth, 1000), hosting: str(o.hosting, 1000), devCommand: cmd(o.devCommand ?? o.dev_command), ci: str(o.ci, 1000),
122
+ basedOn: str(o.basedOn ?? o.based_on, 200) || null, conventions: list(o.conventions), skeleton: str(o.skeleton, 1000), decisions: list(o.decisions),
123
+ assumptions: list(o.assumptions), questions: list(o.questions) };
124
+ }
125
+ function toScaffold(v) {
126
+ if (!v || typeof v !== 'object')
127
+ return null;
128
+ const o = v;
129
+ if (o.status !== 'ok' && o.status !== 'failed')
130
+ return null;
131
+ const surfaces = (Array.isArray(o.surfaces) ? o.surfaces : []).map((x) => {
132
+ const r = (x || {});
133
+ return { key: str(r.key, 40), path: str(r.path, 120), test: cmd(r.test), lint: cmd(r.lint), build: cmd(r.build), ok: r.ok === true };
134
+ }).filter((x) => x.key).slice(0, 12);
135
+ const checks = (Array.isArray(o.checks) ? o.checks : []).map((x) => {
136
+ const r = (x || {});
137
+ return { command: cmd(r.command), ok: r.ok === true, note: str(r.note, 500) };
138
+ }).filter((x) => x.command).slice(0, 40);
139
+ return { status: o.status, surfaces, devCommand: cmd(o.devCommand ?? o.dev_command), checks, assumptions: list(o.assumptions), notes: str(o.notes, 2000) };
140
+ }
141
+ /** The last parseable block of `kind` across a run's text events, in order. */
142
+ function lastOf(texts, kind, conv) {
143
+ for (let i = texts.length - 1; i >= 0; i--) {
144
+ const bs = blocksOf(texts[i], kind);
145
+ for (let j = bs.length - 1; j >= 0; j--) {
146
+ const t = conv(bs[j]);
147
+ if (t)
148
+ return t;
149
+ }
150
+ }
151
+ return null;
152
+ }
153
+ /** Every proposal across texts, the LAST revision of each ref winning. */
154
+ function proposalsOf(texts) {
155
+ const by = new Map();
156
+ for (const t of texts)
157
+ for (const b of blocksOf(t, 'cohorte-ticket')) {
158
+ const p = toProposal(b);
159
+ if (p) {
160
+ by.delete(p.ref);
161
+ by.set(p.ref, p);
162
+ }
163
+ }
164
+ return [...by.values()];
165
+ }