estimetry 0.1.1 → 0.2.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/CHANGELOG.md +13 -0
- package/README.md +45 -15
- package/dist/application/contracts/estimetry-command.js +34 -0
- package/dist/application/contracts/skill-mention.js +20 -0
- package/dist/application/estimetry.js +2 -0
- package/dist/application/hooks/context-limit.js +10 -2
- package/dist/application/hooks/hook-context.js +12 -4
- package/dist/application/hooks/receive-session-hook.js +15 -4
- package/dist/application/hooks/session-end-import.js +6 -7
- package/dist/application/ports/estimetry-runner.js +2 -0
- package/dist/application/project/init-defaults.js +17 -4
- package/dist/application/project/init-project.js +6 -2
- package/dist/application/project/install-copy.js +12 -3
- package/dist/application/project/show-init-choices.js +1 -1
- package/dist/application/project/tool-notices.js +8 -0
- package/dist/application/project/upgrade-plan.js +1 -1
- package/dist/application/task/import-session-logs.js +4 -1
- package/dist/bootstrap/container.js +38 -17
- package/dist/bootstrap/hook-receiver.js +7 -14
- package/dist/bootstrap/main.js +1 -1
- package/dist/domain/code/code-classes.js +1 -1
- package/dist/domain/progress/progress-record-parser.js +6 -0
- package/dist/domain/progress/session-log.js +2 -1
- package/dist/domain/usage/task-usage.js +24 -7
- package/dist/infrastructure/git/git-commit-hook-installer.js +16 -28
- package/dist/integrations/tools/claude-code/claude-code-adapter.js +32 -48
- package/dist/integrations/tools/claude-code/hook-events.js +4 -0
- package/dist/integrations/tools/claude-code/hook-translation.js +16 -34
- package/dist/integrations/tools/claude-code/importer/claude-code-logs.js +1 -1
- package/dist/integrations/tools/claude-code/skill-file.js +7 -19
- package/dist/integrations/tools/codex/codex-adapter.js +161 -0
- package/dist/integrations/tools/codex/hook-events.js +23 -0
- package/dist/integrations/tools/codex/hook-translation.js +76 -0
- package/dist/integrations/tools/codex/hook-trust.js +69 -0
- package/dist/integrations/tools/codex/importer/codex-logs.js +208 -0
- package/dist/integrations/tools/codex/importer/rollout-parser.js +163 -0
- package/dist/integrations/tools/codex/sandbox-rules.js +38 -0
- package/dist/integrations/tools/codex/skill-file.js +22 -0
- package/dist/integrations/tools/codex/trust-tables.js +96 -0
- package/dist/integrations/tools/content/commands.js +27 -20
- package/dist/integrations/tools/shared/generated-file.js +26 -0
- package/dist/integrations/tools/shared/hook-payload.js +33 -0
- package/dist/integrations/tools/{claude-code → shared}/hook-settings.js +40 -16
- package/dist/integrations/tools/shared/instructions-block.js +39 -0
- package/dist/integrations/tools/shared/skills-plan.js +39 -0
- package/dist/interface/cli/commands/hook-command.js +1 -1
- package/dist/interface/cli/commands/init-command.js +16 -7
- package/dist/interface/cli/commands/status-command.js +5 -2
- package/dist/interface/cli/presenters/text/closing-text.js +7 -3
- package/dist/interface/cli/presenters/text/notices-text.js +1 -0
- package/dist/interface/cli/presenters/text/task-text.js +1 -1
- package/dist/interface/cli/presenters/text-presenter.js +3 -3
- package/package.json +1 -1
- package/dist/integrations/tools/claude-code/claude-md.js +0 -28
- /package/dist/integrations/tools/{claude-code/importer → shared}/log-lines.js +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
const GENERATED_LINE = /^ {2}generatedBy: .*\n/m;
|
|
3
|
+
const HASH_LINE = /^ {2}contentHash: "[0-9a-f]*"\n/m;
|
|
4
|
+
/**
|
|
5
|
+
* Frontmatter `metadata` of a file estimetry generates: `generatedBy` with the version. `stamp` puts
|
|
6
|
+
* `contentHash` of the whole text after that line, so `ownership` can tell an untouched file from an edited one.
|
|
7
|
+
*/
|
|
8
|
+
export function generatedBy(version) {
|
|
9
|
+
return ['metadata:', ` generatedBy: "estimetry ${version}"`];
|
|
10
|
+
}
|
|
11
|
+
/** The text with the hash of itself after its `generatedBy` line. */
|
|
12
|
+
export function stamp(unhashed) {
|
|
13
|
+
return unhashed.replace(GENERATED_LINE, (line) => `${line} contentHash: "${hashOf(unhashed)}"\n`);
|
|
14
|
+
}
|
|
15
|
+
/** Whose the file is: ours and untouched, ours but edited by the user, or the user's own. */
|
|
16
|
+
export function ownership(text) {
|
|
17
|
+
if (!/^ {2}generatedBy: "estimetry /m.test(text)) {
|
|
18
|
+
return 'foreign';
|
|
19
|
+
}
|
|
20
|
+
const stamped = /^ {2}contentHash: "([0-9a-f]*)"$/m.exec(text)?.[1];
|
|
21
|
+
return stamped !== undefined && stamped === hashOf(text.replace(HASH_LINE, '')) ? 'ours' : 'edited';
|
|
22
|
+
}
|
|
23
|
+
function hashOf(text) {
|
|
24
|
+
return createHash('sha256').update(text).digest('hex').slice(0, 12);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=generated-file.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SessionId } from '../../../domain/measurement/session-id.js';
|
|
2
|
+
import { InvalidValue } from '../../../domain/shared/domain-error.js';
|
|
3
|
+
/**
|
|
4
|
+
* The translation of one call: the envelope checked here, the events by the tool's own rules. An empty string is
|
|
5
|
+
* no value. @throws InvalidValue naming the tool and the event, never the content of the payload.
|
|
6
|
+
*/
|
|
7
|
+
export function translateHook(tool, event, payload, kinds, events) {
|
|
8
|
+
if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {
|
|
9
|
+
throw new InvalidValue(`${tool} ${event}: stdin is not a JSON object`);
|
|
10
|
+
}
|
|
11
|
+
const p = payload;
|
|
12
|
+
if (typeof p['session_id'] !== 'string') {
|
|
13
|
+
throw new InvalidValue(`${tool} ${event}: session_id is missing`);
|
|
14
|
+
}
|
|
15
|
+
const cwd = payloadText(p['cwd']);
|
|
16
|
+
const transcript = payloadText(p['transcript_path']);
|
|
17
|
+
return {
|
|
18
|
+
session: SessionId.parse(p['session_id']),
|
|
19
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
20
|
+
...(transcript === undefined ? {} : { transcript }),
|
|
21
|
+
kind: kinds[event] ?? 'other',
|
|
22
|
+
events: events(event, p),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** A string field of a payload; an empty one, or anything else, is no value. */
|
|
26
|
+
export function payloadText(value) {
|
|
27
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
28
|
+
}
|
|
29
|
+
/** Context for the agent in the output both tools read: `hookSpecificOutput.additionalContext`. */
|
|
30
|
+
export function additionalContext(event, text) {
|
|
31
|
+
return JSON.stringify({ hookSpecificOutput: { hookEventName: event, additionalContext: text } });
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=hook-payload.js.map
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
+
import { isEstimetryCommand } from '../../../application/contracts/estimetry-command.js';
|
|
1
2
|
import { InstallBlocked } from '../../../application/contracts/install-blocked.js';
|
|
2
|
-
/**
|
|
3
|
-
export const HOOK_PREFIX = 'estimetry hook claude-code';
|
|
3
|
+
/** Seconds a tool waits for an estimetry hook, unless the hook set names another for an event. */
|
|
4
4
|
export const HOOK_TIMEOUT_SECONDS = 10;
|
|
5
5
|
/**
|
|
6
6
|
* Adds one hook per event and drops our earlier ones; every other key, hook and
|
|
7
7
|
* their order stay. `displayPath` names the file in the error a broken one gives.
|
|
8
8
|
*/
|
|
9
|
-
export function withHooks(text,
|
|
9
|
+
export function withHooks(text, set, displayPath) {
|
|
10
|
+
const { events, synchronous, ours } = set;
|
|
10
11
|
const settings = parse(text, displayPath) ?? {};
|
|
11
|
-
const hooks = withoutOurHooks(hooksOf(settings, displayPath));
|
|
12
|
+
const hooks = withoutOurHooks(hooksOf(settings, displayPath), ours);
|
|
12
13
|
for (const event of events) {
|
|
13
14
|
const groups = Array.isArray(hooks[event]) ? hooks[event] : [];
|
|
14
15
|
// The agent does not wait for an async hook: only hooks whose context it needs now, or the session end, are synchronous.
|
|
15
16
|
const handler = {
|
|
16
17
|
type: 'command',
|
|
17
|
-
command:
|
|
18
|
-
timeout: HOOK_TIMEOUT_SECONDS,
|
|
18
|
+
command: set.command(event),
|
|
19
|
+
timeout: set.timeout?.(event) ?? HOOK_TIMEOUT_SECONDS,
|
|
19
20
|
...(synchronous.includes(event) ? {} : { async: true }),
|
|
20
21
|
};
|
|
21
22
|
hooks[event] = [...groups, { hooks: [handler] }];
|
|
@@ -23,12 +24,12 @@ export function withHooks(text, events, displayPath, synchronous = events) {
|
|
|
23
24
|
return render({ ...settings, hooks }, text);
|
|
24
25
|
}
|
|
25
26
|
/** Drops our hooks from a file we no longer install into; `undefined` when nothing else is left. */
|
|
26
|
-
export function withoutHooks(text, displayPath) {
|
|
27
|
+
export function withoutHooks(text, ours, displayPath) {
|
|
27
28
|
const settings = parse(text, displayPath);
|
|
28
29
|
if (settings === undefined || !isObject(settings['hooks'])) {
|
|
29
30
|
return text;
|
|
30
31
|
}
|
|
31
|
-
const hooks = withoutOurHooks(settings['hooks']);
|
|
32
|
+
const hooks = withoutOurHooks(settings['hooks'], ours);
|
|
32
33
|
const { hooks: _old, ...rest } = settings;
|
|
33
34
|
const next = Object.keys(hooks).length > 0 ? { ...settings, hooks } : rest;
|
|
34
35
|
if (Object.keys(next).length === 0) {
|
|
@@ -49,16 +50,18 @@ export function isBrokenJson(text) {
|
|
|
49
50
|
return true;
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
/** Whether the settings hold a hook of ours. */
|
|
54
|
+
export function hasOurHooks(text, ours) {
|
|
53
55
|
try {
|
|
54
56
|
const settings = text === undefined ? undefined : JSON.parse(text);
|
|
55
|
-
|
|
57
|
+
const hooks = isObject(settings) ? settings['hooks'] : undefined;
|
|
58
|
+
return isObject(hooks) && Object.values(hooks).some((groups) => groupsHaveOurs(groups, ours));
|
|
56
59
|
}
|
|
57
60
|
catch {
|
|
58
61
|
return false;
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
function withoutOurHooks(hooks) {
|
|
64
|
+
function withoutOurHooks(hooks, ours) {
|
|
62
65
|
const result = {};
|
|
63
66
|
for (const [event, groups] of Object.entries(hooks)) {
|
|
64
67
|
if (!Array.isArray(groups)) {
|
|
@@ -69,7 +72,7 @@ function withoutOurHooks(hooks) {
|
|
|
69
72
|
if (!isObject(group) || !Array.isArray(group['hooks'])) {
|
|
70
73
|
return [group];
|
|
71
74
|
}
|
|
72
|
-
const handlers = group['hooks'].filter((handler) => !isOurs(handler));
|
|
75
|
+
const handlers = group['hooks'].filter((handler) => !isOurs(handler, ours));
|
|
73
76
|
if (handlers.length === group['hooks'].length) {
|
|
74
77
|
return [group];
|
|
75
78
|
}
|
|
@@ -81,14 +84,15 @@ function withoutOurHooks(hooks) {
|
|
|
81
84
|
}
|
|
82
85
|
return result;
|
|
83
86
|
}
|
|
84
|
-
function groupsHaveOurs(groups) {
|
|
85
|
-
return Array.isArray(groups) &&
|
|
87
|
+
function groupsHaveOurs(groups, ours) {
|
|
88
|
+
return (Array.isArray(groups) &&
|
|
89
|
+
groups.some((group) => isObject(group) && Array.isArray(group['hooks']) && group['hooks'].some((handler) => isOurs(handler, ours))));
|
|
86
90
|
}
|
|
87
|
-
function isOurs(handler) {
|
|
91
|
+
function isOurs(handler, ours) {
|
|
88
92
|
return (isObject(handler) &&
|
|
89
93
|
handler['type'] === 'command' &&
|
|
90
94
|
typeof handler['command'] === 'string' &&
|
|
91
|
-
(handler['command']
|
|
95
|
+
isEstimetryCommand(handler['command'], ours));
|
|
92
96
|
}
|
|
93
97
|
function hooksOf(settings, displayPath) {
|
|
94
98
|
const hooks = settings['hooks'];
|
|
@@ -124,4 +128,24 @@ function render(settings, previous) {
|
|
|
124
128
|
function isObject(value) {
|
|
125
129
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
126
130
|
}
|
|
131
|
+
/** Every handler of ours in the settings, in their order; none when the text does not parse. */
|
|
132
|
+
export function ourHandlers(text, ours) {
|
|
133
|
+
let settings;
|
|
134
|
+
try {
|
|
135
|
+
settings = text === undefined ? undefined : JSON.parse(text);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
const hooks = isObject(settings) ? settings['hooks'] : undefined;
|
|
141
|
+
if (!isObject(hooks)) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
return Object.entries(hooks).flatMap(([event, groups]) => (Array.isArray(groups) ? groups : []).flatMap((group, groupIndex) => (isObject(group) && Array.isArray(group['hooks']) ? group['hooks'] : []).flatMap((handler, handlerIndex) => isOurs(handler, ours) && isObject(handler) && isObject(group)
|
|
145
|
+
? [{ event, group: groupIndex, handler: handlerIndex, config: handler, ...matcherOf(group) }]
|
|
146
|
+
: [])));
|
|
147
|
+
}
|
|
148
|
+
function matcherOf(group) {
|
|
149
|
+
return typeof group['matcher'] === 'string' ? { matcher: group['matcher'] } : {};
|
|
150
|
+
}
|
|
127
151
|
//# sourceMappingURL=hook-settings.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { EMPTY_PLAN } from '../../../application/ports/file-change.js';
|
|
2
|
+
export const BLOCK_START = '<!-- estimetry:start -->';
|
|
3
|
+
export const BLOCK_END = '<!-- estimetry:end -->';
|
|
4
|
+
const EXISTING = new RegExp(`\\n*${escape(BLOCK_START)}[\\s\\S]*?${escape(BLOCK_END)}\\n?`);
|
|
5
|
+
/**
|
|
6
|
+
* A markdown file of instructions for the agent (`CLAUDE.md`, `AGENTS.md`) with one estimetry block at the end:
|
|
7
|
+
* the markers around `## estimetry` and `body`. Text outside the markers stays.
|
|
8
|
+
*/
|
|
9
|
+
export function withBlock(text, body) {
|
|
10
|
+
const block = [BLOCK_START, '## estimetry', '', body, BLOCK_END].join('\n');
|
|
11
|
+
const rest = withoutBlock(text ?? '');
|
|
12
|
+
return rest === '' ? `${block}\n` : `${rest.replace(/\n*$/, '')}\n\n${block}\n`;
|
|
13
|
+
}
|
|
14
|
+
/** The file without the block; the text is returned as is when there is none. */
|
|
15
|
+
export function withoutBlock(text) {
|
|
16
|
+
if (!EXISTING.test(text)) {
|
|
17
|
+
return text;
|
|
18
|
+
}
|
|
19
|
+
const rest = text.replace(EXISTING, '\n');
|
|
20
|
+
return rest.trim() === '' ? '' : `${rest.replace(/\n+$/, '')}\n`;
|
|
21
|
+
}
|
|
22
|
+
function escape(text) {
|
|
23
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The block in an instructions file: written with a shared install (the file the team commits), taken out with a
|
|
27
|
+
* personal one; a file left with nothing but the block goes.
|
|
28
|
+
*/
|
|
29
|
+
export function instructionsPlan(path, current, shared, body) {
|
|
30
|
+
if (shared) {
|
|
31
|
+
return { changes: [{ path, content: withBlock(current, body) }], skipped: [], warnings: [] };
|
|
32
|
+
}
|
|
33
|
+
const rest = current === undefined ? current : withoutBlock(current);
|
|
34
|
+
if (rest === undefined || rest === current) {
|
|
35
|
+
return EMPTY_PLAN;
|
|
36
|
+
}
|
|
37
|
+
return { changes: [rest === '' ? { path, remove: true } : { path, content: rest }], skipped: [], warnings: [] };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=instructions-block.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { ownership } from './generated-file.js';
|
|
3
|
+
/**
|
|
4
|
+
* Writes every skill to its directory, unless the file there is the user's or was edited after install (then only
|
|
5
|
+
* with `force`). A personal install takes untouched copies out of the project; a shared one keeps the personal ones,
|
|
6
|
+
* which serve other projects.
|
|
7
|
+
*/
|
|
8
|
+
export function skillsPlan(skills, target) {
|
|
9
|
+
const { files, shared, force } = target;
|
|
10
|
+
const changes = [];
|
|
11
|
+
const skipped = [];
|
|
12
|
+
const dir = shared ? target.projectDir : target.userDir;
|
|
13
|
+
for (const skill of skills) {
|
|
14
|
+
const path = join(dir, skill.id, 'SKILL.md');
|
|
15
|
+
const current = files.read(path);
|
|
16
|
+
const owner = current === undefined ? 'ours' : ownership(current);
|
|
17
|
+
if (owner === 'foreign') {
|
|
18
|
+
skipped.push({ path, reason: 'not created by estimetry, left as it is' });
|
|
19
|
+
}
|
|
20
|
+
else if (owner === 'edited' && !force) {
|
|
21
|
+
skipped.push({ path, reason: 'edited after install; run init --force to overwrite it' });
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
changes.push({ path, content: target.render(skill) });
|
|
25
|
+
}
|
|
26
|
+
if (!shared) {
|
|
27
|
+
const inProject = join(target.projectDir, skill.id, 'SKILL.md');
|
|
28
|
+
const text = files.read(inProject);
|
|
29
|
+
if (text !== undefined && ownership(text) === 'ours') {
|
|
30
|
+
changes.push({ path: inProject, remove: true });
|
|
31
|
+
}
|
|
32
|
+
else if (text !== undefined && ownership(text) === 'edited') {
|
|
33
|
+
skipped.push({ path: inProject, reason: 'edited after install, so it stays in the project' });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return { changes, skipped, warnings: [] };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=skills-plan.js.map
|
|
@@ -17,7 +17,7 @@ export async function runHook(args, run) {
|
|
|
17
17
|
event,
|
|
18
18
|
payload,
|
|
19
19
|
cwd: run.cwd,
|
|
20
|
-
|
|
20
|
+
environment: run.environment,
|
|
21
21
|
});
|
|
22
22
|
if (output !== undefined) {
|
|
23
23
|
run.out.print(output);
|
|
@@ -3,10 +3,7 @@ import { presenterFor } from '../cli-context.js';
|
|
|
3
3
|
import { Prompts } from '../prompts.js';
|
|
4
4
|
/** Shown in the questions so users see where estimetry is going; not registered until they work. */
|
|
5
5
|
const COMING_SOON = {
|
|
6
|
-
tools: [
|
|
7
|
-
{ value: 'codex', label: 'Codex' },
|
|
8
|
-
{ value: 'cursor', label: 'Cursor' },
|
|
9
|
-
],
|
|
6
|
+
tools: [{ value: 'cursor', label: 'Cursor' }],
|
|
10
7
|
flows: [
|
|
11
8
|
{ value: 'spec-kit', label: 'GitHub Spec Kit' },
|
|
12
9
|
{ value: 'custom', label: 'Your own, from .estimetry/flow.yaml' },
|
|
@@ -22,13 +19,15 @@ export function registerInitCommand(program, ctx) {
|
|
|
22
19
|
.command('init')
|
|
23
20
|
.helpGroup('Setup')
|
|
24
21
|
.description('set up estimetry in this project: hooks, skills and commands of the AI tool, project config')
|
|
25
|
-
.option('--tools <ids>', 'AI tools, comma-separated
|
|
22
|
+
.option('--tools <ids>', 'AI tools, comma-separated: claude-code, codex (default: installed, else found on this machine)')
|
|
26
23
|
.option('--flow <id>', 'development process: openspec or none (default: detected)')
|
|
27
24
|
.option('--share <mode>', `sharing with the team: ${SHARE_MODES.join(', ')}`)
|
|
28
25
|
.option('--track-commits', 'install a git post-commit hook')
|
|
29
26
|
.option('--no-track-commits', 'remove the git post-commit hook')
|
|
30
27
|
.option('--shared-hooks', 'install for the whole team, into files the project commits')
|
|
31
28
|
.option('--no-shared-hooks', 'install for yourself only (default)')
|
|
29
|
+
.option('--trust-hooks', 'trust the hooks in tools that ask for it (Codex) and let its task commands run outside their sandbox')
|
|
30
|
+
.option('--no-trust-hooks', 'trust nothing, take away the rule for the task commands (without either flag: kept as it is)')
|
|
32
31
|
.option('--force', 'overwrite generated skills you have edited')
|
|
33
32
|
.option('--no-interactive', 'do not ask; use flags and defaults')
|
|
34
33
|
.option('--json', 'print JSON')
|
|
@@ -46,6 +45,7 @@ function fromFlags(options) {
|
|
|
46
45
|
...(options.share === undefined ? {} : { share: options.share }),
|
|
47
46
|
...(options.trackCommits === undefined ? {} : { trackCommits: options.trackCommits }),
|
|
48
47
|
...(options.sharedHooks === undefined ? {} : { shared: options.sharedHooks }),
|
|
48
|
+
...(options.trustHooks === undefined ? {} : { trustHooks: options.trustHooks }),
|
|
49
49
|
...(options.force ? { force: true } : {}),
|
|
50
50
|
};
|
|
51
51
|
}
|
|
@@ -58,7 +58,10 @@ async function ask(ctx, choices, options) {
|
|
|
58
58
|
if (input.tools === undefined) {
|
|
59
59
|
input.tools = await prompts.multiSelect('AI tools', [
|
|
60
60
|
...choices.tools.map((tool) => ({ value: tool.id, label: tool.title })),
|
|
61
|
-
|
|
61
|
+
// A tool that is registered is never "coming soon", even if this list lags behind.
|
|
62
|
+
...COMING_SOON.tools
|
|
63
|
+
.filter((soon) => !choices.tools.some((tool) => tool.id === soon.value))
|
|
64
|
+
.map((tool) => ({ ...tool, disabled: true })),
|
|
62
65
|
], defaults.tools);
|
|
63
66
|
}
|
|
64
67
|
if (input.flow === undefined) {
|
|
@@ -73,9 +76,15 @@ async function ask(ctx, choices, options) {
|
|
|
73
76
|
if (input.trackCommits === undefined) {
|
|
74
77
|
input.trackCommits = await prompts.confirm('Install a git post-commit hook to link commits to tasks?', defaults.trackCommits);
|
|
75
78
|
}
|
|
79
|
+
const asking = choices.tools.filter((tool) => tool.asksTrust && (input.tools ?? defaults.tools).includes(tool.id));
|
|
80
|
+
if (input.trustHooks === undefined && asking.length > 0) {
|
|
81
|
+
const titles = asking.map((tool) => tool.title).join(', ');
|
|
82
|
+
input.trustHooks = await prompts.confirm(`${titles} runs a hook only after you trust it, and the agent's commands in a sandbox. ` +
|
|
83
|
+
'Trust the estimetry hooks and let its task commands (emt start, extra, close…) run outside the sandbox?', true);
|
|
84
|
+
}
|
|
76
85
|
const shared = input.shared ?? defaults.shared;
|
|
77
86
|
if (!shared && choices.unignoredPersonalFiles.length > 0) {
|
|
78
|
-
input.excludePersonalFiles = await prompts.confirm(`${choices.unignoredPersonalFiles.join(', ')} is not ignored by git. Add it to your global git excludes
|
|
87
|
+
input.excludePersonalFiles = await prompts.confirm(`${choices.unignoredPersonalFiles.join(', ')} is not ignored by git. Add it to your global git excludes?`, true);
|
|
79
88
|
}
|
|
80
89
|
return input;
|
|
81
90
|
}
|
|
@@ -8,8 +8,11 @@ export function registerStatusCommand(program, ctx) {
|
|
|
8
8
|
.argument('[task]', 'task id; defaults to the only task in progress in this project')
|
|
9
9
|
.option('--json', 'print JSON (durations in minutes)')
|
|
10
10
|
.action(async (id, options) => {
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const app = await ctx.app();
|
|
12
|
+
const view = app.measuring.status({ ...parseTaskOption(id), near: ctx.cwd });
|
|
13
|
+
const presenter = presenterFor(options);
|
|
14
|
+
ctx.out.print(presenter.status(view));
|
|
15
|
+
presenter.notices.tools(app.project.notices()).forEach((line) => ctx.out.error(line));
|
|
13
16
|
});
|
|
14
17
|
}
|
|
15
18
|
//# sourceMappingURL=status-command.js.map
|
|
@@ -92,14 +92,18 @@ export function usageRows(usage) {
|
|
|
92
92
|
if (usage === null) {
|
|
93
93
|
return [];
|
|
94
94
|
}
|
|
95
|
-
const
|
|
95
|
+
const withCost = usage.withCost ?? usage.withLogs;
|
|
96
|
+
const unknown = withCost === 0 ? 'not reported' : 'unknown';
|
|
97
|
+
const cost = usage.costUSD === null ? unknown : `$${usage.costUSD.toFixed(2)}${usage.approximate ? ' (approximate: split by tokens)' : ''}`;
|
|
98
|
+
// A tool without a cost (Codex): the cost stands for fewer sessions than the tokens.
|
|
99
|
+
const costFrom = withCost < usage.withLogs ? `, cost from ${withCost} of ${usage.sessions} sessions` : '';
|
|
96
100
|
const models = Object.entries(usage.tokens).map(([model, t]) => {
|
|
97
|
-
const cacheWrite = tokenCount(t.cacheWrite5m + t.cacheWrite1h);
|
|
101
|
+
const cacheWrite = tokenCount(t.cacheWrite5m + t.cacheWrite1h + (t.cacheWrite ?? 0));
|
|
98
102
|
const read = `in ${tokenCount(t.input)}, out ${tokenCount(t.output)}, cache read ${tokenCount(t.cacheRead)}`;
|
|
99
103
|
return [` ${model}`, `${read}, cache write ${cacheWrite}`];
|
|
100
104
|
});
|
|
101
105
|
return [
|
|
102
|
-
['cost', `${cost}, from the logs of ${usage.withLogs} of ${usage.sessions} sessions`],
|
|
106
|
+
['cost', `${cost}, from the logs of ${usage.withLogs} of ${usage.sessions} sessions${costFrom}`],
|
|
103
107
|
...(models.length === 0 ? [] : [['tokens', ''], ...models]),
|
|
104
108
|
];
|
|
105
109
|
}
|
|
@@ -8,6 +8,7 @@ export const textNotices = {
|
|
|
8
8
|
'the record was added on top of them. If it is the same time, record it with --at so it merges instead',
|
|
9
9
|
]
|
|
10
10
|
: [],
|
|
11
|
+
tools: (notices) => notices.map((notice) => `warning: ${notice}`),
|
|
11
12
|
/** Extra work the revision covers or leaves counted, and untimed manual time that stays. */
|
|
12
13
|
revisionCandidates: (candidates, covers) => [
|
|
13
14
|
...candidates.extras.map((extra) => {
|
|
@@ -128,7 +128,7 @@ export function initText(report) {
|
|
|
128
128
|
`stack: ${report.stack.length === 0 ? '(nothing detected)' : report.stack.join(', ')}`,
|
|
129
129
|
table(report.files.map((file) => [` ${file.status}`, file.reason === undefined ? file.path : `${file.path}: ${file.reason}`])),
|
|
130
130
|
...report.warnings.map((warning) => `warning: ${warning}`),
|
|
131
|
-
'Next: ask the agent for an estimate (
|
|
131
|
+
'Next: ask the agent for an estimate (skill emt-estimate) or create a task with `emt task new "<title>"`.',
|
|
132
132
|
];
|
|
133
133
|
return lines.filter((line) => line !== '').join('\n');
|
|
134
134
|
}
|
|
@@ -47,7 +47,7 @@ export const textPresenter = {
|
|
|
47
47
|
(parts === 1 ? '1 part' : `${parts} parts`) +
|
|
48
48
|
(task.status === 'in-progress'
|
|
49
49
|
? ''
|
|
50
|
-
: `\nTime is not measured yet: start the task when work begins with \`emt start ${task.id}\` (or
|
|
50
|
+
: `\nTime is not measured yet: start the task when work begins with \`emt start ${task.id}\` (or the skill emt-start); add --at "YYYY-MM-DD HH:MM" if it already began.`),
|
|
51
51
|
revisionRepaired: (r) => `Wrote the plan snapshot of revision ${r.revision} of ${r.task.id}.`,
|
|
52
52
|
estimateRevised: (r) => r.firstEstimate
|
|
53
53
|
? `Estimate saved for ${r.task.id} after its start: ${r.total.optimistic} / ${r.total.likely} / ${r.total.pessimistic} h. It is not used for calibration.`
|
|
@@ -86,7 +86,7 @@ export const textPresenter = {
|
|
|
86
86
|
upgradeReport: upgradeReportText,
|
|
87
87
|
taskClosed: (result) => `Closed ${result.task.id} "${result.task.title}"${result.outcome === 'completed' ? '' : ` (${result.outcome})`}: ` +
|
|
88
88
|
`${factText(result.fact, result.estimateHours, result.estimateShare)}.\n` +
|
|
89
|
-
`Now record the retro with the user: emt retro --reason "<why>" --lesson "<one lesson>" (or
|
|
89
|
+
`Now record the retro with the user: emt retro --reason "<why>" --lesson "<one lesson>" (or the skill emt-retro).`,
|
|
90
90
|
taskReopened: ({ task }) => `Reopened ${task.id} "${task.title}"; it is in progress again.`,
|
|
91
91
|
retroRecorded: ({ task, reasons, lesson }) => [
|
|
92
92
|
`Retro recorded for ${task.id}:`,
|
|
@@ -94,7 +94,7 @@ export const textPresenter = {
|
|
|
94
94
|
` lesson: ${lesson}`,
|
|
95
95
|
].join('\n'),
|
|
96
96
|
renegotiated: ({ closed, spawned }) => `Closed ${closed.task.id} as renegotiated: ${factText(closed.fact, closed.estimateHours, closed.estimateShare)}.\n` +
|
|
97
|
-
`Created ${spawned.id} "${spawned.title}" for the rest. Next: estimate it (
|
|
97
|
+
`Created ${spawned.id} "${spawned.title}" for the rest. Next: estimate it (skill emt-estimate), start it, and attach sessions with \`emt attach ${spawned.id} --session <id>\`.`,
|
|
98
98
|
rebuildReport: (report) => [
|
|
99
99
|
`Rebuilt ${report.tasks} task${report.tasks === 1 ? '' : 's'}, ${report.cards} card${report.cards === 1 ? '' : 's'}.`,
|
|
100
100
|
...report.failed.map((f) => `failed: ${f.task}: ${f.error}`),
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const BLOCK_START = '<!-- estimetry:start -->';
|
|
2
|
-
export const BLOCK_END = '<!-- estimetry:end -->';
|
|
3
|
-
const BLOCK = [
|
|
4
|
-
BLOCK_START,
|
|
5
|
-
'## estimetry',
|
|
6
|
-
'',
|
|
7
|
-
'Before you name a deadline or an effort for a task, run `/emt-estimate`: ' +
|
|
8
|
-
'it bases the estimate on past tasks and saves it as the plan the actual effort is measured against.',
|
|
9
|
-
BLOCK_END,
|
|
10
|
-
].join('\n');
|
|
11
|
-
const EXISTING = new RegExp(`\\n*${escape(BLOCK_START)}[\\s\\S]*?${escape(BLOCK_END)}\\n?`);
|
|
12
|
-
/** `CLAUDE.md` with one estimetry block at the end; text outside the markers stays. */
|
|
13
|
-
export function withBlock(text) {
|
|
14
|
-
const rest = withoutBlock(text ?? '') ?? '';
|
|
15
|
-
return rest === '' ? `${BLOCK}\n` : `${rest.replace(/\n*$/, '')}\n\n${BLOCK}\n`;
|
|
16
|
-
}
|
|
17
|
-
/** `CLAUDE.md` without the block; the text is returned as is when there is none. */
|
|
18
|
-
export function withoutBlock(text) {
|
|
19
|
-
if (!EXISTING.test(text)) {
|
|
20
|
-
return text;
|
|
21
|
-
}
|
|
22
|
-
const rest = text.replace(EXISTING, '\n');
|
|
23
|
-
return rest.trim() === '' ? '' : `${rest.replace(/\n+$/, '')}\n`;
|
|
24
|
-
}
|
|
25
|
-
function escape(text) {
|
|
26
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=claude-md.js.map
|
|
File without changes
|