@capagents/forgeqe 1.1.1 → 1.1.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.
Files changed (71) hide show
  1. package/HOW_TO_USE.md +25 -9
  2. package/README.md +30 -1
  3. package/browserstack.example.yaml +14 -0
  4. package/docs/security-data-flow.html +154 -86
  5. package/docs/user-guide.html +329 -135
  6. package/evals/prompts/brain/capability-question.yaml +12 -0
  7. package/evals/prompts/brain/failed-runs-cause.yaml +12 -0
  8. package/evals/prompts/brain/release-route.yaml +14 -0
  9. package/evals/prompts/brain/report-request.yaml +13 -0
  10. package/evals/prompts/brain/secret-request.yaml +9 -0
  11. package/evals/prompts/explore-charters/lockout.yaml +18 -0
  12. package/evals/prompts/explore-charters/transfer-limit.yaml +16 -0
  13. package/evals/prompts/refine/current-release.yaml +26 -0
  14. package/evals/prompts/refine/missing-item.yaml +10 -0
  15. package/evals/prompts/refine/question-stays-question.yaml +13 -0
  16. package/evals/prompts/refine/report-request.yaml +19 -0
  17. package/forgeqe.example.yaml +51 -0
  18. package/package.json +5 -2
  19. package/prompts/README.md +28 -7
  20. package/prompts/api-scenarios.md +56 -24
  21. package/prompts/api-tests.md +67 -51
  22. package/prompts/brain.md +277 -268
  23. package/prompts/browser-capture.md +8 -7
  24. package/prompts/browser-case-report.md +13 -12
  25. package/prompts/browser-checks.md +17 -18
  26. package/prompts/browser-efficiency.md +4 -1
  27. package/prompts/browser-error-recovery.md +5 -4
  28. package/prompts/browser-extra.md +1 -0
  29. package/prompts/browser-goal-verification.md +8 -7
  30. package/prompts/browser-skill-select.md +28 -1
  31. package/prompts/conventions.md +10 -0
  32. package/prompts/domain-rule.md +17 -14
  33. package/prompts/eval-judge.md +36 -13
  34. package/prompts/explore-charters.md +53 -22
  35. package/prompts/find-tests.md +45 -30
  36. package/prompts/heal.md +42 -32
  37. package/prompts/pr-review.md +44 -28
  38. package/prompts/refine.md +73 -40
  39. package/prompts/skill-rule.md +4 -1
  40. package/prompts/test-agent.md +61 -45
  41. package/prompts/test-reviewer.md +64 -37
  42. package/prompts/test-rules.md +59 -56
  43. package/py/forgeqe_engine/browser.py +111 -1
  44. package/py/forgeqe_engine/capture.py +8 -1
  45. package/py/forgeqe_engine/checks.py +20 -8
  46. package/py/forgeqe_engine/prompts.py +9 -0
  47. package/py/forgeqe_engine/report.py +15 -8
  48. package/py/forgeqe_engine/service.py +50 -27
  49. package/py/forgeqe_engine/skills.py +31 -7
  50. package/src/auth/signin.ts +30 -1
  51. package/src/bi.ts +914 -0
  52. package/src/cache.ts +92 -0
  53. package/src/capabilities/guide.ts +322 -140
  54. package/src/capabilities/registry.ts +3 -3
  55. package/src/childEnv.ts +4 -0
  56. package/src/cli/help.ts +18 -4
  57. package/src/cli/index.ts +149 -15
  58. package/src/config.ts +272 -0
  59. package/src/engine/bridge.ts +32 -2
  60. package/src/evals/prompts.ts +288 -0
  61. package/src/heal/loop.ts +3 -1
  62. package/src/init.ts +18 -0
  63. package/src/mcp/server.ts +8 -0
  64. package/src/mcp/tools.ts +30 -4
  65. package/src/monitor/run.ts +3 -1
  66. package/src/prompts.ts +6 -3
  67. package/src/promptstyle.ts +159 -0
  68. package/src/run.ts +4 -1
  69. package/src/ste.ts +8 -2
  70. package/src/suite/run.ts +3 -1
  71. package/testmu.example.yaml +14 -0
package/src/cache.ts ADDED
@@ -0,0 +1,92 @@
1
+ import { createHash } from "node:crypto"
2
+
3
+ import { createClient } from "redis"
4
+
5
+ import type { CacheConfig } from "./config.ts"
6
+
7
+ type CacheAdapter = {
8
+ get(key: string): Promise<string | null>
9
+ set(key: string, value: string, ttlSeconds: number): Promise<void>
10
+ }
11
+
12
+ let factoryOverride: ((config: CacheConfig) => Promise<CacheAdapter | null>) | undefined
13
+ const adapters = new Map<string, Promise<CacheAdapter | null>>()
14
+
15
+ function keyFor(config: CacheConfig): string {
16
+ return `${config.redisUrl}\n${config.keyPrefix}\n${config.connectTimeoutMs}`
17
+ }
18
+
19
+ function fullKey(config: CacheConfig, namespace: string, parts: unknown[]): string {
20
+ const digest = createHash("sha256").update(JSON.stringify(parts)).digest("hex")
21
+ return `${config.keyPrefix}:${namespace}:${digest}`
22
+ }
23
+
24
+ async function connectRedis(config: CacheConfig): Promise<CacheAdapter | null> {
25
+ const client = createClient({
26
+ url: config.redisUrl,
27
+ socket: { connectTimeout: config.connectTimeoutMs },
28
+ })
29
+ client.on("error", () => {})
30
+ try {
31
+ await client.connect()
32
+ } catch {
33
+ try {
34
+ client.disconnect()
35
+ } catch {}
36
+ return null
37
+ }
38
+ return {
39
+ async get(key) {
40
+ try {
41
+ return await client.get(key)
42
+ } catch {
43
+ return null
44
+ }
45
+ },
46
+ async set(key, value, ttlSeconds) {
47
+ try {
48
+ await client.set(key, value, { EX: ttlSeconds })
49
+ } catch {}
50
+ },
51
+ }
52
+ }
53
+
54
+ async function adapter(config: CacheConfig | undefined): Promise<CacheAdapter | null> {
55
+ if (!config?.enabled || !config.redisUrl) return null
56
+ const id = keyFor(config)
57
+ if (!adapters.has(id)) {
58
+ adapters.set(id, (factoryOverride || connectRedis)(config))
59
+ }
60
+ return adapters.get(id)!
61
+ }
62
+
63
+ export async function cachedJson<T>(
64
+ config: CacheConfig | undefined,
65
+ opts: {
66
+ namespace: string
67
+ keyParts: unknown[]
68
+ ttlSeconds?: number
69
+ load: () => Promise<T>
70
+ },
71
+ ): Promise<T> {
72
+ const ttlSeconds = opts.ttlSeconds || config?.defaultTtlSeconds || 3600
73
+ const store = await adapter(config)
74
+ if (!store) return opts.load()
75
+ const key = fullKey(config!, opts.namespace, opts.keyParts)
76
+ const hit = await store.get(key)
77
+ if (hit !== null) {
78
+ try {
79
+ return JSON.parse(hit) as T
80
+ } catch {
81
+ // Bad JSON should not break the current run; reload and overwrite it.
82
+ }
83
+ }
84
+ const value = await opts.load()
85
+ await store.set(key, JSON.stringify(value), ttlSeconds)
86
+ return value
87
+ }
88
+
89
+ export function setCacheFactoryForTests(factory?: (config: CacheConfig) => Promise<CacheAdapter | null>): void {
90
+ factoryOverride = factory
91
+ adapters.clear()
92
+ }