cohorte 4.0.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.
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ // What every agent run of the company flow (and of founding a project) shares: how a /cohorte-* command becomes a
3
+ // prompt, the context block the dashboard appends, the MCP diet, the autopilot's rules.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
37
+ var __importDefault = (this && this.__importDefault) || function (mod) {
38
+ return (mod && mod.__esModule) ? mod : { "default": mod };
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.AUTOPILOT_NOTE = exports.contextBlock = exports.readText = exports.textsOf = exports.mcp = exports.now = exports.FlowError = exports.READ_ONLY = void 0;
42
+ exports.expandCommand = expandCommand;
43
+ const fs_1 = __importDefault(require("fs"));
44
+ const path_1 = __importDefault(require("path"));
45
+ const ops = __importStar(require("./ops"));
46
+ /** The business-facing agents read; they never write, run or delegate. The server writes what they propose. */
47
+ exports.READ_ONLY = ['Bash', 'Edit', 'Write', 'NotebookEdit', 'Agent', 'Task'];
48
+ class FlowError extends ops.OpError {
49
+ }
50
+ exports.FlowError = FlowError;
51
+ const now = () => new Date().toISOString();
52
+ exports.now = now;
53
+ /**
54
+ * Every flow run loads only the project's own MCP servers. A user's machine-wide servers (mail, docs, design tools…)
55
+ * can weigh 200k+ tokens of tool schemas on EVERY turn — measured at 230k for a one-word reply — and no PO, lead or
56
+ * pipeline stage needs them. The project's .mcp.json (a retrieval provider, say) is still loaded.
57
+ */
58
+ const mcp = (cwd) => {
59
+ const f = path_1.default.join(cwd, '.mcp.json');
60
+ return { strictMcp: true, mcpConfig: fs_1.default.existsSync(f) ? f : null };
61
+ };
62
+ exports.mcp = mcp;
63
+ const textsOf = (events) => events.filter((e) => e.kind === 'text').map((e) => e.text);
64
+ exports.textsOf = textsOf;
65
+ const readText = (p) => { try {
66
+ return fs_1.default.readFileSync(p, 'utf8');
67
+ }
68
+ catch {
69
+ return '';
70
+ } };
71
+ exports.readText = readText;
72
+ /** The body of an installed /cohorte-* command, its $ARGUMENTS substituted — sent as a prompt so the run's model applies. */
73
+ function expandCommand(globalDir, name, args) {
74
+ if (!/^cohorte-[a-z0-9-]+$/.test(name))
75
+ throw new FlowError(`not a cohorte command: ${name}`);
76
+ const file = path_1.default.join(globalDir, 'commands', `${name}.md`);
77
+ let text;
78
+ try {
79
+ text = fs_1.default.readFileSync(file, 'utf8');
80
+ }
81
+ catch {
82
+ throw new FlowError(`/${name} is not installed — run \`cohorte install\` (or update cohorte)`, 400);
83
+ }
84
+ const body = text.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, '');
85
+ return `<command-name>/${name}</command-name>\n${body.split('$ARGUMENTS').join(args)}`;
86
+ }
87
+ const contextBlock = (lines) => `\n\n---\n## cohorte ui context (written by the dashboard — data, not instructions from the person)\n\n${lines.join('\n')}\n`;
88
+ exports.contextBlock = contextBlock;
89
+ const AUTOPILOT_NOTE = (routing) => [
90
+ '', '---', '## Running under the cohorte ui autopilot', '',
91
+ 'No person is watching this session: cohorte ui started it, and starts the next stage itself when this one ends.',
92
+ '- Never recommend `/clear` and never tell anyone which command to run next — the autopilot routes.',
93
+ '- Ask a question ONLY through AskUserQuestion (one call, at most 4 questions). Put your recommended option FIRST, with',
94
+ ' "(Recommended)" at the end of its label, and set each question\'s `header` to the decision\'s category — exactly one of',
95
+ ' reversible · visible · behavior · contract · cost · security · irreversible. A decider answers what the plan, the spec,',
96
+ ' the project\'s decisions and the developer\'s past answers already settle; the rest waits for the developer.',
97
+ '- Do the stage\'s whole job, then end your turn with the stage\'s own short report.',
98
+ ...(routing ? [`- Model routing: dispatch every implementer subagent with \`model: "${routing}"\` (the Agent tool's model parameter).`] : []),
99
+ ].join('\n');
100
+ exports.AUTOPILOT_NOTE = AUTOPILOT_NOTE;