@eocrm/cli 0.4.0 → 0.4.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/README.md +8 -4
- package/lib/cli/run.mjs +3 -2
- package/lib/state.mjs +15 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
# eocrm
|
|
1
|
+
# eocrm for coding agents
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Track your coding agents' work in eocrm: runs, commits, plan steps and pull requests, against the task they belong to. Pick the setup that matches your tool:
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
5
|
+
- **Any agent (Cline, Roo Code, Cursor, opencode, Aider, …): the `@eocrm/cli` package.** It reports through git hooks, so it needs no model tokens and no editor plugin. `npx @eocrm/cli init` in your repo. See [Use with any agent (CLI)](#use-with-any-agent-cli).
|
|
6
|
+
- **Claude Code or Codex: the plugins below**, installed from this repo's catalogue:
|
|
7
|
+
- **`eocrm-mcp`**: eocrm tools only. Claude can read and change tasks, contacts, deals, appointments and records in your workspaces through the eocrm MCP server. No hooks and no tracking.
|
|
8
|
+
- **`eocrm`**: agent work. It reports Claude Code and Codex runs, plan steps, commits, test runs, PRs and review findings to your eocrm workspace. In Claude Code it installs `eocrm-mcp` too; in Codex, add `eocrm-mcp` yourself.
|
|
9
|
+
|
|
10
|
+
Teams that plan with [OpenSpec](https://github.com/Fission-AI/OpenSpec) get each change's `tasks.md` as a live eocrm checklist with either setup ([OpenSpec](#openspec)).
|
|
7
11
|
|
|
8
12
|
## Install (Claude Code)
|
|
9
13
|
|
package/lib/cli/run.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { appendFileSync, mkdirSync, readFileSync, renameSync } from 'node:fs';
|
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { randomBytes } from 'node:crypto';
|
|
6
|
-
import { git, worktreeOf, withLock, loadRun, saveRun, loadWorktree, saveWorktree, liveDirOf, liveSession, gitTimeout, remove } from '../state.mjs';
|
|
6
|
+
import { git, GitDeadline, worktreeOf, withLock, loadRun, saveRun, loadWorktree, saveWorktree, liveDirOf, liveSession, gitTimeout, remove } from '../state.mjs';
|
|
7
7
|
import { append } from '../outbox.mjs';
|
|
8
8
|
import { eventId } from '../ids.mjs';
|
|
9
9
|
import { prStatus, repoSlug } from '../git.mjs';
|
|
@@ -138,15 +138,16 @@ export async function runHook(ctx, name, cwd, args = []) {
|
|
|
138
138
|
if (!hook) return 'unknown hook';
|
|
139
139
|
const budget = ctx.hookMs ?? HOOK_MS;
|
|
140
140
|
Object.assign(gitTimeout, { ms: HOOK_GIT_MS, deadline: Date.now() + budget });
|
|
141
|
-
if (!cloneEntry(ctx.data, cwd).initialized) return 'not initialized';
|
|
142
141
|
let timer;
|
|
143
142
|
const late = new Promise((resolve) => {
|
|
144
143
|
timer = setTimeout(() => resolve('timeout'), budget);
|
|
145
144
|
timer.unref?.();
|
|
146
145
|
});
|
|
147
146
|
try {
|
|
147
|
+
if (!cloneEntry(ctx.data, cwd).initialized) return 'not initialized';
|
|
148
148
|
return await Promise.race([hook(ctx, cwd, args), late]);
|
|
149
149
|
} catch (e) {
|
|
150
|
+
if (e instanceof GitDeadline) return 'timeout';
|
|
150
151
|
logError(ctx.data, e);
|
|
151
152
|
return 'failed';
|
|
152
153
|
} finally {
|
package/lib/state.mjs
CHANGED
|
@@ -125,14 +125,24 @@ export function writeFileAtomic(file, text, { mode = 0o666 } = {}) {
|
|
|
125
125
|
// deadline (epoch ms), when set, caps every git call after it: a hook's whole budget, not one call's.
|
|
126
126
|
export const gitTimeout = { ms: 5000, deadline: null };
|
|
127
127
|
|
|
128
|
+
export class GitDeadline extends Error {
|
|
129
|
+
constructor() {
|
|
130
|
+
super('eocrm: hook time budget spent');
|
|
131
|
+
this.name = 'GitDeadline';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Past the deadline git throws: an empty answer would read as a fact (no commit, no live session).
|
|
128
136
|
export const git = (cwd, args, run = execFileSync) => {
|
|
129
|
-
const
|
|
130
|
-
|
|
137
|
+
const { deadline } = gitTimeout;
|
|
138
|
+
const left = deadline === null ? gitTimeout.ms : Math.min(gitTimeout.ms, deadline - Date.now());
|
|
131
139
|
try {
|
|
132
|
-
return run('git', args, { cwd, encoding: 'utf8', timeout: left, windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
133
|
-
} catch {
|
|
134
|
-
|
|
140
|
+
if (left > 0) return run('git', args, { cwd, encoding: 'utf8', timeout: left, windowsHide: true, stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
141
|
+
} catch (e) {
|
|
142
|
+
if (deadline !== null && e.code === 'ETIMEDOUT') throw new GitDeadline();
|
|
135
143
|
}
|
|
144
|
+
if (deadline !== null && Date.now() >= deadline) throw new GitDeadline();
|
|
145
|
+
return '';
|
|
136
146
|
};
|
|
137
147
|
|
|
138
148
|
export function worktreeOf(cwd, run, top = git(cwd, ['rev-parse', '--show-toplevel'], run)) {
|