@jigyasudham/veto 0.8.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 (198) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/README.md +190 -0
  3. package/dist/adapters/claude.js +57 -0
  4. package/dist/adapters/codex.js +58 -0
  5. package/dist/adapters/gemini.js +58 -0
  6. package/dist/adapters/index.js +156 -0
  7. package/dist/agents/development/api.js +116 -0
  8. package/dist/agents/development/backend.js +82 -0
  9. package/dist/agents/development/coder.js +207 -0
  10. package/dist/agents/development/database.js +81 -0
  11. package/dist/agents/development/debugger.js +234 -0
  12. package/dist/agents/development/devops.js +84 -0
  13. package/dist/agents/development/frontend.js +83 -0
  14. package/dist/agents/development/migration.js +141 -0
  15. package/dist/agents/development/performance.js +142 -0
  16. package/dist/agents/development/refactor.js +85 -0
  17. package/dist/agents/development/reviewer.js +260 -0
  18. package/dist/agents/development/tester.js +143 -0
  19. package/dist/agents/executor.js +144 -0
  20. package/dist/agents/memory/context-manager.js +167 -0
  21. package/dist/agents/memory/decision-logger.js +157 -0
  22. package/dist/agents/memory/knowledge-base.js +120 -0
  23. package/dist/agents/memory/pattern-learner.js +140 -0
  24. package/dist/agents/memory/project-mapper.js +114 -0
  25. package/dist/agents/quality/accessibility.js +89 -0
  26. package/dist/agents/quality/code-quality.js +109 -0
  27. package/dist/agents/quality/compatibility.js +55 -0
  28. package/dist/agents/quality/documentation.js +95 -0
  29. package/dist/agents/quality/error-handling.js +87 -0
  30. package/dist/agents/research/competitor-analyzer.js +44 -0
  31. package/dist/agents/research/cost-analyzer.js +51 -0
  32. package/dist/agents/research/estimator.js +57 -0
  33. package/dist/agents/research/ethics-bias.js +111 -0
  34. package/dist/agents/research/researcher.js +112 -0
  35. package/dist/agents/research/risk-assessor.js +61 -0
  36. package/dist/agents/research/tech-advisor.js +52 -0
  37. package/dist/agents/security/auth.js +269 -0
  38. package/dist/agents/security/dependency-audit.js +273 -0
  39. package/dist/agents/security/penetration.js +245 -0
  40. package/dist/agents/security/privacy.js +259 -0
  41. package/dist/agents/security/scanner.js +288 -0
  42. package/dist/agents/security/secrets.js +212 -0
  43. package/dist/agents/types.js +2 -0
  44. package/dist/agents/workflow/automation.js +56 -0
  45. package/dist/agents/workflow/file-manager.js +49 -0
  46. package/dist/agents/workflow/git-agent.js +52 -0
  47. package/dist/agents/workflow/reporter.js +48 -0
  48. package/dist/agents/workflow/search-agent.js +39 -0
  49. package/dist/agents/workflow/task-coordinator.js +40 -0
  50. package/dist/agents/workflow/task-planner.js +46 -0
  51. package/dist/cli.js +132 -0
  52. package/dist/council/decision-engine.js +136 -0
  53. package/dist/council/devil-advocate.js +106 -0
  54. package/dist/council/index.js +37 -0
  55. package/dist/council/lead-developer.js +108 -0
  56. package/dist/council/legal-compliance.js +142 -0
  57. package/dist/council/product-manager.js +92 -0
  58. package/dist/council/security.js +162 -0
  59. package/dist/council/system-architect.js +122 -0
  60. package/dist/council/types.js +2 -0
  61. package/dist/council/ux-designer.js +109 -0
  62. package/dist/memory/local.js +182 -0
  63. package/dist/memory/schema.js +116 -0
  64. package/dist/memory/sync.js +199 -0
  65. package/dist/router/complexity-scorer.js +78 -0
  66. package/dist/router/context-compressor.js +58 -0
  67. package/dist/router/index.js +29 -0
  68. package/dist/router/learning-updater.js +186 -0
  69. package/dist/router/model-selector.js +51 -0
  70. package/dist/router/rate-monitor.js +73 -0
  71. package/dist/server.js +949 -0
  72. package/dist/skills/development/skill-api-design.js +313 -0
  73. package/dist/skills/development/skill-auth.js +255 -0
  74. package/dist/skills/development/skill-ci-cd.js +2 -0
  75. package/dist/skills/development/skill-crud.js +193 -0
  76. package/dist/skills/development/skill-db-schema.js +2 -0
  77. package/dist/skills/development/skill-docker.js +2 -0
  78. package/dist/skills/development/skill-env-setup.js +2 -0
  79. package/dist/skills/development/skill-scaffold.js +299 -0
  80. package/dist/skills/intelligence/skill-complexity-score.js +66 -0
  81. package/dist/skills/intelligence/skill-cost-track.js +36 -0
  82. package/dist/skills/intelligence/skill-learning-loop.js +66 -0
  83. package/dist/skills/intelligence/skill-pattern-detect.js +35 -0
  84. package/dist/skills/intelligence/skill-rate-watch.js +58 -0
  85. package/dist/skills/memory/skill-context-compress.js +82 -0
  86. package/dist/skills/memory/skill-cross-sync.js +88 -0
  87. package/dist/skills/memory/skill-decision-log.js +103 -0
  88. package/dist/skills/memory/skill-session-restore.js +44 -0
  89. package/dist/skills/memory/skill-session-save.js +78 -0
  90. package/dist/skills/quality/skill-accessibility.js +2 -0
  91. package/dist/skills/quality/skill-code-review.js +60 -0
  92. package/dist/skills/quality/skill-docs-gen.js +2 -0
  93. package/dist/skills/quality/skill-perf-audit.js +2 -0
  94. package/dist/skills/quality/skill-security-scan.js +67 -0
  95. package/dist/skills/quality/skill-test-suite.js +274 -0
  96. package/dist/skills/workflow/skill-deploy.js +2 -0
  97. package/dist/skills/workflow/skill-git-workflow.js +2 -0
  98. package/dist/skills/workflow/skill-rollback.js +2 -0
  99. package/dist/skills/workflow/skill-task-breakdown.js +2 -0
  100. package/package.json +30 -0
  101. package/src/adapters/claude.ts +70 -0
  102. package/src/adapters/codex.ts +71 -0
  103. package/src/adapters/gemini.ts +71 -0
  104. package/src/adapters/index.ts +217 -0
  105. package/src/agents/development/api.ts +120 -0
  106. package/src/agents/development/backend.ts +85 -0
  107. package/src/agents/development/coder.ts +213 -0
  108. package/src/agents/development/database.ts +83 -0
  109. package/src/agents/development/debugger.ts +238 -0
  110. package/src/agents/development/devops.ts +86 -0
  111. package/src/agents/development/frontend.ts +85 -0
  112. package/src/agents/development/migration.ts +144 -0
  113. package/src/agents/development/performance.ts +144 -0
  114. package/src/agents/development/refactor.ts +86 -0
  115. package/src/agents/development/reviewer.ts +268 -0
  116. package/src/agents/development/tester.ts +151 -0
  117. package/src/agents/executor.ts +158 -0
  118. package/src/agents/memory/context-manager.ts +171 -0
  119. package/src/agents/memory/decision-logger.ts +160 -0
  120. package/src/agents/memory/knowledge-base.ts +124 -0
  121. package/src/agents/memory/pattern-learner.ts +143 -0
  122. package/src/agents/memory/project-mapper.ts +118 -0
  123. package/src/agents/quality/accessibility.ts +99 -0
  124. package/src/agents/quality/code-quality.ts +115 -0
  125. package/src/agents/quality/compatibility.ts +58 -0
  126. package/src/agents/quality/documentation.ts +105 -0
  127. package/src/agents/quality/error-handling.ts +96 -0
  128. package/src/agents/research/competitor-analyzer.ts +45 -0
  129. package/src/agents/research/cost-analyzer.ts +54 -0
  130. package/src/agents/research/estimator.ts +60 -0
  131. package/src/agents/research/ethics-bias.ts +113 -0
  132. package/src/agents/research/researcher.ts +114 -0
  133. package/src/agents/research/risk-assessor.ts +63 -0
  134. package/src/agents/research/tech-advisor.ts +55 -0
  135. package/src/agents/security/auth.ts +287 -0
  136. package/src/agents/security/dependency-audit.ts +337 -0
  137. package/src/agents/security/penetration.ts +262 -0
  138. package/src/agents/security/privacy.ts +285 -0
  139. package/src/agents/security/scanner.ts +322 -0
  140. package/src/agents/security/secrets.ts +249 -0
  141. package/src/agents/types.ts +66 -0
  142. package/src/agents/workflow/automation.ts +59 -0
  143. package/src/agents/workflow/file-manager.ts +52 -0
  144. package/src/agents/workflow/git-agent.ts +55 -0
  145. package/src/agents/workflow/reporter.ts +51 -0
  146. package/src/agents/workflow/search-agent.ts +40 -0
  147. package/src/agents/workflow/task-coordinator.ts +41 -0
  148. package/src/agents/workflow/task-planner.ts +47 -0
  149. package/src/cli.ts +143 -0
  150. package/src/council/decision-engine.ts +171 -0
  151. package/src/council/devil-advocate.ts +116 -0
  152. package/src/council/index.ts +44 -0
  153. package/src/council/lead-developer.ts +118 -0
  154. package/src/council/legal-compliance.ts +152 -0
  155. package/src/council/product-manager.ts +102 -0
  156. package/src/council/security.ts +172 -0
  157. package/src/council/system-architect.ts +132 -0
  158. package/src/council/types.ts +33 -0
  159. package/src/council/ux-designer.ts +121 -0
  160. package/src/memory/local.ts +305 -0
  161. package/src/memory/schema.ts +174 -0
  162. package/src/memory/sync.ts +274 -0
  163. package/src/router/complexity-scorer.ts +96 -0
  164. package/src/router/context-compressor.ts +74 -0
  165. package/src/router/index.ts +60 -0
  166. package/src/router/learning-updater.ts +271 -0
  167. package/src/router/model-selector.ts +83 -0
  168. package/src/router/rate-monitor.ts +103 -0
  169. package/src/server.ts +1038 -0
  170. package/src/skills/development/skill-api-design.ts +329 -0
  171. package/src/skills/development/skill-auth.ts +271 -0
  172. package/src/skills/development/skill-ci-cd.ts +0 -0
  173. package/src/skills/development/skill-crud.ts +209 -0
  174. package/src/skills/development/skill-db-schema.ts +0 -0
  175. package/src/skills/development/skill-docker.ts +0 -0
  176. package/src/skills/development/skill-env-setup.ts +0 -0
  177. package/src/skills/development/skill-scaffold.ts +323 -0
  178. package/src/skills/intelligence/skill-complexity-score.ts +69 -0
  179. package/src/skills/intelligence/skill-cost-track.ts +39 -0
  180. package/src/skills/intelligence/skill-learning-loop.ts +69 -0
  181. package/src/skills/intelligence/skill-pattern-detect.ts +38 -0
  182. package/src/skills/intelligence/skill-rate-watch.ts +61 -0
  183. package/src/skills/memory/skill-context-compress.ts +98 -0
  184. package/src/skills/memory/skill-cross-sync.ts +104 -0
  185. package/src/skills/memory/skill-decision-log.ts +119 -0
  186. package/src/skills/memory/skill-session-restore.ts +59 -0
  187. package/src/skills/memory/skill-session-save.ts +94 -0
  188. package/src/skills/quality/skill-accessibility.ts +0 -0
  189. package/src/skills/quality/skill-code-review.ts +84 -0
  190. package/src/skills/quality/skill-docs-gen.ts +0 -0
  191. package/src/skills/quality/skill-perf-audit.ts +0 -0
  192. package/src/skills/quality/skill-security-scan.ts +91 -0
  193. package/src/skills/quality/skill-test-suite.ts +290 -0
  194. package/src/skills/workflow/skill-deploy.ts +0 -0
  195. package/src/skills/workflow/skill-git-workflow.ts +0 -0
  196. package/src/skills/workflow/skill-rollback.ts +0 -0
  197. package/src/skills/workflow/skill-task-breakdown.ts +0 -0
  198. package/tsconfig.json +20 -0
@@ -0,0 +1,167 @@
1
+ function detectCategory(task) {
2
+ const t = task.toLowerCase();
3
+ if (t.includes('start') || t.includes('begin') || t.includes('new session') || t.includes('initialize'))
4
+ return 'session-start';
5
+ if (t.includes('compress') || t.includes('trim') || t.includes('reduce') || t.includes('shrink') || t.includes('token'))
6
+ return 'compression';
7
+ if (t.includes('switch') || t.includes('handoff') || t.includes('transfer') || t.includes('gemini') || t.includes('codex'))
8
+ return 'context-switch';
9
+ if (t.includes('mid') || t.includes('checkpoint') || t.includes('save') || t.includes('continue'))
10
+ return 'mid-task';
11
+ return 'general';
12
+ }
13
+ const categoryApproach = {
14
+ 'session-start': 'Load prior session via veto_session_restore. Identify the active project, last completed task, and immediate next action. Build a compact working context — goals, constraints, key files, recent decisions. Discard old context that no longer applies.',
15
+ 'mid-task': 'Snapshot current progress to context: completed subtasks, in-progress work, emerging blockers. Trim historical conversation that is no longer load-bearing. Keep all active decisions and constraints live. Evaluate whether token budget warrants a save-and-compress cycle.',
16
+ 'context-switch': 'Serialize current context to a portable session snapshot. Include task state, file manifest, active decisions, and next action. Write to veto_session_save. Confirm the receiving platform can restore and resume without re-reading source files.',
17
+ 'compression': 'Identify context tiers: critical (keep verbatim), summarisable (compress to 1–3 sentences), droppable (no longer relevant). Apply the router\'s context-compressor module. Target < 30% of original token count while preserving all active constraints and decisions.',
18
+ 'general': 'Audit the current context window for relevance. Remove completed subtasks, resolved blockers, and superseded decisions. Elevate forward-looking content — pending work, live constraints, open questions. Summarise historical content to 1–2 sentences per topic.',
19
+ };
20
+ const categorySteps = {
21
+ 'session-start': [
22
+ 'Call veto_sessions_list to find the most recent session for this project directory',
23
+ 'Call veto_session_restore with the session ID to load prior context',
24
+ 'Parse the restored task_state to identify completed, in-progress, and remaining work',
25
+ 'Call veto_memory_search with the project_dir to load relevant knowledge base entries',
26
+ 'Call veto_project_map_get to load the current codebase structure',
27
+ 'Synthesise a compact active-context object: goals, constraints, key files, decisions',
28
+ 'Identify the single most important next action and make it the session focus',
29
+ 'Discard any context older than the last significant decision or file change',
30
+ ],
31
+ 'mid-task': [
32
+ 'List what has been completed since the last save',
33
+ 'Identify what is currently in progress and what is blocked',
34
+ 'Score each context item: critical | summarisable | droppable',
35
+ 'Draft a compressed context string using summarisable items',
36
+ 'Trigger a session save if token count exceeds 8,000 or a subtask just completed',
37
+ 'Record any new decisions or discoveries to veto_memory_store',
38
+ 'Update the project map if new files were created or deleted',
39
+ 'Verify the next action is concrete and unambiguous',
40
+ ],
41
+ 'context-switch': [
42
+ 'Freeze the current session: write final progress state',
43
+ 'Call veto_session_save with full task_state including phase, progress, decisions',
44
+ 'Note the session ID — give it to the human to paste into the receiving platform',
45
+ 'Confirm the session summary is self-contained (receiving agent needs no prior context)',
46
+ 'Include the file manifest for files that were read or modified this session',
47
+ 'Include the single next action as the last line of the context',
48
+ 'Verify the save by calling veto_sessions_list and inspecting the new row',
49
+ ],
50
+ 'compression': [
51
+ 'Count current context tokens using the router\'s compressor estimate',
52
+ 'Identify the compression target: what percentage reduction is needed?',
53
+ 'Categorise each context block: verbatim | summarise | drop',
54
+ 'Keep all active constraints, open blockers, and pending tasks verbatim',
55
+ 'Summarise historical completed work to one sentence per subtask',
56
+ 'Drop resolved blockers, superseded decisions, and read-back confirmations',
57
+ 'Verify compressed context passes a completeness check: can the task still be continued?',
58
+ 'Save the compressed state as a new session checkpoint',
59
+ ],
60
+ 'general': [
61
+ 'Audit the context for items that are no longer relevant to the current task phase',
62
+ 'Identify decisions that have been superseded and mark them deprecated',
63
+ 'Summarise completed subtask history into single-sentence progress notes',
64
+ 'Elevate forward-looking items to the top of the active context',
65
+ 'Ensure all active file paths and module names are accurate (not stale)',
66
+ 'Record new patterns or solutions to the knowledge base',
67
+ 'Save the refined context as a session checkpoint',
68
+ ],
69
+ };
70
+ const categoryChecklist = {
71
+ 'session-start': [
72
+ '[ ] Prior session restored via veto_session_restore',
73
+ '[ ] Task phase identified: planning | implementing | reviewing | blocked',
74
+ '[ ] Completed subtasks listed — no re-doing finished work',
75
+ '[ ] Remaining subtasks listed in priority order',
76
+ '[ ] All active file paths verified to exist',
77
+ '[ ] Active constraints and decisions loaded from session',
78
+ '[ ] Knowledge base queried for relevant prior solutions',
79
+ '[ ] Project map loaded — key modules and entry points known',
80
+ '[ ] Next action is a single concrete step, not a vague direction',
81
+ ],
82
+ 'mid-task': [
83
+ '[ ] Progress snapshot written: completed, in-progress, remaining',
84
+ '[ ] New decisions or discoveries logged to knowledge base',
85
+ '[ ] Stale context removed — no completed blockers still listed as active',
86
+ '[ ] Session saved if checkpoint warranted (> 8k tokens or subtask complete)',
87
+ '[ ] Project map updated if files were added or removed',
88
+ '[ ] Next action re-confirmed: single concrete step',
89
+ ],
90
+ 'context-switch': [
91
+ '[ ] Session saved with full task_state before switching platforms',
92
+ '[ ] Session ID recorded and ready to give to receiving platform',
93
+ '[ ] Summary is self-contained — receiving agent needs no prior context',
94
+ '[ ] File manifest included in session save',
95
+ '[ ] Next action is the final line of the context',
96
+ '[ ] Receiving platform tested with veto_session_restore before committing to switch',
97
+ ],
98
+ 'compression': [
99
+ '[ ] Original token count measured before compression',
100
+ '[ ] Compression target set (aim for < 30% of original)',
101
+ '[ ] All active constraints preserved verbatim',
102
+ '[ ] Completed work compressed to one sentence per subtask',
103
+ '[ ] No active blockers or decisions removed',
104
+ '[ ] Compressed context passes completeness check',
105
+ '[ ] Compressed state saved as new session checkpoint',
106
+ ],
107
+ 'general': [
108
+ '[ ] Context audit completed — stale items removed',
109
+ '[ ] All file paths verified to be current',
110
+ '[ ] Decisions table up to date — no deprecated decisions still marked accepted',
111
+ '[ ] Knowledge base updated with new findings',
112
+ '[ ] Session saved with current state',
113
+ '[ ] Next action is concrete and prioritised',
114
+ ],
115
+ };
116
+ const categoryPitfalls = {
117
+ 'session-start': [
118
+ 'Starting work before restoring prior session — redoing completed subtasks',
119
+ 'Loading the session but ignoring the task_state — treating the session as read-only',
120
+ 'Not checking the project map — assuming file structure from memory instead of current state',
121
+ 'Taking the next action from the prior session without checking if it is still valid',
122
+ ],
123
+ 'mid-task': [
124
+ 'Waiting until 50k tokens to compress — forces an emergency compression that risks losing context',
125
+ 'Saving a session without a nextAction — the restoring agent starts from scratch',
126
+ 'Not recording decisions to the knowledge base — the same decision gets relitigated next session',
127
+ 'Updating the project map only on session end — missing interim file creates/deletes',
128
+ ],
129
+ 'context-switch': [
130
+ 'Switching platforms without calling veto_session_save first — all progress lost',
131
+ 'Including raw file contents in the session save instead of file paths — balloons token cost',
132
+ 'Not testing restore on the receiving platform before committing to the switch',
133
+ 'Switching while a destructive operation (migration, deploy) is in progress',
134
+ ],
135
+ 'compression': [
136
+ 'Compressing active constraints as if they were completed work — causes silent constraint violations',
137
+ 'Over-compressing: removing the rationale for active decisions — future agent reverses them',
138
+ 'Not saving the compressed context — compression is lost at next context switch',
139
+ 'Targeting a fixed token number without checking completeness — may cut load-bearing context',
140
+ ],
141
+ 'general': [
142
+ 'Context drift: the active context describes a different version of the task than the current one',
143
+ 'Stale file paths in context that no longer exist in the project',
144
+ 'Decisions still listed as "proposed" that have already been implemented',
145
+ 'Context growing monotonically without pruning — each session inherits all prior context',
146
+ ],
147
+ };
148
+ export function plan(task, context) {
149
+ const category = detectCategory(task + ' ' + (context ?? ''));
150
+ return {
151
+ agent: 'context-manager',
152
+ task,
153
+ tier: 1,
154
+ approach: categoryApproach[category],
155
+ steps: categorySteps[category],
156
+ checklist: categoryChecklist[category],
157
+ pitfalls: categoryPitfalls[category],
158
+ patterns: [
159
+ 'Checkpoint pattern: save context at phase boundaries, not only at session end',
160
+ 'Minimal viable context: enough to resume work, not a full transcript',
161
+ 'Tiered retention: verbatim | summarised | dropped — never binary keep/delete',
162
+ 'Forward-first ordering: next actions at the top, completed history at the bottom',
163
+ ],
164
+ duration_estimate: '5-15 minutes',
165
+ };
166
+ }
167
+ //# sourceMappingURL=context-manager.js.map
@@ -0,0 +1,157 @@
1
+ function detectCategory(task) {
2
+ const t = task.toLowerCase();
3
+ if (t.includes('architect') || t.includes('design') || t.includes('structure') || t.includes('pattern') || t.includes('framework'))
4
+ return 'architecture';
5
+ if (t.includes('auth') || t.includes('security') || t.includes('encrypt') || t.includes('permission') || t.includes('token'))
6
+ return 'security';
7
+ if (t.includes('schema') || t.includes('database') || t.includes('migration') || t.includes('model') || t.includes('table'))
8
+ return 'data';
9
+ if (t.includes('api') || t.includes('endpoint') || t.includes('contract') || t.includes('version') || t.includes('rest') || t.includes('graphql'))
10
+ return 'api';
11
+ return 'general';
12
+ }
13
+ const categoryApproach = {
14
+ 'architecture': 'Document the architectural decision as an ADR. Capture context (what forces are in play), the decision made, full rationale, rejected alternatives with reasons, and positive/negative consequences. Store in veto_memory_store with type="decision". Link from code comments using the ADR ID.',
15
+ 'security': 'Log the security decision with threat model context. State the attack surface being protected, the chosen control, why alternatives were rejected (too weak, too complex, operational burden), and any residual risk accepted. Tag with "security" for fast retrieval during reviews.',
16
+ 'data': 'Record the data schema decision with migration path. Document the constraints that drove the schema choice (access patterns, cardinality, denormalisation trade-offs). Include the rollback plan if the decision proves wrong. Tag with "schema" and affected table names.',
17
+ 'api': 'Log the API contract decision including versioning strategy. Capture backward-compatibility commitments, breaking-change triggers, and the client impact. Once an API contract is published, record it as immutable unless a version bump is logged.',
18
+ 'general': 'Use the ADR format: context → decision → rationale → alternatives → consequences. Log to veto_memory_store (type="decision") and the local decisions table. Reference the ADR ID in code comments near the implementation.',
19
+ };
20
+ const categorySteps = {
21
+ 'architecture': [
22
+ 'Assign a sequential ADR ID (ADR-001, ADR-002, …)',
23
+ 'Write the context: what forces, constraints, or requirements make this choice necessary?',
24
+ 'State the decision in one unambiguous sentence',
25
+ 'Document the rationale: why this option over alternatives?',
26
+ 'List at least two alternatives that were genuinely considered',
27
+ 'For each alternative: pros, cons, and the specific reason it was rejected',
28
+ 'Document positive consequences: what does this decision enable?',
29
+ 'Document negative consequences: what technical debt or constraints does it introduce?',
30
+ 'Set status: proposed | accepted | deprecated | superseded-by:ADR-xxx',
31
+ 'Add file references to the implementation',
32
+ 'Call veto_memory_store with type="decision", title=ADR ID, tags=["architecture"]',
33
+ 'Add // See ADR-001 comment near the implementation',
34
+ ],
35
+ 'security': [
36
+ 'Describe the threat being mitigated (attack vector, affected asset, likelihood)',
37
+ 'State the chosen security control in one sentence',
38
+ 'Document why weaker alternatives were rejected (OWASP reference where applicable)',
39
+ 'Document why stronger alternatives were not chosen (operational burden, complexity, cost)',
40
+ 'Quantify residual risk: what attack surface remains after this control?',
41
+ 'Reference relevant standards: OWASP, NIST, RFC',
42
+ 'Set a review date — security decisions should be re-evaluated annually',
43
+ 'Call veto_memory_store with type="decision", tags=["security", threat category]',
44
+ 'Add SECURITY-DECISION comment near the implementation with a reference link',
45
+ ],
46
+ 'data': [
47
+ 'Describe the access patterns this schema must support',
48
+ 'State the chosen schema structure (table names, key columns, relationships)',
49
+ 'Document denormalisation choices: what query performance trade-off justifies them?',
50
+ 'Document normalisation choices: what integrity benefit justifies the join cost?',
51
+ 'Write the migration plan: how to move existing data to the new schema?',
52
+ 'Write the rollback plan: how to revert if the schema proves wrong?',
53
+ 'Note index strategy: which columns need indexes and why?',
54
+ 'Call veto_memory_store with type="decision", tags=["schema", table name]',
55
+ 'Record the decision_id in the migration file comment',
56
+ ],
57
+ 'api': [
58
+ 'Define the API contract: method, path, request shape, response shape',
59
+ 'State the versioning strategy: URL path (/v1/), header, or content negotiation',
60
+ 'Document backward-compatibility commitments for this version',
61
+ 'List fields that must never be removed or renamed without a version bump',
62
+ 'Define breaking-change criteria: what requires a new major version?',
63
+ 'Document deprecation timeline if replacing an existing endpoint',
64
+ 'Reference the OpenAPI spec file path',
65
+ 'Call veto_memory_store with type="decision", tags=["api-contract", endpoint path]',
66
+ 'Add OpenAPI operation ID that matches the decision ID for traceability',
67
+ ],
68
+ 'general': [
69
+ 'Assign an ADR ID if this is a durable architectural decision',
70
+ 'Write the context: what problem or constraint is being addressed?',
71
+ 'State the decision clearly in one sentence',
72
+ 'Document the rationale with at least two sentences of "why"',
73
+ 'List alternatives that were considered and rejected',
74
+ 'Identify the primary consequence: what does this decision make easier and harder?',
75
+ 'Call veto_memory_store with type="decision", title, and relevant tags',
76
+ 'If the decision affects code, add a reference comment near the implementation',
77
+ 'Set a review trigger: what event should prompt re-evaluating this decision?',
78
+ ],
79
+ };
80
+ const categoryChecklist = {
81
+ 'architecture': [
82
+ '[ ] ADR ID assigned sequentially',
83
+ '[ ] Context section explains forces in play, not just the problem statement',
84
+ '[ ] Decision stated in one clear sentence',
85
+ '[ ] Rationale answers "why this over alternatives"',
86
+ '[ ] At least two alternatives documented with rejection reason',
87
+ '[ ] Positive consequences listed',
88
+ '[ ] Negative consequences / technical debt acknowledged',
89
+ '[ ] Status set to "accepted"',
90
+ '[ ] Stored in veto_memory_store with type="decision"',
91
+ '[ ] Code comment added: // See ADR-xxx',
92
+ ],
93
+ 'security': [
94
+ '[ ] Threat clearly described: vector, asset, likelihood',
95
+ '[ ] Chosen control stated',
96
+ '[ ] Weaker alternatives rejected with reason',
97
+ '[ ] Residual risk quantified',
98
+ '[ ] OWASP or NIST reference included where applicable',
99
+ '[ ] Review date set',
100
+ '[ ] Stored with tags=["security"]',
101
+ ],
102
+ 'data': [
103
+ '[ ] Access patterns documented before schema choice',
104
+ '[ ] Schema decision stated with table/column names',
105
+ '[ ] Migration plan included',
106
+ '[ ] Rollback plan included',
107
+ '[ ] Index strategy documented',
108
+ '[ ] Stored with tags=["schema", table name]',
109
+ '[ ] Migration file references the decision ID',
110
+ ],
111
+ 'api': [
112
+ '[ ] Endpoint contract fully specified',
113
+ '[ ] Versioning strategy stated',
114
+ '[ ] Backward-compatibility commitments listed',
115
+ '[ ] Breaking-change criteria defined',
116
+ '[ ] Deprecation plan if replacing existing endpoint',
117
+ '[ ] OpenAPI spec path referenced',
118
+ '[ ] Stored with tags=["api-contract"]',
119
+ ],
120
+ 'general': [
121
+ '[ ] Decision stated in one clear sentence',
122
+ '[ ] Rationale documented',
123
+ '[ ] Alternatives listed with rejection reasons',
124
+ '[ ] Primary consequence identified',
125
+ '[ ] Stored in veto_memory_store',
126
+ '[ ] Code comment added if decision affects implementation',
127
+ '[ ] Review trigger identified',
128
+ ],
129
+ };
130
+ export function plan(task, context) {
131
+ const category = detectCategory(task + ' ' + (context ?? ''));
132
+ return {
133
+ agent: 'decision-logger',
134
+ task,
135
+ tier: 1,
136
+ approach: categoryApproach[category],
137
+ steps: categorySteps[category],
138
+ checklist: categoryChecklist[category],
139
+ pitfalls: [
140
+ 'Logging the decision after the fact with hindsight bias — capture original thinking at decision time',
141
+ 'Writing the "what" without the "why" — future engineers see the choice but not the reasoning',
142
+ 'Only logging the chosen option without alternatives — looks like no deliberation happened',
143
+ 'Forgetting to update the status when a decision is superseded — stale "accepted" entries cause confusion',
144
+ 'Using vague titles like "Auth decision" instead of "Use JWT with rotating refresh tokens"',
145
+ 'Not linking the ADR from the implementation — the decision and code drift apart',
146
+ 'Logging trivial decisions (variable names) — reserve the log for non-obvious, hard-to-reverse choices',
147
+ ],
148
+ patterns: [
149
+ 'ADR (Architecture Decision Record): context → decision → rationale → alternatives → consequences',
150
+ 'Decision-in-context: co-locate decision reference with implementation via code comments',
151
+ 'Living document: update status (deprecated / superseded-by) rather than deleting entries',
152
+ 'Decision chain: reference prior ADRs that this decision builds on or overrides',
153
+ ],
154
+ duration_estimate: '15-30 minutes',
155
+ };
156
+ }
157
+ //# sourceMappingURL=decision-logger.js.map
@@ -0,0 +1,120 @@
1
+ function detectCategory(task) {
2
+ const t = task.toLowerCase();
3
+ if (t.includes('store') || t.includes('save') || t.includes('record') || t.includes('add to') || t.includes('log solution'))
4
+ return 'store-solution';
5
+ if (t.includes('find') || t.includes('search') || t.includes('retrieve') || t.includes('look up') || t.includes('query'))
6
+ return 'search';
7
+ if (t.includes('dedup') || t.includes('duplicate') || t.includes('clean') || t.includes('merge'))
8
+ return 'dedup';
9
+ return 'general';
10
+ }
11
+ const categoryApproach = {
12
+ 'store-solution': 'Before storing, check for a similar existing entry via veto_memory_search to avoid duplicates. If found, update the existing entry. If new, store via veto_memory_store with a precise title, type classification (solution/pattern/error/reference), relevant tags, and the project_dir for scoped retrieval. A good knowledge entry is self-contained: a future agent should understand and apply it without the original context.',
13
+ 'search': 'Query the knowledge base via veto_memory_search before starting any task. Use type filters and tags to narrow results. Combine a keyword query with the project_dir filter for project-scoped results. Search for prior errors before debugging — the same error may already be solved. Search for patterns before writing code — the established style may already be documented.',
14
+ 'dedup': 'Search for entries with similar titles using multiple keyword variants. Group semantically similar entries. Merge by: keeping the entry with higher relevance, combining the content, and deleting the duplicate. Update the merged entry\'s tags to include all tags from both entries.',
15
+ 'general': 'Check the knowledge base at the start of every task (veto_memory_search). Store new solutions, discovered patterns, and resolved errors after every task. Keep entries self-contained and searchable. Prune stale entries that no longer apply to the current codebase version.',
16
+ };
17
+ const categorySteps = {
18
+ 'store-solution': [
19
+ 'Identify what type this entry is: solution | pattern | error | reference | decision | context',
20
+ 'Write a precise, searchable title (not "Fixed the bug" — use "Fix: Node 22 sqlite binding fails on Windows without --experimental-sqlite flag")',
21
+ 'Write content that is self-contained: problem statement → root cause → solution steps → outcome',
22
+ 'Choose 3–5 tags that describe the topic, technology, and error category',
23
+ 'Set project_dir if this is project-specific knowledge (not general programming knowledge)',
24
+ 'Search veto_memory_search for similar entries before storing',
25
+ 'If a similar entry exists: update it, do not create a duplicate',
26
+ 'If new: call veto_memory_store with all fields populated',
27
+ 'Confirm storage by searching for the entry by title',
28
+ ],
29
+ 'search': [
30
+ 'Identify the key terms of what you are searching for',
31
+ 'Call veto_memory_search with query=key terms, type filter if known',
32
+ 'If results are empty: try synonyms or broader terms',
33
+ 'Add project_dir filter for project-specific knowledge',
34
+ 'Read the top 3 results — check relevance and recency',
35
+ 'If an old result has been superseded by a newer approach, mark the old entry for deletion',
36
+ 'Apply the found solution or pattern directly if the context matches',
37
+ 'If the context is different from the stored entry, adapt the solution and update the entry with the new context',
38
+ ],
39
+ 'dedup': [
40
+ 'Search for entries with the same title or very similar titles',
41
+ 'Search for entries with the same tags to find topic overlap',
42
+ 'Group semantically similar entries',
43
+ 'For each duplicate group: identify the most complete and accurate entry to keep',
44
+ 'Merge content: combine unique information from all entries into the survivor',
45
+ 'Merge tags: union of all tags across the group',
46
+ 'Set the survivor\'s relevance to the maximum of the group',
47
+ 'Delete duplicate entries via veto_memory_search (note IDs) + internal delete',
48
+ 'Confirm dedup by re-running the search — only one entry should appear per topic',
49
+ ],
50
+ 'general': [
51
+ 'At session start: call veto_memory_search with the current task description',
52
+ 'Review results for prior solutions, patterns, or errors that apply to this task',
53
+ 'During the task: note any new solutions, patterns, or errors discovered',
54
+ 'At session end: store all new knowledge via veto_memory_store',
55
+ 'Check for duplicates before each store',
56
+ 'Periodically review low-relevance entries and delete stale ones',
57
+ 'Keep the knowledge base scoped: use project_dir for project-specific entries',
58
+ ],
59
+ };
60
+ const categoryChecklist = {
61
+ 'store-solution': [
62
+ '[ ] Type classification chosen: solution | pattern | error | reference | decision | context',
63
+ '[ ] Title is precise and searchable — not vague',
64
+ '[ ] Content is self-contained (problem → root cause → solution)',
65
+ '[ ] At least 3 tags chosen',
66
+ '[ ] project_dir set if project-specific',
67
+ '[ ] Duplicate search performed before storing',
68
+ '[ ] Entry confirmed via follow-up search',
69
+ ],
70
+ 'search': [
71
+ '[ ] Knowledge base queried before starting the task',
72
+ '[ ] Synonyms tried if initial query returns empty results',
73
+ '[ ] Top 3 results evaluated for relevance',
74
+ '[ ] Stale results flagged for deletion',
75
+ '[ ] Found solution adapted to current context if needed',
76
+ ],
77
+ 'dedup': [
78
+ '[ ] Title-based and tag-based search performed',
79
+ '[ ] Duplicate groups identified',
80
+ '[ ] Best entry per group selected',
81
+ '[ ] Content merged',
82
+ '[ ] Tags merged',
83
+ '[ ] Duplicates deleted',
84
+ '[ ] Dedup confirmed by re-search',
85
+ ],
86
+ 'general': [
87
+ '[ ] Knowledge base searched at session start',
88
+ '[ ] New knowledge stored at session end',
89
+ '[ ] No duplicates created',
90
+ '[ ] Stale entries reviewed',
91
+ ],
92
+ };
93
+ export function plan(task, context) {
94
+ const category = detectCategory(task + ' ' + (context ?? ''));
95
+ return {
96
+ agent: 'knowledge-base',
97
+ task,
98
+ tier: 1,
99
+ approach: categoryApproach[category],
100
+ steps: categorySteps[category],
101
+ checklist: categoryChecklist[category],
102
+ pitfalls: [
103
+ 'Storing entries with vague titles — "Fixed bug" is not searchable; "Fix: X fails when Y" is',
104
+ 'Creating duplicate entries — always search before storing',
105
+ 'Storing entries without tags — makes retrieval rely entirely on full-text search',
106
+ 'Storing project-specific knowledge without project_dir — it bleeds into unrelated projects',
107
+ 'Not searching the knowledge base before starting a task — solving the same problem twice',
108
+ 'Keeping stale entries after the codebase has moved on — old solutions become misleading',
109
+ 'Storing too much: copying entire file contents instead of the key insight',
110
+ ],
111
+ patterns: [
112
+ 'Search-first: always query the knowledge base before solving a problem from scratch',
113
+ 'Self-contained entries: each entry stands alone — future agent needs no original context',
114
+ 'Type-and-tag taxonomy: type (solution/pattern/error/reference/decision) + tags enables faceted retrieval',
115
+ 'Dedup-on-write: search for duplicates before every store operation',
116
+ ],
117
+ duration_estimate: '5-15 minutes',
118
+ };
119
+ }
120
+ //# sourceMappingURL=knowledge-base.js.map
@@ -0,0 +1,140 @@
1
+ function detectCategory(task) {
2
+ const t = task.toLowerCase();
3
+ if (t.includes('style') || t.includes('format') || t.includes('indent') || t.includes('structure') || t.includes('code pattern'))
4
+ return 'coding-style';
5
+ if (t.includes('naming') || t.includes('convention') || t.includes('variable') || t.includes('function name') || t.includes('identifier'))
6
+ return 'naming';
7
+ if (t.includes('error') || t.includes('exception') || t.includes('catch') || t.includes('throw') || t.includes('handling'))
8
+ return 'error-handling';
9
+ if (t.includes('test') || t.includes('spec') || t.includes('unit') || t.includes('mock') || t.includes('assertion'))
10
+ return 'testing';
11
+ return 'general';
12
+ }
13
+ const categoryApproach = {
14
+ 'coding-style': 'Observe recurring structural patterns in the codebase: file layout, function organisation, import grouping, async patterns, class vs functional preference. Record each distinct pattern via veto_memory_store (type="pattern"). Increment confidence on re-observation. Use high-confidence patterns to guide future code generation.',
15
+ 'naming': 'Extract naming conventions from the existing codebase: camelCase vs snake_case, file naming (kebab-case), export style (named vs default), constant casing (UPPER_SNAKE). Record as patterns with confidence scored by frequency. Apply consistently — an AI that ignores existing conventions creates noisy diffs.',
16
+ 'error-handling': 'Identify the error-handling contract: typed errors vs raw strings, Result types vs exceptions, HTTP error mapping conventions, logging format. Record the dominant pattern so all generated code uses the same error style. Flag when new code diverges from the established pattern.',
17
+ 'testing': 'Learn the testing conventions: framework (Jest / Vitest / Mocha), file placement (co-located vs __tests__/), describe/it nesting depth, mock style (jest.mock vs manual mocks), assertion verbosity. Record each observed pattern. Generated tests should be indistinguishable from human-written tests in this codebase.',
18
+ 'general': 'Scan recent files modified in the session. Extract 3–5 recurring patterns that are non-obvious (not just "uses TypeScript"). Store each via veto_memory_store (type="pattern"). On subsequent observations of the same pattern, call upsertPattern to increment confidence.',
19
+ };
20
+ const categorySteps = {
21
+ 'coding-style': [
22
+ 'Read 5–10 representative source files across the codebase',
23
+ 'Identify the dominant import grouping order (stdlib → third-party → local)',
24
+ 'Identify async pattern: async/await vs Promise chains vs callbacks',
25
+ 'Identify class vs functional component preference',
26
+ 'Identify single-return vs early-return guard clause preference',
27
+ 'Identify comment style: JSDoc, inline comments, or none',
28
+ 'Record each as a pattern: { key: "code.async-pattern", val: "async/await with try/catch" }',
29
+ 'Call veto_memory_store for each new pattern with type="pattern"',
30
+ 'On subsequent observation, call upsertPattern to increase confidence',
31
+ 'Output a pattern summary for use in future code generation prompts',
32
+ ],
33
+ 'naming': [
34
+ 'Scan file names in src/ to confirm naming convention (kebab-case, camelCase, etc.)',
35
+ 'Read 5 files and extract variable names to confirm camelCase vs snake_case',
36
+ 'Check constants for UPPER_SNAKE_CASE vs camelCase',
37
+ 'Check type / interface names for PascalCase confirmation',
38
+ 'Check function names for verb-first convention (getData vs getDataFetch)',
39
+ 'Check boolean variable names for is/has/can prefix convention',
40
+ 'Record each naming rule as a pattern with confidence',
41
+ 'Flag any files that violate the dominant convention — they may be intentional exceptions',
42
+ ],
43
+ 'error-handling': [
44
+ 'Search for throw new and catch patterns across the codebase',
45
+ 'Identify if typed error classes are used (class NotFoundError extends Error)',
46
+ 'Identify if Result<T, E> pattern is used vs throwing',
47
+ 'Identify the HTTP status code mapping pattern for API errors',
48
+ 'Identify the logging format for errors (structured JSON vs console.error)',
49
+ 'Identify if error messages are user-facing strings or internal codes',
50
+ 'Record the dominant error pattern as high-confidence',
51
+ 'Record any secondary patterns as lower-confidence alternatives',
52
+ ],
53
+ 'testing': [
54
+ 'Identify the test framework from package.json devDependencies',
55
+ 'Find test files and confirm naming convention (*.test.ts vs *.spec.ts)',
56
+ 'Confirm test file placement: co-located vs separate __tests__/ directory',
57
+ 'Read 3 test files to identify describe/it nesting depth',
58
+ 'Identify mock strategy: jest.mock() at top vs factory functions vs manual mocks',
59
+ 'Identify setup/teardown patterns (beforeEach, afterEach usage)',
60
+ 'Identify assertion library and verbosity (expect(x).toBe(y) vs x === y)',
61
+ 'Record each pattern with confidence scored by frequency across test files',
62
+ ],
63
+ 'general': [
64
+ 'Read the 5 most recently modified source files',
65
+ 'Extract patterns that appear in 3 or more of the files',
66
+ 'Identify patterns that are non-obvious (not just "uses TypeScript")',
67
+ 'For each pattern: write a key (category.pattern-name) and a concise value',
68
+ 'Call veto_memory_store with type="pattern" for new patterns',
69
+ 'For patterns already stored, call upsertPattern to increment confidence',
70
+ 'Output a pattern summary listing key, value, and confidence for each learned pattern',
71
+ ],
72
+ };
73
+ const categoryChecklist = {
74
+ 'coding-style': [
75
+ '[ ] At least 5 source files scanned',
76
+ '[ ] Async pattern identified and recorded',
77
+ '[ ] Import order identified and recorded',
78
+ '[ ] Functional vs class preference identified',
79
+ '[ ] Comment style identified',
80
+ '[ ] All patterns stored via veto_memory_store',
81
+ '[ ] Confidence incremented for re-observed patterns',
82
+ ],
83
+ 'naming': [
84
+ '[ ] File naming convention confirmed',
85
+ '[ ] Variable naming convention confirmed',
86
+ '[ ] Constant naming convention confirmed',
87
+ '[ ] Boolean naming prefix confirmed',
88
+ '[ ] All naming rules stored as patterns',
89
+ '[ ] Convention violations flagged',
90
+ ],
91
+ 'error-handling': [
92
+ '[ ] Typed vs untyped error strategy identified',
93
+ '[ ] Result type vs exception choice recorded',
94
+ '[ ] HTTP error mapping pattern recorded',
95
+ '[ ] Logging format pattern recorded',
96
+ '[ ] Dominant pattern stored as high-confidence',
97
+ ],
98
+ 'testing': [
99
+ '[ ] Test framework identified',
100
+ '[ ] Test file naming convention recorded',
101
+ '[ ] Test file placement recorded',
102
+ '[ ] Mock strategy identified and recorded',
103
+ '[ ] Assertion style recorded',
104
+ '[ ] All patterns stored with confidence',
105
+ ],
106
+ 'general': [
107
+ '[ ] At least 5 files scanned',
108
+ '[ ] Only non-obvious patterns recorded',
109
+ '[ ] pattern_key follows category.pattern-name format',
110
+ '[ ] Existing patterns updated via upsertPattern',
111
+ '[ ] Pattern summary outputted',
112
+ ],
113
+ };
114
+ export function plan(task, context) {
115
+ const category = detectCategory(task + ' ' + (context ?? ''));
116
+ return {
117
+ agent: 'pattern-learner',
118
+ task,
119
+ tier: 1,
120
+ approach: categoryApproach[category],
121
+ steps: categorySteps[category],
122
+ checklist: categoryChecklist[category],
123
+ pitfalls: [
124
+ 'Recording obvious patterns ("uses TypeScript", "has functions") — only record non-obvious recurring choices',
125
+ 'Treating low-frequency patterns as conventions — require at least 3 observations before treating as established',
126
+ 'Conflating two different patterns: e.g. "async/await in services, promises in utilities" — store separately',
127
+ 'Not incrementing confidence on re-observation — all patterns stay at 1.0 and are equally trusted',
128
+ 'Applying learned patterns to files that deliberately deviate (e.g. legacy files, test fixtures)',
129
+ 'Over-specifying patterns: "uses 2-space indent in coder.ts" vs "uses 2-space indent across all TypeScript files"',
130
+ ],
131
+ patterns: [
132
+ 'Frequency-confidence: confidence increases with each additional observation of the pattern',
133
+ 'Category namespacing: key format "category.specific-pattern" enables prefix search',
134
+ 'Deviation detection: compare new code to stored patterns and flag significant divergence',
135
+ 'Pattern evolution: when a pattern changes (e.g. moving from callbacks to async/await), update the stored value rather than adding a duplicate',
136
+ ],
137
+ duration_estimate: '10-20 minutes',
138
+ };
139
+ }
140
+ //# sourceMappingURL=pattern-learner.js.map