@adhd/agent-engine-compiler 2.1.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 (62) hide show
  1. package/drizzle/meta/_journal.json +5 -0
  2. package/package.json +58 -0
  3. package/src/cache/composed-prompt-cache.d.ts +60 -0
  4. package/src/cache/composed-prompt-cache.d.ts.map +1 -0
  5. package/src/cache/composed-prompt-cache.js +120 -0
  6. package/src/cache/composed-prompt-cache.js.map +1 -0
  7. package/src/cli/compile.d.ts +3 -0
  8. package/src/cli/compile.d.ts.map +1 -0
  9. package/src/cli/compile.js +294 -0
  10. package/src/cli/compile.js.map +1 -0
  11. package/src/compile.d.ts +61 -0
  12. package/src/compile.d.ts.map +1 -0
  13. package/src/compile.js +279 -0
  14. package/src/compile.js.map +1 -0
  15. package/src/db/client.d.ts +7 -0
  16. package/src/db/client.d.ts.map +1 -0
  17. package/src/db/client.js +31 -0
  18. package/src/db/client.js.map +1 -0
  19. package/src/db/migrate-runner.d.ts +31 -0
  20. package/src/db/migrate-runner.d.ts.map +1 -0
  21. package/src/db/migrate-runner.js +35 -0
  22. package/src/db/migrate-runner.js.map +1 -0
  23. package/src/db/migrate.d.ts +9 -0
  24. package/src/db/migrate.d.ts.map +1 -0
  25. package/src/db/migrate.js +13 -0
  26. package/src/db/migrate.js.map +1 -0
  27. package/src/db/schema.d.ts +3 -0
  28. package/src/db/schema.d.ts.map +1 -0
  29. package/src/db/schema.js +30 -0
  30. package/src/db/schema.js.map +1 -0
  31. package/src/emit/json.d.ts +50 -0
  32. package/src/emit/json.d.ts.map +1 -0
  33. package/src/emit/json.js +66 -0
  34. package/src/emit/json.js.map +1 -0
  35. package/src/emit/markdown.d.ts +35 -0
  36. package/src/emit/markdown.d.ts.map +1 -0
  37. package/src/emit/markdown.js +90 -0
  38. package/src/emit/markdown.js.map +1 -0
  39. package/src/index.d.ts +20 -0
  40. package/src/index.d.ts.map +1 -0
  41. package/src/index.js +23 -0
  42. package/src/index.js.map +1 -0
  43. package/src/resolve/composition.d.ts +28 -0
  44. package/src/resolve/composition.d.ts.map +1 -0
  45. package/src/resolve/composition.js +33 -0
  46. package/src/resolve/composition.js.map +1 -0
  47. package/src/resolve/model.d.ts +22 -0
  48. package/src/resolve/model.d.ts.map +1 -0
  49. package/src/resolve/model.js +69 -0
  50. package/src/resolve/model.js.map +1 -0
  51. package/src/resolve/policy.d.ts +34 -0
  52. package/src/resolve/policy.d.ts.map +1 -0
  53. package/src/resolve/policy.js +44 -0
  54. package/src/resolve/policy.js.map +1 -0
  55. package/src/resolve/tools.d.ts +33 -0
  56. package/src/resolve/tools.d.ts.map +1 -0
  57. package/src/resolve/tools.js +62 -0
  58. package/src/resolve/tools.js.map +1 -0
  59. package/src/seed/fixtures.d.ts +52 -0
  60. package/src/seed/fixtures.d.ts.map +1 -0
  61. package/src/seed/fixtures.js +148 -0
  62. package/src/seed/fixtures.js.map +1 -0
@@ -0,0 +1,148 @@
1
+ /**
2
+ * fixtures.ts — real-row fixture seeder for agent-compiler e2e tests.
3
+ *
4
+ * Exports `seedFixtureAgent(db)` which seeds the `api-design-reviewer` fixture
5
+ * agent (modelled after SEED_DATA.md §14 `code-reviewer`) into a shared SQLite
6
+ * DB handle that already has all four package migrations applied.
7
+ *
8
+ * Seed coverage:
9
+ * - registry prefix : taxonomy category, agent, components, junction rows
10
+ * - tool prefix : agent tool grants (file_read, file_grep, web_search)
11
+ * - provider prefix : model_hint = claude_sonnet_4_6 (seeded by seedProvider)
12
+ * - policy prefix : no-credentials policy template + direct attachment
13
+ *
14
+ * The two `success_criteria` junction rows are conditioned:
15
+ * position=4 → code-review-criteria (no context condition — general/review)
16
+ * position=5 → security-audit-criteria (context_condition={ticket_type:"security"})
17
+ *
18
+ * This mirrors the exact pattern from SEED_DATA.md §14 (code-reviewer, positions
19
+ * 5+6) and USAGE.md "Context-Conditional Composition".
20
+ *
21
+ * [inv:one-db-handle] — caller passes ONE shared DB handle, all four prefixes.
22
+ * [inv:real-rows-not-mocks] — this function seeds real rows; no mocks needed.
23
+ */
24
+ import { AgentStore, TaxonomyStore, CompositionStore, } from '@adhd/agent-store-prompts';
25
+ import { AgentToolStore } from '@adhd/agent-store-tools';
26
+ import { AgentPolicyStore } from '@adhd/agent-core-policy';
27
+ // ── exported fixture constants ─────────────────────────────────────────────
28
+ /** Slug of the seeded fixture agent. */
29
+ export const FIXTURE_AGENT_SLUG = 'api-design-reviewer-e2e';
30
+ export const FIXTURE_CATEGORY_SLUG = 'e2e-api-specialists';
31
+ // Component slugs from the shared registry seed (SEED_DATA.md §8).
32
+ // These must exist after seedRegistry() has run against the same DB.
33
+ export const COMP_ROLE = 'generic-reviewer-role'; // position 1
34
+ export const COMP_IDENTITY = 'reviewer-identity'; // position 2
35
+ export const COMP_RULE = 'default-skeptic'; // position 3
36
+ export const COMP_REVIEW_CRITERIA = 'code-review-criteria'; // position 4 – general
37
+ export const COMP_SECURITY_CRITERIA = 'security-audit-criteria'; // position 5 – {ticket_type:security}
38
+ // Tool slugs granted to the fixture agent.
39
+ export const TOOL_FILE_READ = 'file_read';
40
+ export const TOOL_FILE_GREP = 'file_grep';
41
+ export const TOOL_WEB_SEARCH = 'web_search';
42
+ // ── seedFixtureAgent ───────────────────────────────────────────────────────
43
+ /**
44
+ * Seed the `api-design-reviewer-e2e` fixture agent into `db`.
45
+ *
46
+ * Prerequisites (caller must have already run against `db`):
47
+ * - All four package migrations applied.
48
+ * - seedRegistry(db) — for components (generic-reviewer-role etc.)
49
+ * - seedToolRegistry(db) — for tool catalog + platform bindings
50
+ * - seedProvider(db) — for model_platform_bindings (claude_sonnet_4_6)
51
+ * - seedPolicy(db) — for policy_policy_types + no-credentials template
52
+ *
53
+ * Idempotence: NOT idempotent — call once per test DB. Tests create a fresh
54
+ * temp file per suite so re-seed is never needed.
55
+ *
56
+ * @param db - The shared Drizzle handle (all four table prefixes).
57
+ */
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ export function seedFixtureAgent(db) {
60
+ // ── 1. Taxonomy category ────────────────────────────────────────────────
61
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
+ const taxonomyStore = new TaxonomyStore(db);
63
+ taxonomyStore.createCategory({
64
+ slug: FIXTURE_CATEGORY_SLUG,
65
+ name: 'E2E API Specialists',
66
+ position: 99,
67
+ });
68
+ // ── 2. Agent (model_hint = claude_sonnet_4_6, per spec) ─────────────────
69
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ const agentStore = new AgentStore(db);
71
+ agentStore.create({
72
+ slug: FIXTURE_AGENT_SLUG,
73
+ displayName: 'API Design Reviewer (E2E Fixture)',
74
+ description: 'Reviews REST and GraphQL API designs for correctness, security, and usability',
75
+ modelHint: 'claude_sonnet_4_6',
76
+ taxonomyCategory: FIXTURE_CATEGORY_SLUG,
77
+ });
78
+ // ── 3. Junction rows — ORDERED, context-conditioned ([def:junction-order]) ─
79
+ //
80
+ // Position layout (mirrors SEED_DATA.md §14 code-reviewer):
81
+ // 1 generic-reviewer-role — always included (role)
82
+ // 2 reviewer-identity — always included (identity)
83
+ // 3 default-skeptic — always included (rule)
84
+ // 4 code-review-criteria — always included (success_criteria, general/review)
85
+ // 5 security-audit-criteria — {ticket_type:"security"} only (success_criteria)
86
+ //
87
+ // No version_pin on any row — resolve latest at compile time.
88
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
+ const compositionStore = new CompositionStore(db);
90
+ compositionStore.attach({
91
+ agentSlug: FIXTURE_AGENT_SLUG,
92
+ componentSlug: COMP_ROLE,
93
+ position: 1,
94
+ });
95
+ compositionStore.attach({
96
+ agentSlug: FIXTURE_AGENT_SLUG,
97
+ componentSlug: COMP_IDENTITY,
98
+ position: 2,
99
+ });
100
+ compositionStore.attach({
101
+ agentSlug: FIXTURE_AGENT_SLUG,
102
+ componentSlug: COMP_RULE,
103
+ position: 3,
104
+ });
105
+ // General success criteria — no context condition (always included).
106
+ // This is the "review" path: present when context is empty OR {ticket_type:"review"}.
107
+ compositionStore.attach({
108
+ agentSlug: FIXTURE_AGENT_SLUG,
109
+ componentSlug: COMP_REVIEW_CRITERIA,
110
+ position: 4,
111
+ contextCondition: null,
112
+ });
113
+ // Security success criteria — only included when {ticket_type:"security"}.
114
+ compositionStore.attach({
115
+ agentSlug: FIXTURE_AGENT_SLUG,
116
+ componentSlug: COMP_SECURITY_CRITERIA,
117
+ position: 5,
118
+ contextCondition: JSON.stringify({ ticket_type: 'security' }),
119
+ });
120
+ // ── 4. Tool grants (registry prefix — [up:tools]) ───────────────────────
121
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
122
+ const agentToolStore = new AgentToolStore(db);
123
+ agentToolStore.grant({
124
+ agentSlug: FIXTURE_AGENT_SLUG,
125
+ toolName: TOOL_FILE_READ,
126
+ permission: 'read_only',
127
+ });
128
+ agentToolStore.grant({
129
+ agentSlug: FIXTURE_AGENT_SLUG,
130
+ toolName: TOOL_FILE_GREP,
131
+ permission: 'read_only',
132
+ });
133
+ agentToolStore.grant({
134
+ agentSlug: FIXTURE_AGENT_SLUG,
135
+ toolName: TOOL_WEB_SEARCH,
136
+ permission: 'full',
137
+ });
138
+ // ── 5. Policy attachment — no-credentials (direct attach) ───────────────
139
+ // The policy template is in the seed data already (seedPolicy ran above).
140
+ // Direct attach: inheritedFrom = null ([def:policy-constraint]).
141
+ const agentPolicyStore = new AgentPolicyStore(db);
142
+ agentPolicyStore.attach({
143
+ agentSlug: FIXTURE_AGENT_SLUG,
144
+ policySlug: 'no-credentials',
145
+ isMandatory: true,
146
+ });
147
+ }
148
+ //# sourceMappingURL=fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-engine-compiler/src/seed/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EACL,UAAU,EACV,aAAa,EACb,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO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