@cobusgreyling/loop-cost 1.0.2 → 1.0.3

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/cli.js CHANGED
@@ -3,7 +3,7 @@ import { readFile, access } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import yaml from 'yaml';
6
- import { estimateCost, formatEstimateHuman, } from './estimator.js';
6
+ import { assertValidLevel, estimateCost, formatEstimateHuman, } from './estimator.js';
7
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
8
  const PACKAGE_ROOT = path.resolve(__dirname, '..');
9
9
  function parseArgs(argv) {
@@ -87,6 +87,14 @@ Examples:
87
87
  console.error(`Unknown pattern: ${args.pattern}. Use --list for ids.`);
88
88
  process.exit(1);
89
89
  }
90
+ try {
91
+ assertValidLevel(args.level);
92
+ }
93
+ catch (err) {
94
+ const msg = err instanceof Error ? err.message : String(err);
95
+ console.error(msg);
96
+ process.exit(1);
97
+ }
90
98
  if (!pattern.cost) {
91
99
  console.error(`Pattern ${args.pattern} has no cost block in registry.`);
92
100
  process.exit(1);
@@ -1,4 +1,6 @@
1
1
  export type ReadinessLevel = 'L1' | 'L2' | 'L3';
2
+ export declare const VALID_READINESS_LEVELS: ReadinessLevel[];
3
+ export declare function assertValidLevel(level: string): asserts level is ReadinessLevel;
2
4
  export interface PatternCost {
3
5
  tokens_noop: number;
4
6
  tokens_report: number;
package/dist/estimator.js CHANGED
@@ -1,3 +1,9 @@
1
+ export const VALID_READINESS_LEVELS = ['L1', 'L2', 'L3'];
2
+ export function assertValidLevel(level) {
3
+ if (!VALID_READINESS_LEVELS.includes(level)) {
4
+ throw new Error(`Invalid level: ${level}. Valid: ${VALID_READINESS_LEVELS.join(', ')}`);
5
+ }
6
+ }
1
7
  const INTERVAL_MS = {
2
8
  m: 60_000,
3
9
  h: 3_600_000,
@@ -62,6 +68,7 @@ function formatTokens(n) {
62
68
  return String(n);
63
69
  }
64
70
  export function estimateCost(input) {
71
+ assertValidLevel(input.level);
65
72
  const cadence = input.cadence ?? input.pattern.cadence;
66
73
  const runsPerDay = cadenceToRunsPerDay(cadence, input.conservative);
67
74
  const { cost, token_cost: tokenCostTier } = input.pattern;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobusgreyling/loop-cost",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Estimate token budgets and daily costs for loop engineering patterns. By cadence, readiness level (L1/L2/L3), and coding agent tool.",
5
5
  "type": "module",
6
6
  "bin": {
package/registry.json CHANGED
@@ -279,7 +279,7 @@
279
279
  "ambiguous-duplicates",
280
280
  "stale-closures"
281
281
  ],
282
- "starter": "starters/minimal-loop",
282
+ "starter": "starters/issue-triage",
283
283
  "week_one_mode": "L1",
284
284
  "token_cost": "low",
285
285
  "cost": {