guild-agents 1.4.0 → 2.0.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 (58) hide show
  1. package/README.md +69 -68
  2. package/bin/guild.js +4 -85
  3. package/package.json +2 -2
  4. package/src/commands/doctor.js +11 -33
  5. package/src/commands/init.js +1 -1
  6. package/src/templates/agents/advisor.md +0 -1
  7. package/src/templates/agents/developer.md +2 -2
  8. package/src/templates/agents/qa.md +1 -1
  9. package/src/templates/agents/tech-lead.md +2 -2
  10. package/src/templates/skills/build-feature/SKILL.md +59 -117
  11. package/src/templates/skills/build-feature/evals/evals.json +3 -4
  12. package/src/templates/skills/council/SKILL.md +6 -16
  13. package/src/templates/skills/council/evals/evals.json +3 -13
  14. package/src/templates/skills/create-pr/SKILL.md +2 -5
  15. package/src/templates/skills/guild-specialize/SKILL.md +2 -9
  16. package/src/templates/skills/qa-cycle/SKILL.md +0 -7
  17. package/src/templates/skills/re-specialize/SKILL.md +0 -3
  18. package/src/templates/skills/session-end/SKILL.md +77 -30
  19. package/src/templates/skills/session-start/SKILL.md +51 -20
  20. package/src/utils/eval-runner.js +2 -8
  21. package/src/utils/generators.js +3 -4
  22. package/src/utils/skill-parser.js +83 -0
  23. package/src/utils/trigger-runner.js +1 -1
  24. package/src/commands/logs.js +0 -63
  25. package/src/commands/reset-learnings.js +0 -44
  26. package/src/commands/run.js +0 -105
  27. package/src/commands/stats.js +0 -147
  28. package/src/templates/agents/db-migration.md +0 -51
  29. package/src/templates/agents/learnings-extractor.md +0 -49
  30. package/src/templates/agents/platform-expert.md +0 -92
  31. package/src/templates/agents/product-owner.md +0 -52
  32. package/src/templates/skills/dev-flow/SKILL.md +0 -83
  33. package/src/templates/skills/dev-flow/evals/evals.json +0 -36
  34. package/src/templates/skills/dev-flow/evals/triggers.json +0 -16
  35. package/src/templates/skills/new-feature/SKILL.md +0 -119
  36. package/src/templates/skills/new-feature/evals/evals.json +0 -41
  37. package/src/templates/skills/new-feature/evals/triggers.json +0 -16
  38. package/src/templates/skills/review/SKILL.md +0 -97
  39. package/src/templates/skills/review/evals/evals.json +0 -43
  40. package/src/templates/skills/review/evals/triggers.json +0 -16
  41. package/src/templates/skills/status/SKILL.md +0 -100
  42. package/src/templates/skills/status/evals/evals.json +0 -40
  43. package/src/templates/skills/status/evals/triggers.json +0 -16
  44. package/src/templates/skills/verify/SKILL.md +0 -114
  45. package/src/templates/skills/verify/evals/triggers.json +0 -16
  46. package/src/utils/accounting.js +0 -139
  47. package/src/utils/dispatch-protocol.js +0 -74
  48. package/src/utils/dispatch.js +0 -172
  49. package/src/utils/executor.js +0 -183
  50. package/src/utils/learnings-io.js +0 -76
  51. package/src/utils/learnings.js +0 -204
  52. package/src/utils/orchestrator-io.js +0 -356
  53. package/src/utils/orchestrator.js +0 -590
  54. package/src/utils/pricing.js +0 -28
  55. package/src/utils/providers/claude-code.js +0 -43
  56. package/src/utils/skill-loader.js +0 -83
  57. package/src/utils/trace.js +0 -400
  58. package/src/utils/workflow-parser.js +0 -225
@@ -1,16 +0,0 @@
1
- {
2
- "skill": "new-feature",
3
- "matcherType": "keyword",
4
- "description": "Creates branch and scaffold for a new feature",
5
- "threshold": 0.3,
6
- "tests": [
7
- { "prompt": "create a new feature branch", "shouldTrigger": true },
8
- { "prompt": "scaffold a new feature", "shouldTrigger": true },
9
- { "prompt": "start a new feature called user-auth", "shouldTrigger": true },
10
- { "prompt": "prepare the branch for a new feature", "shouldTrigger": true },
11
- { "prompt": "review my code", "shouldTrigger": false },
12
- { "prompt": "create a pull request", "shouldTrigger": false },
13
- { "prompt": "debug this bug", "shouldTrigger": false },
14
- { "prompt": "save my session", "shouldTrigger": false }
15
- ]
16
- }
@@ -1,97 +0,0 @@
1
- ---
2
- name: review
3
- description: "Standalone code review on the current diff"
4
- user-invocable: true
5
- workflow:
6
- version: 1
7
- steps:
8
- - id: gather-diff
9
- role: system
10
- intent: "Get current git diff (staged or unstaged) and run tests + lint for context."
11
- commands: [git diff --staged, git diff, npm test, npm run lint]
12
- produces: [diff-content, test-result, lint-result]
13
- - id: review
14
- role: code-reviewer
15
- intent: "Review code quality, patterns, security, and tests. Classify findings by severity."
16
- requires: [diff-content, test-result, lint-result]
17
- produces: [review-report]
18
- model-tier: reasoning
19
- - id: present
20
- role: system
21
- intent: "Present findings organized by severity with final verdict."
22
- requires: [review-report]
23
- produces: [formatted-report]
24
- gate: true
25
- ---
26
-
27
- # Review
28
-
29
- Runs an independent code review on the current project changes. Invokes the Code Reviewer agent to analyze quality, patterns, security, and technical debt.
30
-
31
- ## When to use
32
-
33
- - Before creating a PR
34
- - To review your own changes before requesting review from others
35
- - When you want a second opinion on the code you wrote
36
-
37
- ## Usage
38
-
39
- `/review`
40
-
41
- ## Process
42
-
43
- ### Step 1 — Get diff and verification state
44
-
45
- Get the current changes:
46
-
47
- 1. First try `git diff --staged` (staged changes)
48
- 2. If there are no staged changes, use `git diff` (unstaged changes)
49
- 3. If there are no changes at all, report that there is nothing to review
50
-
51
- Run automated verification to give context to the reviewer:
52
-
53
- 1. Run project tests (e.g., `npm test`) — capture result
54
- 2. Run project lint (e.g., `npm run lint`) — capture result
55
- 3. Include both results as context for the Code Reviewer
56
-
57
- Note: The Code Reviewer does not have access to Bash (only Read, Glob, Grep), so tests and lint are run here before invoking the reviewer.
58
-
59
- ### Step 2 — Invoke Code Reviewer
60
-
61
- Invoke the Code Reviewer agent using Task tool with `model: "opus"` (reasoning tier):
62
-
63
- 1. Read `.claude/agents/code-reviewer.md` to assume the role
64
- 2. Read CLAUDE.md to understand the project conventions
65
- 3. Receive the full diff + test and lint results from Step 1
66
- 4. If tests or lint failed, this is automatically a Blocker finding
67
- 5. Review the full diff
68
- 6. Classify each finding by severity:
69
- - **Blocker**: Must be fixed before merge
70
- - **Warning**: Should be fixed, introduces technical debt
71
- - **Suggestion**: Optional improvement
72
-
73
- ### Step 3 — Present findings
74
-
75
- Present the report organized by severity:
76
-
77
- - Total count of findings by type
78
- - Detail of each finding: file, description, suggested fix
79
- - Final verdict: Approved / Approved with warnings / Blocked
80
-
81
- If there are blockers, suggest fixing them and running `/review` again.
82
-
83
- ## Example Session
84
-
85
- ```text
86
- User: /review
87
-
88
- Reviewing diff: 4 files changed, +127 -34
89
- Code Reviewer (opus) — Reviewing changes...
90
-
91
- Findings:
92
- - [Warning] src/api/users.js:45 — No input validation on email parameter
93
- - [Suggestion] src/utils/format.js:12 — Consider using Intl.DateTimeFormat
94
- - [Blocker] src/db/queries.js:78 — SQL injection vulnerability in raw query
95
-
96
- 1 blocker, 1 warning, 1 suggestion.
97
- ```
@@ -1,43 +0,0 @@
1
- {
2
- "skill": "review",
3
- "evals": [
4
- {
5
- "id": "rv-has-core-steps",
6
- "description": "Review has gather-diff, review, and present steps",
7
- "expectations": [
8
- { "text": "Has gather-diff step", "assertion": "step-exists:gather-diff" },
9
- { "text": "Has review step", "assertion": "step-exists:review" },
10
- { "text": "Has present step", "assertion": "step-exists:present" }
11
- ]
12
- },
13
- {
14
- "id": "rv-reviewer-role",
15
- "description": "Review step uses code-reviewer role",
16
- "expectations": [
17
- { "text": "review uses code-reviewer role", "assertion": "step-role:review:code-reviewer" }
18
- ]
19
- },
20
- {
21
- "id": "rv-reasoning-tier",
22
- "description": "Code review uses reasoning tier (opus)",
23
- "expectations": [
24
- { "text": "review uses reasoning tier", "assertion": "step-model-tier:review:reasoning" }
25
- ]
26
- },
27
- {
28
- "id": "rv-presentation-gate",
29
- "description": "Present step has gate for user review",
30
- "expectations": [
31
- { "text": "present has gate", "assertion": "gate-exists:present" }
32
- ]
33
- },
34
- {
35
- "id": "rv-dependencies",
36
- "description": "Review requires diff content, present requires report",
37
- "expectations": [
38
- { "text": "review requires diff-content", "assertion": "step-requires:review:diff-content" },
39
- { "text": "present requires review-report", "assertion": "step-requires:present:review-report" }
40
- ]
41
- }
42
- ]
43
- }
@@ -1,16 +0,0 @@
1
- {
2
- "skill": "review",
3
- "matcherType": "keyword",
4
- "description": "Standalone code review on the current diff",
5
- "threshold": 0.3,
6
- "tests": [
7
- { "prompt": "review my code", "shouldTrigger": true },
8
- { "prompt": "do a code review on the current changes", "shouldTrigger": true },
9
- { "prompt": "check my diff for issues", "shouldTrigger": true },
10
- { "prompt": "review the current diff", "shouldTrigger": true },
11
- { "prompt": "create a pull request", "shouldTrigger": false },
12
- { "prompt": "save my session", "shouldTrigger": false },
13
- { "prompt": "what phase am I in", "shouldTrigger": false },
14
- { "prompt": "start a new feature", "shouldTrigger": false }
15
- ]
16
- }
@@ -1,100 +0,0 @@
1
- ---
2
- name: status
3
- description: "Shows current project and session state"
4
- user-invocable: true
5
- workflow:
6
- version: 1
7
- steps:
8
- - id: read-state
9
- role: system
10
- intent: "Read CLAUDE.md, PROJECT.md, and SESSION.md for project state."
11
- commands: [cat CLAUDE.md, cat PROJECT.md, cat SESSION.md]
12
- produces: [claude-md, project-md, session-md]
13
- - id: scan-resources
14
- role: system
15
- intent: "List available agents and skills from .claude/ directories."
16
- commands: [ls .claude/agents/, ls .claude/skills/]
17
- produces: [agent-list, skill-list]
18
- - id: present-status
19
- role: system
20
- intent: "Display project summary: name, stack, session state, agents, skills, and suggested next steps."
21
- requires: [project-md, session-md, agent-list, skill-list]
22
- produces: [status-display]
23
- gate: true
24
- ---
25
-
26
- # Status
27
-
28
- Shows a complete summary of the current project state, the active session, and the available Guild resources.
29
-
30
- ## When to use
31
-
32
- - At the start of a session to get oriented
33
- - To verify that Guild is correctly configured
34
- - To see which agents and skills are available
35
-
36
- ## Usage
37
-
38
- `/status`
39
-
40
- ## Process
41
-
42
- ### Step 1 — Read state files
43
-
44
- Read the Guild configuration files:
45
-
46
- - `CLAUDE.md` — project instructions and conventions
47
- - `PROJECT.md` — identity, stack, and configured agents
48
- - `SESSION.md` — current session state
49
-
50
- ### Step 2 — Present state
51
-
52
- Show the summary in the following format:
53
-
54
- ```text
55
- Guild v1 — [project name]
56
-
57
- Current session:
58
- - Date: [date from SESSION.md]
59
- - Task in progress: [task or "none"]
60
- - State: [current state]
61
-
62
- Stack:
63
- - [technologies listed in PROJECT.md]
64
-
65
- Available agents:
66
- - [list of .md files in .claude/agents/]
67
-
68
- Available skills:
69
- - [list of directories in .claude/skills/]
70
-
71
- Next steps:
72
- - [extracted from SESSION.md]
73
- ```
74
-
75
- ### Step 3 — Suggest actions
76
-
77
- If there is no task in progress, suggest:
78
-
79
- - `/build-feature` to implement something new
80
- - `/new-feature` to prepare the environment for a feature
81
- - `/council` to debate a decision
82
-
83
- If there is a task in progress, suggest continuing with the appropriate skill based on the state.
84
-
85
- ## Example Session
86
-
87
- ```text
88
- User: /status
89
-
90
- Guild — MyProject
91
- Stack: Node.js 20, React 18, PostgreSQL
92
-
93
- Session: 2026-02-23
94
- Task: Implementing user preferences
95
- State: Phase 4 — Developer implementing
96
-
97
- Agents: advisor, product-owner, tech-lead, developer, code-reviewer, qa, bugfix, db-migration, platform-expert
98
- Skills: guild-specialize, build-feature, new-feature, council, qa-cycle, review, dev-flow,
99
- status, session-start, session-end
100
- ```
@@ -1,40 +0,0 @@
1
- {
2
- "skill": "status",
3
- "evals": [
4
- {
5
- "id": "st-has-core-steps",
6
- "description": "Status has read-state, scan-resources, present steps",
7
- "expectations": [
8
- { "text": "Has read-state step", "assertion": "step-exists:read-state" },
9
- { "text": "Has scan-resources step", "assertion": "step-exists:scan-resources" },
10
- { "text": "Has present-status step", "assertion": "step-exists:present-status" }
11
- ]
12
- },
13
- {
14
- "id": "st-all-system",
15
- "description": "All steps are system role",
16
- "expectations": [
17
- { "text": "read-state is system", "assertion": "step-role:read-state:system" },
18
- { "text": "scan-resources is system", "assertion": "step-role:scan-resources:system" },
19
- { "text": "present-status is system", "assertion": "step-role:present-status:system" }
20
- ]
21
- },
22
- {
23
- "id": "st-presentation-gate",
24
- "description": "Present-status has gate",
25
- "expectations": [
26
- { "text": "present-status has gate", "assertion": "gate-exists:present-status" }
27
- ]
28
- },
29
- {
30
- "id": "st-dependencies",
31
- "description": "Present-status requires project and session data",
32
- "expectations": [
33
- { "text": "present-status requires project-md", "assertion": "step-requires:present-status:project-md" },
34
- { "text": "present-status requires session-md", "assertion": "step-requires:present-status:session-md" },
35
- { "text": "present-status requires agent-list", "assertion": "step-requires:present-status:agent-list" },
36
- { "text": "present-status requires skill-list", "assertion": "step-requires:present-status:skill-list" }
37
- ]
38
- }
39
- ]
40
- }
@@ -1,16 +0,0 @@
1
- {
2
- "skill": "status",
3
- "matcherType": "keyword",
4
- "description": "Shows current project and session state",
5
- "threshold": 0.3,
6
- "tests": [
7
- { "prompt": "show the project status", "shouldTrigger": true },
8
- { "prompt": "show current session state", "shouldTrigger": true },
9
- { "prompt": "what is the current project state", "shouldTrigger": true },
10
- { "prompt": "how is the project going", "shouldTrigger": true },
11
- { "prompt": "create a pull request", "shouldTrigger": false },
12
- { "prompt": "review my code", "shouldTrigger": false },
13
- { "prompt": "debug this bug", "shouldTrigger": false },
14
- { "prompt": "save my session", "shouldTrigger": false }
15
- ]
16
- }
@@ -1,114 +0,0 @@
1
- ---
2
- name: verify
3
- description: "Discipline skill — verification before completion. Use when about to claim work is complete, fixed, or passing, before committing or creating PRs."
4
- user-invocable: true
5
- ---
6
-
7
- # Verification Before Completion
8
-
9
- Claiming work is complete without verification is dishonesty, not efficiency.
10
-
11
- **Core principle:** Evidence before claims, always.
12
-
13
- ## Usage
14
-
15
- `/verify`
16
-
17
- Invoke this skill before claiming any work is done, before committing, and before creating PRs.
18
-
19
- ## When to use
20
-
21
- **ALWAYS before:**
22
-
23
- - Any success or completion claim
24
- - Committing, pushing, or creating PRs
25
- - Moving to the next task
26
- - Expressing satisfaction about work state
27
-
28
- ## The Iron Law
29
-
30
- ```text
31
- NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE
32
- ```
33
-
34
- If you haven't run the verification command in this step, you cannot claim it passes.
35
-
36
- ## The Gate Function
37
-
38
- ```text
39
- BEFORE claiming any status:
40
-
41
- 1. IDENTIFY: What command proves this claim?
42
- 2. RUN: Execute the FULL command (fresh, complete)
43
- 3. READ: Full output, check exit code, count failures
44
- 4. VERIFY: Does output confirm the claim?
45
- - If NO: State actual status with evidence
46
- - If YES: State claim WITH evidence
47
- 5. ONLY THEN: Make the claim
48
-
49
- Skip any step = lying, not verifying
50
- ```
51
-
52
- ## What Each Claim Requires
53
-
54
- | Claim | Requires | Not Sufficient |
55
- | ---------------- | ------------------------------- | ------------------------------ |
56
- | Tests pass | Test command output: 0 failures | Previous run, "should pass" |
57
- | Linter clean | Linter output: 0 errors | Partial check, extrapolation |
58
- | Build succeeds | Build command: exit 0 | Linter passing, logs look good |
59
- | Bug fixed | Test original symptom: passes | Code changed, assumed fixed |
60
- | Regression test | Red-green cycle verified | Test passes once |
61
- | Requirements met | Line-by-line checklist | Tests passing |
62
-
63
- ## Red Flags - STOP
64
-
65
- - Using "should", "probably", "seems to"
66
- - Expressing satisfaction before verification ("Great!", "Perfect!", "Done!")
67
- - About to commit/push/PR without verification
68
- - Relying on partial verification
69
- - Thinking "just this once"
70
- - ANY wording implying success without having run verification
71
-
72
- ## Common Rationalizations
73
-
74
- | Excuse | Reality |
75
- | ---------------------------- | ------------------------------ |
76
- | "Should work now" | RUN the verification |
77
- | "I'm confident" | Confidence is not evidence |
78
- | "Just this once" | No exceptions |
79
- | "Linter passed" | Linter is not compiler |
80
- | "Partial check is enough" | Partial proves nothing |
81
-
82
- ## Verification Patterns
83
-
84
- **Tests:**
85
-
86
- ```text
87
- OK: [Run test command] [See: 34/34 pass] "All tests pass"
88
- BAD: "Should pass now" / "Looks correct"
89
- ```
90
-
91
- **Build:**
92
-
93
- ```text
94
- OK: [Run build] [See: exit 0] "Build passes"
95
- BAD: "Linter passed" (linter doesn't check compilation)
96
- ```
97
-
98
- **Requirements:**
99
-
100
- ```text
101
- OK: Re-read plan -> Create checklist -> Verify each -> Report gaps or completion
102
- BAD: "Tests pass, phase complete"
103
- ```
104
-
105
- ## The Bottom Line
106
-
107
- Run the command. Read the output. THEN claim the result.
108
-
109
- No shortcuts. Non-negotiable.
110
-
111
- ## Related Skills
112
-
113
- - `/tdd` — TDD ensures tests exist before claiming code works
114
- - `/debug` — systematic debugging when verification reveals failures
@@ -1,16 +0,0 @@
1
- {
2
- "skill": "verify",
3
- "matcherType": "keyword",
4
- "description": "Discipline skill — verification before completion. Use when about to claim work is complete, fixed, or passing, before committing or creating PRs.",
5
- "threshold": 0.3,
6
- "tests": [
7
- { "prompt": "verify before committing", "shouldTrigger": true },
8
- { "prompt": "run verification before completion", "shouldTrigger": true },
9
- { "prompt": "verify the work is complete", "shouldTrigger": true },
10
- { "prompt": "make sure everything passes before the PR", "shouldTrigger": true, "keywordExpected": false },
11
- { "prompt": "create a pull request", "shouldTrigger": false },
12
- { "prompt": "review my code", "shouldTrigger": false },
13
- { "prompt": "debug this bug", "shouldTrigger": false },
14
- { "prompt": "save my session", "shouldTrigger": false }
15
- ]
16
- }
@@ -1,139 +0,0 @@
1
- /**
2
- * accounting.js — Token usage recording, persistence, and aggregation.
3
- *
4
- * Persists usage data to .claude/guild/usage.json.
5
- */
6
-
7
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
8
- import { join, dirname } from 'path';
9
- import { estimateCost } from './pricing.js';
10
-
11
- const USAGE_PATH = join('.claude', 'guild', 'usage.json');
12
-
13
- export function emptyUsage() {
14
- return {
15
- version: 1,
16
- lastUpdated: new Date().toISOString(),
17
- entries: [],
18
- totals: {
19
- totalTokens: 0,
20
- totalInputTokens: 0,
21
- totalOutputTokens: 0,
22
- totalCostUSD: 0,
23
- tokensByModel: {},
24
- tokensByTier: {},
25
- tokensByWorkflow: {},
26
- workflowCount: 0,
27
- },
28
- };
29
- }
30
-
31
- export function createEntry({ workflow, agent, tier, model, inputTokens, outputTokens }) {
32
- const totalTokens = inputTokens + outputTokens;
33
- return {
34
- timestamp: new Date().toISOString(),
35
- workflow,
36
- agent,
37
- tier,
38
- model,
39
- inputTokens,
40
- outputTokens,
41
- totalTokens,
42
- estimatedCostUSD: estimateCost(model, inputTokens, outputTokens),
43
- };
44
- }
45
-
46
- export function loadUsage(root) {
47
- const filePath = join(root, USAGE_PATH);
48
- if (!existsSync(filePath)) return emptyUsage();
49
- try {
50
- return JSON.parse(readFileSync(filePath, 'utf8'));
51
- } catch {
52
- return emptyUsage();
53
- }
54
- }
55
-
56
- export function saveUsage(root, usage) {
57
- const filePath = join(root, USAGE_PATH);
58
- mkdirSync(dirname(filePath), { recursive: true });
59
- usage.lastUpdated = new Date().toISOString();
60
- writeFileSync(filePath, JSON.stringify(usage, null, 2) + '\n');
61
- }
62
-
63
- function updateTotals(totals, entry) {
64
- totals.totalTokens += entry.totalTokens;
65
- totals.totalInputTokens += entry.inputTokens;
66
- totals.totalOutputTokens += entry.outputTokens;
67
- totals.totalCostUSD += entry.estimatedCostUSD;
68
- totals.tokensByModel[entry.model] = (totals.tokensByModel[entry.model] || 0) + entry.totalTokens;
69
- totals.tokensByTier[entry.tier] = (totals.tokensByTier[entry.tier] || 0) + entry.totalTokens;
70
- totals.tokensByWorkflow[entry.workflow] = (totals.tokensByWorkflow[entry.workflow] || 0) + entry.totalTokens;
71
- totals.workflowCount += 1;
72
- }
73
-
74
- export function recordStep(root, params) {
75
- const usage = loadUsage(root);
76
- const entry = createEntry(params);
77
- usage.entries.push(entry);
78
- updateTotals(usage.totals, entry);
79
- saveUsage(root, usage);
80
- }
81
-
82
- const PROFILES = {
83
- max: { reasoning: 'claude-opus-4-6', execution: 'claude-sonnet-4-5', routine: 'claude-haiku-4-5' },
84
- pro: { reasoning: 'claude-sonnet-4-5', execution: 'claude-sonnet-4-5', routine: 'claude-haiku-4-5' },
85
- 'all-opus': { reasoning: 'claude-opus-4-6', execution: 'claude-opus-4-6', routine: 'claude-opus-4-6' },
86
- };
87
-
88
- export function aggregate(root, period) {
89
- const usage = loadUsage(root);
90
- const now = new Date();
91
- let cutoff;
92
-
93
- switch (period) {
94
- case 'today':
95
- cutoff = new Date(now.getFullYear(), now.getMonth(), now.getDate());
96
- break;
97
- case 'week':
98
- cutoff = new Date(now);
99
- cutoff.setDate(cutoff.getDate() - 7);
100
- break;
101
- case 'month':
102
- cutoff = new Date(now);
103
- cutoff.setDate(cutoff.getDate() - 30);
104
- break;
105
- default:
106
- cutoff = new Date(0);
107
- }
108
-
109
- const filtered = usage.entries.filter(e => new Date(e.timestamp) >= cutoff);
110
-
111
- const totals = {
112
- totalTokens: 0,
113
- totalInputTokens: 0,
114
- totalOutputTokens: 0,
115
- totalCostUSD: 0,
116
- tokensByModel: {},
117
- tokensByTier: {},
118
- tokensByWorkflow: {},
119
- workflowCount: 0,
120
- };
121
-
122
- for (const entry of filtered) {
123
- updateTotals(totals, entry);
124
- }
125
-
126
- return totals;
127
- }
128
-
129
- export function estimateWithProfile(entries, profileName) {
130
- const profile = PROFILES[profileName];
131
- if (!profile) return 0;
132
-
133
- let cost = 0;
134
- for (const entry of entries) {
135
- const model = profile[entry.tier] || entry.model;
136
- cost += estimateCost(model, entry.inputTokens, entry.outputTokens);
137
- }
138
- return cost;
139
- }
@@ -1,74 +0,0 @@
1
- /**
2
- * dispatch-protocol.js — Constants and type definitions for the Guild dispatch protocol.
3
- *
4
- * Defines the vocabulary shared by dispatch utilities, workflow parser,
5
- * model routing, and trace modules. Zero dependencies.
6
- */
7
-
8
- /**
9
- * Valid model tier values. Each tier maps to a class of model capability.
10
- * @type {readonly ['reasoning', 'execution', 'routine']}
11
- */
12
- export const MODEL_TIERS = ['reasoning', 'execution', 'routine'];
13
-
14
- /**
15
- * Valid failure strategy base values for workflow steps.
16
- * - abort: halt the workflow on failure (default)
17
- * - continue: skip this step and proceed
18
- * Additionally, `goto:<step-id>` is valid for redirecting to another step.
19
- * @type {readonly ['abort', 'continue']}
20
- */
21
- export const FAILURE_STRATEGIES = ['abort', 'continue'];
22
-
23
- /**
24
- * Default failure strategy when none is specified.
25
- * @type {string}
26
- */
27
- export const DEFAULT_FAILURE_STRATEGY = 'abort';
28
-
29
- /**
30
- * Default tier assignment for each Guild agent role.
31
- * Used as fallback when neither the workflow step nor the agent frontmatter
32
- * specifies a tier.
33
- * @type {Record<string, string>}
34
- */
35
- export const DEFAULT_AGENT_TIERS = {
36
- 'advisor': 'reasoning',
37
- 'product-owner': 'reasoning',
38
- 'tech-lead': 'reasoning',
39
- 'code-reviewer': 'reasoning',
40
- 'developer': 'execution',
41
- 'bugfix': 'execution',
42
- 'db-migration': 'execution',
43
- 'qa': 'execution',
44
- 'platform-expert': 'execution',
45
- 'learnings-extractor': 'routine',
46
- };
47
-
48
- /**
49
- * Built-in model profiles mapping tiers to concrete model IDs.
50
- * @type {Record<string, Record<string, string>>}
51
- */
52
- export const DEFAULT_MODEL_PROFILES = {
53
- max: {
54
- reasoning: 'claude-opus-4-6',
55
- execution: 'claude-sonnet-4-6',
56
- routine: 'claude-haiku-4-5',
57
- },
58
- pro: {
59
- reasoning: 'claude-sonnet-4-6',
60
- execution: 'claude-sonnet-4-6',
61
- routine: 'claude-haiku-4-5',
62
- },
63
- };
64
-
65
- /**
66
- * Fallback chain for tier resolution. When a tier's model is unavailable,
67
- * fall back to the next tier. `null` means no further fallback.
68
- * @type {Record<string, string|null>}
69
- */
70
- export const FALLBACK_CHAIN = {
71
- reasoning: 'execution',
72
- execution: 'routine',
73
- routine: null,
74
- };