@meshpoint/cli 1.8.0 → 1.9.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/dist/agents-md.js +19 -4
- package/dist/bin.js +21 -1
- package/package.json +1 -1
package/dist/agents-md.js
CHANGED
|
@@ -8,6 +8,9 @@ import { isExpired } from "@meshpoint/sdk";
|
|
|
8
8
|
export const AGENTS_FILE = "AGENTS.md";
|
|
9
9
|
export const BLOCK_START = "<!-- meshpoint:conventions start -->";
|
|
10
10
|
export const BLOCK_END = "<!-- meshpoint:conventions end -->";
|
|
11
|
+
// The session-start context for a job that has no hook (CI, cloud agents): written per checkout, not committed.
|
|
12
|
+
export const CONTEXT_START = "<!-- meshpoint:context start -->";
|
|
13
|
+
export const CONTEXT_END = "<!-- meshpoint:context end -->";
|
|
11
14
|
const ID_TAG = /<!--\s*mp:([A-Za-z0-9_-]{8,})\s*-->/g;
|
|
12
15
|
const CLAUDE_IMPORT = /^@(?:\.\/)?AGENTS\.md\s*$/m;
|
|
13
16
|
// Harnesses that read AGENTS.md at the repository root on their own. Claude Code reads CLAUDE.md
|
|
@@ -35,13 +38,13 @@ export function renderBlock(items) {
|
|
|
35
38
|
return lines.join("\n");
|
|
36
39
|
}
|
|
37
40
|
// Replaces the block in place, appends it to a file without one, or starts a new file.
|
|
38
|
-
export function applyBlock(existing, block) {
|
|
41
|
+
export function applyBlock(existing, block, markers = [BLOCK_START, BLOCK_END]) {
|
|
39
42
|
if (existing === null)
|
|
40
43
|
return `# Agent instructions\n\n${block}\n`;
|
|
41
|
-
const start = existing.indexOf(
|
|
42
|
-
const end = existing.indexOf(
|
|
44
|
+
const start = existing.indexOf(markers[0]);
|
|
45
|
+
const end = existing.indexOf(markers[1], start);
|
|
43
46
|
if (start >= 0 && end > start)
|
|
44
|
-
return `${existing.slice(0, start)}${block}${existing.slice(end +
|
|
47
|
+
return `${existing.slice(0, start)}${block}${existing.slice(end + markers[1].length)}`;
|
|
45
48
|
const head = existing.replace(/\s+$/, "");
|
|
46
49
|
return `${head ? `${head}\n\n` : ""}${block}\n`;
|
|
47
50
|
}
|
|
@@ -59,6 +62,18 @@ export function exportConventions(items, root, opts = {}) {
|
|
|
59
62
|
writeFileSync(abs, next);
|
|
60
63
|
return { file: rel, created: existing === null, changed, count: conventions.length };
|
|
61
64
|
}
|
|
65
|
+
// The inject text as a block for a checkout without hooks. Replaces an earlier block, leaves the
|
|
66
|
+
// conventions block alone, and answers whether the file changed.
|
|
67
|
+
export function writeContext(text, root, file = AGENTS_FILE) {
|
|
68
|
+
const abs = path.join(root, file);
|
|
69
|
+
const existing = read(abs);
|
|
70
|
+
const body = text.trim() || "No team knowledge for this branch yet.";
|
|
71
|
+
const next = applyBlock(existing, `${CONTEXT_START}\n${body}\n${CONTEXT_END}`, [CONTEXT_START, CONTEXT_END]);
|
|
72
|
+
const changed = next !== existing;
|
|
73
|
+
if (changed)
|
|
74
|
+
writeFileSync(abs, next);
|
|
75
|
+
return { file, created: existing === null, changed };
|
|
76
|
+
}
|
|
62
77
|
export function hasBlock(root, file = AGENTS_FILE) {
|
|
63
78
|
const text = read(path.join(root, file));
|
|
64
79
|
return text !== null && text.includes(BLOCK_START) && text.includes(BLOCK_END);
|
package/dist/bin.js
CHANGED
|
@@ -27,7 +27,7 @@ import { renderDoctor, runDoctor } from "./doctor.js";
|
|
|
27
27
|
import { branchItems, confirmItems, parseItemArgs, parseItems, putItems, retractItems } from "./items.js";
|
|
28
28
|
import { importOffer } from "./import/offer.js";
|
|
29
29
|
import { applyProposalFile, DEFAULT_SINCE_DAYS, importSessions } from "./import/run.js";
|
|
30
|
-
import { AGENTS_FILE, exportConventions, hasBlock } from "./agents-md.js";
|
|
30
|
+
import { AGENTS_FILE, exportConventions, hasBlock, writeContext } from "./agents-md.js";
|
|
31
31
|
import { connectMcp } from "./mcp/connect.js";
|
|
32
32
|
import { McpServer } from "./mcp/server.js";
|
|
33
33
|
import { MCP_INSTRUCTIONS, MCP_SERVER_NAME, meshpointTools } from "./mcp/tools.js";
|
|
@@ -104,6 +104,9 @@ const USAGE = `meshpoint <command>
|
|
|
104
104
|
stdin form takes a JSON array of {kind, title, body}
|
|
105
105
|
items retract <id>... retract items on the current branch; an id may be a prefix
|
|
106
106
|
items confirm <id>... confirm items on the current branch (counts toward their rank)
|
|
107
|
+
context write [--file <path>] write the session-start context (team knowledge, verification
|
|
108
|
+
marks, teammates) as a marked block in AGENTS.md for a checkout
|
|
109
|
+
without hooks: CI jobs and cloud agents. Not for committing
|
|
107
110
|
export agents [--file <path>] [--check] write the branch's conventions as a marked block in AGENTS.md
|
|
108
111
|
(or --file, repo-relative) for agents that read that file
|
|
109
112
|
without a hook; the block is the only part touched, rerun to
|
|
@@ -340,6 +343,23 @@ async function main(argv) {
|
|
|
340
343
|
await server.serve(process.stdin, process.stdout);
|
|
341
344
|
return 0;
|
|
342
345
|
}
|
|
346
|
+
case "context": {
|
|
347
|
+
if (rest[0] !== "write")
|
|
348
|
+
throw new Error("context supports: write");
|
|
349
|
+
const config = await requireConfig();
|
|
350
|
+
const repo = repoContext(process.cwd());
|
|
351
|
+
if (!repo)
|
|
352
|
+
throw new Error("not inside a git repo with an origin remote");
|
|
353
|
+
const file = flag(rest, "--file");
|
|
354
|
+
if (file !== undefined && (path.isAbsolute(file) || file.split(/[\\/]/).includes("..")))
|
|
355
|
+
throw new Error("--file is a path inside the repository");
|
|
356
|
+
const tap = new Tap({ config, repo, session: `context-${randomUUID()}`, spool: new Spool(spoolDir()), checkpoints: new Checkpoints(stateDir()), local: localChecks(repo.root), refresh: () => freshConfig(config, { force: true }).catch(() => null) });
|
|
357
|
+
const text = await tap.start();
|
|
358
|
+
const out = writeContext(text, repo.root, file);
|
|
359
|
+
const items = (text.match(/^- /gm) ?? []).length;
|
|
360
|
+
console.log(`${out.created ? "created" : out.changed ? "updated" : "unchanged"} ${out.file}: context for ${repo.project} @ ${repo.branch}, ${items} line${items === 1 ? "" : "s"}. Not for committing.`);
|
|
361
|
+
return 0;
|
|
362
|
+
}
|
|
343
363
|
case "export": {
|
|
344
364
|
if (rest[0] !== "agents")
|
|
345
365
|
throw new Error("export supports: agents");
|