estimetry 0.1.2 → 0.3.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 (65) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +88 -16
  3. package/dist/application/contracts/skill-mention.js +20 -0
  4. package/dist/application/estimetry.js +2 -0
  5. package/dist/application/hooks/context-limit.js +10 -2
  6. package/dist/application/hooks/hook-context.js +12 -4
  7. package/dist/application/hooks/receive-session-hook.js +15 -4
  8. package/dist/application/hooks/session-end-import.js +6 -7
  9. package/dist/application/project/init-defaults.js +17 -4
  10. package/dist/application/project/init-project.js +4 -1
  11. package/dist/application/project/install-copy.js +8 -1
  12. package/dist/application/project/show-init-choices.js +1 -1
  13. package/dist/application/project/tool-notices.js +8 -0
  14. package/dist/application/task/import-session-logs.js +4 -1
  15. package/dist/application/task/show-calibration.js +12 -8
  16. package/dist/application/task/task-cards.js +1 -1
  17. package/dist/bootstrap/container.js +23 -6
  18. package/dist/bootstrap/hook-receiver.js +7 -14
  19. package/dist/bootstrap/main.js +1 -1
  20. package/dist/domain/calibration/applicable-coefficient.js +35 -19
  21. package/dist/domain/calibration/calibration-policy.js +39 -0
  22. package/dist/domain/calibration/calibration.js +21 -36
  23. package/dist/domain/calibration/level-parts.js +41 -0
  24. package/dist/domain/calibration/ratio-samples.js +34 -0
  25. package/dist/domain/code/code-classes.js +1 -1
  26. package/dist/domain/estimate/estimate.js +22 -5
  27. package/dist/domain/progress/progress-record-parser.js +6 -0
  28. package/dist/domain/progress/session-log.js +2 -1
  29. package/dist/domain/usage/task-usage.js +24 -7
  30. package/dist/infrastructure/persistence/records.js +1 -1
  31. package/dist/infrastructure/persistence/yaml-config-store.js +6 -5
  32. package/dist/infrastructure/persistence/yaml-estimate-reader.js +20 -12
  33. package/dist/integrations/tools/claude-code/claude-code-adapter.js +29 -48
  34. package/dist/integrations/tools/claude-code/hook-events.js +4 -0
  35. package/dist/integrations/tools/claude-code/hook-translation.js +16 -34
  36. package/dist/integrations/tools/claude-code/importer/claude-code-logs.js +1 -1
  37. package/dist/integrations/tools/claude-code/skill-file.js +7 -19
  38. package/dist/integrations/tools/codex/codex-adapter.js +161 -0
  39. package/dist/integrations/tools/codex/hook-events.js +23 -0
  40. package/dist/integrations/tools/codex/hook-translation.js +76 -0
  41. package/dist/integrations/tools/codex/hook-trust.js +69 -0
  42. package/dist/integrations/tools/codex/importer/codex-logs.js +208 -0
  43. package/dist/integrations/tools/codex/importer/rollout-parser.js +163 -0
  44. package/dist/integrations/tools/codex/sandbox-rules.js +38 -0
  45. package/dist/integrations/tools/codex/skill-file.js +22 -0
  46. package/dist/integrations/tools/codex/trust-tables.js +96 -0
  47. package/dist/integrations/tools/content/commands.js +35 -26
  48. package/dist/integrations/tools/shared/generated-file.js +26 -0
  49. package/dist/integrations/tools/shared/hook-payload.js +33 -0
  50. package/dist/integrations/tools/{claude-code → shared}/hook-settings.js +37 -22
  51. package/dist/integrations/tools/shared/instructions-block.js +39 -0
  52. package/dist/integrations/tools/shared/skills-plan.js +39 -0
  53. package/dist/interface/cli/commands/calibrate-command.js +11 -0
  54. package/dist/interface/cli/commands/hook-command.js +1 -1
  55. package/dist/interface/cli/commands/init-command.js +16 -7
  56. package/dist/interface/cli/commands/status-command.js +5 -2
  57. package/dist/interface/cli/help.js +3 -1
  58. package/dist/interface/cli/presenters/text/closing-text.js +7 -3
  59. package/dist/interface/cli/presenters/text/estimate-text.js +35 -13
  60. package/dist/interface/cli/presenters/text/notices-text.js +1 -0
  61. package/dist/interface/cli/presenters/text/task-text.js +1 -1
  62. package/dist/interface/cli/presenters/text-presenter.js +3 -3
  63. package/package.json +1 -1
  64. package/dist/integrations/tools/claude-code/claude-md.js +0 -28
  65. /package/dist/integrations/tools/{claude-code/importer → shared}/log-lines.js +0 -0
@@ -71,7 +71,7 @@ function queried(slices) {
71
71
  }
72
72
  export function calibrationText(view) {
73
73
  const slices = queried(view.ratio);
74
- const lines = [coefficientLine(view, slices)];
74
+ const lines = [coefficientLine(view)];
75
75
  lines.push('', 'Fact over the first estimate:');
76
76
  const ratioRows = [
77
77
  ['overall', statsText(view.ratio.overall)],
@@ -102,25 +102,41 @@ export function calibrationText(view) {
102
102
  lines.push(...cardNotes({ skipped: [], otherAuthors: view.otherAuthors }));
103
103
  return lines.join('\n');
104
104
  }
105
- /** The coefficient to apply, or why there is none. */
106
- function coefficientLine(view, slices) {
105
+ /** The coefficient to apply with what it rests on, or why there is none. */
106
+ function coefficientLine(view) {
107
107
  const coefficient = view.coefficient;
108
- const what = view.query.revise ? 'estimates made during work' : 'first estimates';
109
108
  if (coefficient !== null) {
110
- return (`Coefficient ×${coefficient.value} (${coefficient.slice.kind} ${coefficient.slice.key}, ${coefficient.n} tasks, ${what}): ` +
111
- 'multiply the optimistic, most likely and pessimistic hours of every part.');
109
+ const what = view.query.revise ? 'estimates made during work' : 'first estimates';
110
+ const slice = coefficient.slice.kind === 'overall' ? 'overall' : `${coefficient.slice.kind} ${coefficient.slice.key}`;
111
+ const value = times(coefficient.value);
112
+ const pessimistic = times(coefficient.pessimistic);
113
+ return (`Coefficient ${value} from ${coefficient.n} ${coefficient.n === 1 ? 'task' : 'tasks'} (weight ${percent(coefficient.weight)}), ` +
114
+ `slice ${slice}; pessimistic ${pessimistic} (${what}): ` +
115
+ `multiply the optimistic and most likely hours of every part by ${value}, the pessimistic hours by ${pessimistic}.`);
112
116
  }
113
117
  if (view.skipped.length > 0) {
114
118
  // Not the sample: calibration without some cards could name a wrong coefficient.
115
119
  return (`Without calibration: cards of a newer estimetry (${view.skipped.join(', ')}) cannot be read, ` +
116
120
  'so no coefficient is given — update estimetry.');
117
121
  }
118
- const counts = (view.query.revise ? queried(view.revised) : slices).map(([name, stats]) => `${name} ${stats.n} of ${view.minTasks}`);
119
122
  const overall = view.query.revise ? view.revised.overall : view.ratio.overall;
120
- return ((counts.length === 0
121
- ? 'Without calibration: give --type or --stack; only slices by type or technology are applied.'
122
- : `Without calibration: ${counts.join(', ')} tasks needed.`) +
123
- (overall.median === null ? '' : ` Overall ×${overall.median} (${overall.n} tasks) is for reference only.`));
123
+ if (view.tasks === 0) {
124
+ return 'Without calibration: no closed task yet.';
125
+ }
126
+ if (overall.n === 0) {
127
+ if (view.query.revise) {
128
+ return 'Without calibration: no revised task counts yet.';
129
+ }
130
+ // A card without an estimate is neither a sample nor left out: there is nothing below to point to.
131
+ return Object.keys(overall.excluded).length === 0
132
+ ? 'Without calibration: none of the closed tasks has an estimate.'
133
+ : 'Without calibration: none of the closed tasks counts (see what is left out below).';
134
+ }
135
+ return `Without calibration: ${overall.n} of ${view.minTasks} tasks needed (calibration.minTasks).`;
136
+ }
137
+ /** A coefficient in text: two decimals are enough to read; `--json` keeps three. */
138
+ function times(value) {
139
+ return `×${Math.round(value * 100) / 100}`;
124
140
  }
125
141
  /** Revisions by category and `spent`, and extra work by category: shares of the base. */
126
142
  function revisionAndExtraLines(view) {
@@ -148,7 +164,9 @@ function statsText(stats) {
148
164
  return 'no tasks';
149
165
  }
150
166
  const excluded = Object.entries(stats.excluded).map(([reason, n]) => `${reason} ${n}`);
151
- return (`${stats.n} tasks, median ×${stats.median}, mean ×${stats.mean}${stats.applicable ? '' : ', too few to apply'}` +
167
+ // The weight of a whole slice is not what its level weighs in the coefficient: only the coefficient line names one.
168
+ const tooFew = stats.weight > 0 ? '' : ', too few to apply';
169
+ return (`${stats.n} tasks, median ×${stats.median}, mean ×${stats.mean}${tooFew}` +
152
170
  `${stats.revised > 0 ? `, ${stats.revised} revised` : ''}${stats.uncertain > 0 ? `, ${stats.uncertain} uncertain` : ''}` +
153
171
  `${excluded.length > 0 ? `; left out: ${excluded.join(', ')}` : ''}`);
154
172
  }
@@ -170,7 +188,7 @@ export function estimateText(estimate) {
170
188
  const context = [
171
189
  estimate.type,
172
190
  estimate.stack === undefined ? undefined : estimate.stack.join(', '),
173
- estimate.calibrated ? `calibrated ×${estimate.calibration?.coefficient ?? '?'}` : 'without calibration',
191
+ estimate.calibrated ? calibratedText(estimate.calibration) : 'without calibration',
174
192
  estimate.basedOn === undefined ? undefined : `based on ${estimate.basedOn.join(', ')}`,
175
193
  ].filter((part) => part !== undefined);
176
194
  return table([
@@ -182,4 +200,8 @@ export function estimateText(estimate) {
182
200
  }),
183
201
  ]);
184
202
  }
203
+ function calibratedText(calibration) {
204
+ const pessimistic = calibration?.pessimistic === undefined ? '' : `, pessimistic ×${calibration.pessimistic}`;
205
+ return `calibrated ×${calibration?.coefficient ?? '?'}${pessimistic}`;
206
+ }
185
207
  //# sourceMappingURL=estimate-text.js.map
@@ -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 (/emt-estimate) or create a task with `emt task new "<title>"`.',
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 /emt-start); add --at "YYYY-MM-DD HH:MM" if it already began.`),
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 /emt-retro).`,
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 (/emt-estimate), start it, and attach sessions with \`emt attach ${spawned.id} --session <id>\`.`,
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,6 +1,6 @@
1
1
  {
2
2
  "name": "estimetry",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "description": "Compares work estimates with actual effort in AI-agent development and reuses that experience in the next estimate",
5
5
  "keywords": [
6
6
  "estimation",
@@ -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