@theihtisham/agent-shadow-brain 7.0.0 → 7.2.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 (79) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +36 -396
  3. package/dist/brain/auto-update.js +1 -1
  4. package/dist/brain/brain-portability.js +1 -1
  5. package/dist/brain/context-assembly.d.ts +58 -0
  6. package/dist/brain/context-assembly.d.ts.map +1 -0
  7. package/dist/brain/context-assembly.js +207 -0
  8. package/dist/brain/context-assembly.js.map +1 -0
  9. package/dist/brain/feature-settings.d.ts +53 -0
  10. package/dist/brain/feature-settings.d.ts.map +1 -0
  11. package/dist/brain/feature-settings.js +232 -0
  12. package/dist/brain/feature-settings.js.map +1 -0
  13. package/dist/brain/global-brain.d.ts +1 -0
  14. package/dist/brain/global-brain.d.ts.map +1 -1
  15. package/dist/brain/global-brain.js +3 -3
  16. package/dist/brain/global-brain.js.map +1 -1
  17. package/dist/brain/mcp-server.d.ts +4 -0
  18. package/dist/brain/mcp-server.d.ts.map +1 -1
  19. package/dist/brain/mcp-server.js +81 -5
  20. package/dist/brain/mcp-server.js.map +1 -1
  21. package/dist/brain/orchestrator.js +1 -1
  22. package/dist/brain/subconscious.d.ts +19 -24
  23. package/dist/brain/subconscious.d.ts.map +1 -1
  24. package/dist/brain/subconscious.js +77 -218
  25. package/dist/brain/subconscious.js.map +1 -1
  26. package/dist/brain/task-workflow.d.ts +22 -0
  27. package/dist/brain/task-workflow.d.ts.map +1 -0
  28. package/dist/brain/task-workflow.js +182 -0
  29. package/dist/brain/task-workflow.js.map +1 -0
  30. package/dist/brain/workflow-skills.d.ts +86 -0
  31. package/dist/brain/workflow-skills.d.ts.map +1 -0
  32. package/dist/brain/workflow-skills.js +514 -0
  33. package/dist/brain/workflow-skills.js.map +1 -0
  34. package/dist/cli.js +6 -2
  35. package/dist/cli.js.map +1 -1
  36. package/dist/context-cli.d.ts +3 -0
  37. package/dist/context-cli.d.ts.map +1 -0
  38. package/dist/context-cli.js +54 -0
  39. package/dist/context-cli.js.map +1 -0
  40. package/dist/dashboard/server.d.ts +1 -0
  41. package/dist/dashboard/server.d.ts.map +1 -1
  42. package/dist/dashboard/server.js +32 -4
  43. package/dist/dashboard/server.js.map +1 -1
  44. package/dist/dashboard/v6-dashboard-html.d.ts +1 -1
  45. package/dist/dashboard/v6-dashboard-html.d.ts.map +1 -1
  46. package/dist/dashboard/v6-dashboard-html.js +5 -27
  47. package/dist/dashboard/v6-dashboard-html.js.map +1 -1
  48. package/dist/dashboard/workspace-api.d.ts +10 -0
  49. package/dist/dashboard/workspace-api.d.ts.map +1 -0
  50. package/dist/dashboard/workspace-api.js +193 -0
  51. package/dist/dashboard/workspace-api.js.map +1 -0
  52. package/dist/dashboard/workspace-html.d.ts +2 -0
  53. package/dist/dashboard/workspace-html.d.ts.map +1 -0
  54. package/dist/dashboard/workspace-html.js +1555 -0
  55. package/dist/dashboard/workspace-html.js.map +1 -0
  56. package/dist/index.d.ts +8 -0
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +4 -0
  59. package/dist/index.js.map +1 -1
  60. package/dist/types.d.ts +4 -2
  61. package/dist/types.d.ts.map +1 -1
  62. package/dist/workflow-cli.d.ts +3 -0
  63. package/dist/workflow-cli.d.ts.map +1 -0
  64. package/dist/workflow-cli.js +100 -0
  65. package/dist/workflow-cli.js.map +1 -0
  66. package/docs/WORKFLOW_INTEGRATION.md +105 -0
  67. package/docs/WORKSPACE.md +70 -0
  68. package/docs/assets/context-flow-v7.2.png +0 -0
  69. package/docs/assets/workspace-graph-v7.2.png +0 -0
  70. package/docs/assets/workspace-overview-v7.2.png +0 -0
  71. package/docs/launch/RELEASE_NOTES_v7.1.0.md +32 -0
  72. package/docs/launch/RELEASE_NOTES_v7.2.0.md +24 -0
  73. package/package.json +111 -207
  74. package/skills/shadow-debug/SKILL.md +16 -0
  75. package/skills/shadow-implement/SKILL.md +16 -0
  76. package/skills/shadow-release/SKILL.md +16 -0
  77. package/skills/shadow-research/SKILL.md +12 -0
  78. package/skills/shadow-review/SKILL.md +14 -0
  79. package/skills/shadow-workflow/SKILL.md +31 -0
@@ -1 +1 @@
1
- {"version":3,"file":"subconscious.d.ts","sourceRoot":"","sources":["../../src/brain/subconscious.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EAElB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAkB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAkBhE,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAAoB;gBAErB,MAAM,GAAE,OAAO,CAAC,kBAAkB,CAAM,EAAE,KAAK,CAAC,EAAE,WAAW;IAazE,oFAAoF;IAC9E,gBAAgB,CAAC,IAAI,EAAE;QAC3B,SAAS,EAAE,SAAS,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA4EjC,wBAAwB;IACxB,QAAQ,IAAI,iBAAiB;IAI7B,+BAA+B;IAC/B,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,IAAI;IAInD,SAAS,IAAI,kBAAkB;IAM/B,OAAO,CAAC,YAAY;IAoBpB,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,gBAAgB;IA8CxB,OAAO,CAAC,YAAY;IAmBpB,OAAO,CAAC,aAAa;IAmBrB,O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,CAAC,UAAU;IAiBlB,OAAO,CAAC,aAAa;CAkBtB;AAID,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,kBAAkB,CAIxF"}
@@ -1,18 +1,9 @@
1
- // src/brain/subconscious.ts — Subconscious Engine (v5.2.0)
2
- //
3
- // On every new agent session, the Subconscious proactively injects a tight
4
- // briefing of relevant context — recent decisions, similar past work, project
5
- // state, cross-agent insights — so the agent doesn't have to ask.
6
- //
7
- // "Subconscious" because the agent doesn't actively retrieve this — the brain
8
- // makes it available implicitly. Like human intuition: the relevant memory
9
- // surfaces before you consciously look for it.
10
- //
11
- // Token budget: hard-capped (default 2000) to never bloat the agent's context.
12
- // Relevance ranked: each section competes for budget by importance × recency.
1
+ import * as path from 'node:path';
2
+ import { createHash, randomUUID } from 'node:crypto';
3
+ import { assembleContext, contextQueryKeywords } from './context-assembly.js';
4
+ import { FEATURE_SETTINGS_FILENAME, FeatureSettingsStore } from './feature-settings.js';
13
5
  import { getGlobalBrain, GlobalBrain } from './global-brain.js';
14
- import { getCache } from './l0-cache.js';
15
- import * as crypto from 'crypto';
6
+ import { L0Cache } from './l0-cache.js';
16
7
  const DEFAULT_CONFIG = {
17
8
  enabled: true,
18
9
  tokenBudget: 2000,
@@ -21,14 +12,9 @@ const DEFAULT_CONFIG = {
21
12
  alwaysInclude: ['decision', 'pattern', 'warning'],
22
13
  enabledAgents: [],
23
14
  };
24
- /** ~4 chars per token (rough English heuristic) */
25
- function estimateTokens(text) {
26
- return Math.ceil(text.length / 4);
27
- }
28
15
  export class SubconsciousEngine {
29
- constructor(config = {}, brain) {
30
- this.config = { ...DEFAULT_CONFIG, ...config };
31
- this.brain = brain ?? getGlobalBrain();
16
+ constructor(config = {}, brain, settings) {
17
+ this.cache = new L0Cache({ bytesLimit: 2 * 1024 * 1024 });
32
18
  this.stats = {
33
19
  totalBriefings: 0,
34
20
  avgTokenCount: 0,
@@ -37,216 +23,92 @@ export class SubconsciousEngine {
37
23
  byAgent: {},
38
24
  lastBriefing: null,
39
25
  };
26
+ this.config = { ...DEFAULT_CONFIG, ...config };
27
+ this.brain = brain ?? getGlobalBrain();
28
+ this.settings = settings ?? new FeatureSettingsStore({
29
+ filePath: path.join(path.dirname(this.brain.dbPath), FEATURE_SETTINGS_FILENAME),
30
+ });
40
31
  }
41
- /** Generate a session-start briefing for the agent — proactive context injection */
32
+ /** Generate a session-start briefing from the current project and task. */
42
33
  async generateBriefing(opts) {
43
34
  const start = Date.now();
44
- const sessionId = crypto.randomUUID();
45
- const projectId = opts.projectId ?? GlobalBrain.projectIdFor(opts.projectDir);
46
- const projectName = opts.projectName ?? opts.projectDir.split(/[/\\]/).pop() ?? 'unknown';
47
- // L0 cache check — if we briefed this agent for this project recently, reuse
48
- const cacheKey = `subconscious:${opts.agentTool}:${projectId}`;
49
- const cache = getCache('subconscious');
50
- const cached = cache.get(cacheKey);
51
- if (cached && Date.now() - cached.generatedAt.getTime() < 60000) {
52
- return cached;
53
- }
54
- // Skip if disabled or agent not in enabled list
55
- if (!this.config.enabled || (this.config.enabledAgents.length > 0 && !this.config.enabledAgents.includes(opts.agentTool))) {
56
- return this.emptyBriefing(opts.agentTool, opts.projectDir, sessionId);
57
- }
58
- if (!('init' in this.brain)) {
59
- return this.emptyBriefing(opts.agentTool, opts.projectDir, sessionId);
35
+ const briefing = this.emptyBriefing(opts);
36
+ const config = this.getConfig();
37
+ if (!config.enabled)
38
+ return { ...briefing, disabledReason: 'configuration' };
39
+ if (config.enabledAgents.length && !config.enabledAgents.includes(opts.agentTool)) {
40
+ return { ...briefing, disabledReason: 'agent' };
60
41
  }
61
- try {
62
- await this.brain.init();
63
- }
64
- catch { /* already initialized */ }
65
- // Build sections within budget
66
- const lookbackMs = this.config.lookbackHours * 60 * 60 * 1000;
67
- const cutoff = Date.now() - lookbackMs;
68
- const recentDecisions = this.fetchSection(projectId, ['decision'], cutoff, 5);
69
- const activeTasks = this.fetchSection(projectId, ['task', 'todo'], cutoff, 5);
70
- const projectState = this.fetchProjectStateSummary(projectId);
71
- const crossAgentInsights = this.fetchCrossAgentInsights(projectId, opts.agentTool, cutoff, 5);
72
- const warnings = this.fetchSection(projectId, ['warning', 'critical', 'security'], cutoff, 3);
73
- const similarPastWork = opts.currentTask
74
- ? this.fetchSimilarWork(opts.currentTask, opts.agentTool, 3)
75
- : this.fetchTopPatterns(projectId, 3);
76
- const briefing = {
77
- agentTool: opts.agentTool,
78
- projectDir: opts.projectDir,
79
- sessionId,
80
- generatedAt: new Date(),
81
- tokenCount: 0,
82
- sections: {
83
- recentDecisions: recentDecisions.map(e => this.formatEntry(e)),
84
- activeTasks: activeTasks.map(e => this.formatEntry(e)),
85
- similarPastWork: similarPastWork.map(e => this.formatEntry(e)),
86
- projectState,
87
- crossAgentInsights: crossAgentInsights.map(e => `[${e.agentTool}] ${this.formatEntry(e)}`),
88
- warnings: warnings.map(e => this.formatEntry(e)),
89
- },
90
- fullText: '',
91
- };
92
- briefing.fullText = this.assembleBriefing(briefing, projectName);
93
- briefing.tokenCount = estimateTokens(briefing.fullText);
94
- // Trim if over budget — drop lowest-priority sections first
95
- if (briefing.tokenCount > this.config.tokenBudget) {
96
- briefing.fullText = this.trimToBudget(briefing, projectName);
97
- briefing.tokenCount = estimateTokens(briefing.fullText);
98
- }
99
- // Cache it
100
- cache.set(cacheKey, briefing);
101
- // Update stats
42
+ const settings = this.settings.get();
43
+ if (!settings.features.automaticBriefing)
44
+ return { ...briefing, disabledReason: 'automaticBriefing' };
45
+ if (!settings.features.contextAssembly)
46
+ return { ...briefing, disabledReason: 'contextAssembly' };
47
+ const projectId = opts.projectId ?? GlobalBrain.projectIdFor(opts.projectDir);
48
+ const terms = contextQueryKeywords(opts.currentTask);
49
+ await this.brain.init();
50
+ const key = createHash('sha256').update(JSON.stringify({
51
+ projectDir: opts.projectDir, projectId, agentTool: opts.agentTool, terms, config,
52
+ includeCrossProject: opts.includeCrossProject, settings,
53
+ lastCommit: this.brain.getStorageHealth().lastSuccessfulSync,
54
+ })).digest('hex');
55
+ const cached = this.cache.get(key);
56
+ if (cached && Date.now() - cached.generatedAt.getTime() < 60000)
57
+ return structuredClone(cached);
58
+ const context = assembleContext(this.brain, {
59
+ projectId,
60
+ query: opts.currentTask,
61
+ maxEntries: 15,
62
+ tokenBudget: config.tokenBudget,
63
+ minImportance: config.relevanceThreshold,
64
+ lookbackHours: config.lookbackHours,
65
+ alwaysInclude: config.alwaysInclude,
66
+ includeCrossProject: opts.includeCrossProject,
67
+ features: settings.features,
68
+ });
69
+ for (const entry of context.entries)
70
+ this.addSection(briefing.sections, entry, projectId, opts.agentTool, terms.length > 0);
71
+ briefing.fullText = context.markdown;
72
+ briefing.tokenCount = context.budget.estimatedTokens;
73
+ this.cache.set(key, structuredClone(briefing));
102
74
  this.stats.totalBriefings++;
103
- this.stats.avgTokenCount = this.runningAvg(this.stats.avgTokenCount, briefing.tokenCount, this.stats.totalBriefings);
104
- this.stats.avgGenerationMs = this.runningAvg(this.stats.avgGenerationMs, Date.now() - start, this.stats.totalBriefings);
75
+ this.stats.avgTokenCount += (briefing.tokenCount - this.stats.avgTokenCount) / this.stats.totalBriefings;
76
+ this.stats.avgGenerationMs += (Date.now() - start - this.stats.avgGenerationMs) / this.stats.totalBriefings;
105
77
  this.stats.byAgent[opts.agentTool] = (this.stats.byAgent[opts.agentTool] ?? 0) + 1;
106
78
  this.stats.lastBriefing = new Date();
107
79
  return briefing;
108
80
  }
109
- /** Get current stats */
110
81
  getStats() {
111
- return { ...this.stats };
82
+ return { ...this.stats, byAgent: { ...this.stats.byAgent } };
112
83
  }
113
- /** Update config at runtime */
114
84
  configure(patch) {
115
85
  this.config = { ...this.config, ...patch };
86
+ this.cache.clear();
116
87
  }
117
88
  getConfig() {
118
- return { ...this.config };
119
- }
120
- // ─── Private helpers ────────────────────────────────────────────────────────
121
- fetchSection(projectId, categories, cutoffMs, limit) {
122
- const results = [];
123
- for (const category of categories) {
124
- const entries = this.brain.recall({
125
- projectId,
126
- category,
127
- limit,
128
- minImportance: this.config.relevanceThreshold,
129
- });
130
- for (const e of entries) {
131
- if (e.lastAccessed.getTime() >= cutoffMs || e.createdAt.getTime() >= cutoffMs) {
132
- results.push(e);
133
- }
134
- }
135
- }
136
- return results
137
- .sort((a, b) => b.importance - a.importance)
138
- .slice(0, limit);
139
- }
140
- fetchCrossAgentInsights(projectId, currentAgent, cutoffMs, limit) {
141
- const all = this.brain.recall({
142
- projectId,
143
- limit: limit * 3,
144
- minImportance: this.config.relevanceThreshold,
145
- });
146
- return all
147
- .filter(e => e.agentTool !== currentAgent && (e.lastAccessed.getTime() >= cutoffMs || e.createdAt.getTime() >= cutoffMs))
148
- .slice(0, limit);
149
- }
150
- fetchProjectStateSummary(projectId) {
151
- const recent = this.brain.recall({ projectId, category: 'state', limit: 1 });
152
- if (recent.length)
153
- return recent[0].content.slice(0, 300);
154
- const top = this.brain.recall({ projectId, limit: 3 });
155
- if (!top.length)
156
- return '';
157
- return top.map(e => `${e.category}: ${e.content.slice(0, 80)}`).join('; ');
158
- }
159
- fetchSimilarWork(taskHint, agentTool, limit) {
160
- const keywords = this.extractKeywords(taskHint);
161
- if (!keywords.length)
162
- return [];
163
- return this.brain.recall({
164
- keywords,
165
- limit,
166
- minImportance: this.config.relevanceThreshold,
167
- });
168
- }
169
- fetchTopPatterns(projectId, limit) {
170
- return this.brain.recall({ projectId, category: 'pattern', limit });
171
- }
172
- extractKeywords(text) {
173
- const stop = new Set(['the', 'and', 'or', 'a', 'an', 'is', 'are', 'was', 'were', 'in', 'on', 'at', 'to', 'for', 'of', 'with', 'by', 'this', 'that']);
174
- return text
175
- .toLowerCase()
176
- .split(/\W+/)
177
- .filter(w => w.length > 3 && !stop.has(w))
178
- .slice(0, 5);
179
- }
180
- formatEntry(entry) {
181
- const content = entry.content.length > 200 ? entry.content.slice(0, 197) + '...' : entry.content;
182
- return content;
183
- }
184
- assembleBriefing(briefing, projectName) {
185
- const parts = [];
186
- parts.push(`# 🧠 Shadow Brain — Subconscious Briefing`);
187
- parts.push(`_Project: ${projectName} | Agent: ${briefing.agentTool} | Auto-generated by Shadow Brain v5.2.0_`);
188
- parts.push('');
189
- if (briefing.sections.warnings.length) {
190
- parts.push(`## ⚠️ Warnings`);
191
- for (const w of briefing.sections.warnings)
192
- parts.push(`- ${w}`);
193
- parts.push('');
194
- }
195
- if (briefing.sections.recentDecisions.length) {
196
- parts.push(`## Recent Decisions`);
197
- for (const d of briefing.sections.recentDecisions)
198
- parts.push(`- ${d}`);
199
- parts.push('');
200
- }
201
- if (briefing.sections.activeTasks.length) {
202
- parts.push(`## Active Tasks`);
203
- for (const t of briefing.sections.activeTasks)
204
- parts.push(`- ${t}`);
205
- parts.push('');
206
- }
207
- if (briefing.sections.projectState) {
208
- parts.push(`## Project State`);
209
- parts.push(briefing.sections.projectState);
210
- parts.push('');
211
- }
212
- if (briefing.sections.crossAgentInsights.length) {
213
- parts.push(`## Cross-Agent Insights`);
214
- for (const i of briefing.sections.crossAgentInsights)
215
- parts.push(`- ${i}`);
216
- parts.push('');
217
- }
218
- if (briefing.sections.similarPastWork.length) {
219
- parts.push(`## Similar Past Work`);
220
- for (const s of briefing.sections.similarPastWork)
221
- parts.push(`- ${s}`);
222
- parts.push('');
223
- }
224
- return parts.join('\n').trim();
225
- }
226
- trimToBudget(briefing, projectName) {
227
- // Drop sections in this priority order until under budget:
228
- // similarPastWork → crossAgentInsights → activeTasks → recentDecisions → warnings (warnings last)
229
- const trimmedSections = { ...briefing.sections };
230
- const dropOrder = ['similarPastWork', 'crossAgentInsights', 'activeTasks', 'recentDecisions'];
231
- for (const key of dropOrder) {
232
- let text = this.assembleBriefing({ ...briefing, sections: trimmedSections }, projectName);
233
- if (estimateTokens(text) <= this.config.tokenBudget)
234
- return text;
235
- const arr = trimmedSections[key];
236
- if (Array.isArray(arr)) {
237
- trimmedSections[key] = [];
238
- }
239
- else {
240
- trimmedSections[key] = '';
241
- }
242
- }
243
- return this.assembleBriefing({ ...briefing, sections: trimmedSections }, projectName);
244
- }
245
- emptyBriefing(agentTool, projectDir, sessionId) {
89
+ return { ...this.config, alwaysInclude: [...this.config.alwaysInclude], enabledAgents: [...this.config.enabledAgents] };
90
+ }
91
+ addSection(sections, entry, projectId, agentTool, hasTask) {
92
+ const origin = entry.projectId === projectId ? '' : '[' + (entry.projectName || entry.projectId) + '] ';
93
+ const text = origin + (entry.excerptTruncated ? 'Excerpt: ' : '') + entry.excerpt;
94
+ if (['warning', 'critical', 'security'].includes(entry.category))
95
+ sections.warnings.push(text);
96
+ else if (entry.category === 'decision')
97
+ sections.recentDecisions.push(text);
98
+ else if (entry.category === 'task' || entry.category === 'todo')
99
+ sections.activeTasks.push(text);
100
+ else if (entry.category === 'state' && !sections.projectState)
101
+ sections.projectState = text;
102
+ else if (entry.agentTool !== agentTool && !hasTask)
103
+ sections.crossAgentInsights.push('[' + entry.agentTool + '] ' + text);
104
+ else
105
+ sections.similarPastWork.push(text);
106
+ }
107
+ emptyBriefing(opts) {
246
108
  return {
247
- agentTool,
248
- projectDir,
249
- sessionId,
109
+ agentTool: opts.agentTool,
110
+ projectDir: opts.projectDir,
111
+ sessionId: randomUUID(),
250
112
  generatedAt: new Date(),
251
113
  tokenCount: 0,
252
114
  sections: {
@@ -260,9 +122,6 @@ export class SubconsciousEngine {
260
122
  fullText: '',
261
123
  };
262
124
  }
263
- runningAvg(prev, next, n) {
264
- return prev + (next - prev) / n;
265
- }
266
125
  }
267
126
  let defaultEngine = null;
268
127
  export function getSubconscious(config) {
@@ -1 +1 @@
1
- {"version":3,"file":"subconscious.js","sourceRoot":"","sources":["../../src/brain/subconscious.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,2EAA2E;AAC3E,8EAA8E;AAC9E,kEAAkE;AAClE,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,+CAA+C;AAC/C,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAS9E,OAAO,EAAE,cAAc,EAA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orkflowOptions {
3
+ mode?: 'auto' | 'plan-only' | 'execute';
4
+ taskType?: 'auto' | Exclude<TaskType, 'direct'>;
5
+ complexity?: 'auto' | 'simple' | 'complex';
6
+ }
7
+ export interface TaskWorkflow {
8
+ taskType: TaskType;
9
+ mode: 'direct' | 'plan-only' | 'plan-then-execute';
10
+ skills: string[];
11
+ steps: Array<{
12
+ id: string;
13
+ title: string;
14
+ completion: string;
15
+ }>;
16
+ reasons: string[];
17
+ requiresAuthorization: string[];
18
+ limitations: string[];
19
+ }
20
+ /** Return advisory routing based on the request and explicit options. */
21
+ export declare function analyzeTask(request: string, options?: TaskWorkflowOptions): TaskWorkflow;
22
+ //# sourceMappingURL=task-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-workflow.d.ts","sourceRoot":"","sources":["../../src/brain/task-workflow.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;AAE5F,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChD,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,QAAQ,GAAG,WAAW,GAAG,mBAAmB,CAAC;IACnD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAChC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAsHD,yEAAyE;AACzE,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,YAAY,CAgF5F"}
@@ -0,0 +1,182 @@
1
+ const TRANSFORMATION = /^(?:(?:please|just)\s+)*(?:translate|rewrite|rephrase|summarize|summarise|proofread|format|capitalize|convert|shorten)\b/;
2
+ const SMALL_EDIT = /^(?:(?:please|just)\s+)*(?:fix|correct)\s+(?:this|the|a|one)\s+(?:typo|spelling|punctuation|grammar in (?:this|the) (?:sentence|text|paragraph))\b/;
3
+ const EXPLANATION = /^(?:(?:please|just)\s+)*(?:what (?:does|is|are|means?)|why does|how (?:does|do i|can i|to)|explain|define)\b/;
4
+ const ENGINEERING_SCOPE = /\b(?:api|backend|frontend|service|application|database|codebase|repository|entire project)\b/;
5
+ const DIAGNOSIS_ONLY = /\b(?:analy[sz]e|analysis|diagnose|diagnosis|investigate|inspection) only\b/;
6
+ const PLAN_ONLY = /\b(?:plan only|only plan|just plan|planning only|just (?:write|make|draft|give|provide)?\s*(?:me )?a plan|do not execute|don['’]t execute|without executing)\b/;
7
+ const ASK_FOR_PLAN = /^(?:(?:please|just)\s+)*(?:plan\b|outline\b|(?:make|create|draft|write|provide|give)\s+(?:me\s+)?(?:a\s+)?(?:\w+\s+){0,2}(?:plan|roadmap)\b)/;
8
+ const PLAN_THEN_EXECUTE = /\b(?:plan|outline)\b[^.!?\n]{0,120}(?:[.!?\n]\s*then|\b(?:then|and))\s+(?:(?:actually|also|then)\s+)?(?:implement|execute|fix|build|repair|apply|ship|deploy|publish)\b/;
9
+ const NO_EDITS = /\b(?:(?:do not|don['’]t|never|without|no)\s+(?:make\s+)?(?:chang(?:e|es|ing)|edit(?:s|ing)?|modify(?:ing)?|mutat(?:e|ion|ing)?|implement(?:ing)?|write|writing)|read[- ]only|leave (?:the files|everything) unchanged)\b/;
10
+ const REVIEW_REQUEST = /\b(?:review|audit|inspect|assess)\s+(?:this|the|my|our|these|a|an|changes|code|pr|pull request|patch|diff|repo(?:sitory)?|for)\b|^(?:please\s+)?(?:review|audit)\b/;
11
+ const RESEARCH_REQUEST = /\b(?:research|look up|find out|compare)\b|\b(?:which|what)\b[^.!?\n]{0,100}\b(?:current|latest|supports?|available|official)\b/;
12
+ const DEBUG_REQUEST = /\b(?:debug|diagnose|diagnosis|troubleshoot|reproduce|regression|broken|failing|fails|failure|crash(?:es|ing)?|error|bug|repair)\b/;
13
+ const DIAGNOSIS_REQUEST = /^(?:(?:please|just)\s+)*(?:diagnose|investigate|analy[sz]e|identify the cause|find out why)\b/;
14
+ const IMPLEMENT_REQUEST = /\b(?:build|implement|add|create|write|update|modify|refactor|integrate|migrate|migration|change|fix|edit|improve|rewrite|convert)\b/;
15
+ const RELEASE_REQUEST = /\b(?:release (?:checklist|plan|package|artifact|notes|preparation)|(?:prepare|stage|cut|make|create)\b[^.!?\n]{0,80}\b(?:release|artifact)|package (?:the|this|our) (?:release|project|artifact|build|application)|(?:publish|deploy|ship|push|tag)\b[^.!?\n]{0,80}\b(?:npm|production|artifact|package|release|repository|repo\b|github|version|build|live)|(?:publish|deploy)\b)/;
16
+ const COMPLEX_REQUEST = /\b(?:migration|migrate|rollout|production|architecture|cross[- ](?:service|project|platform)|multiple (?:components|services|projects|files)|across (?:the )?(?:api|ui|backend|frontend|services|projects)|(?:api|backend)\s+(?:and|plus)\s+(?:ui|frontend)|end[- ]to[- ]end|from scratch|multi[- ]step)\b/;
17
+ const NEGATIVE_CLAUSE = /\b(?:do not|don['’]t|never|without|avoid|no)\s+[^.!?;,\n]*?(?=\s+(?:but|then|however)\b|[.!?;,\n]|$)/g;
18
+ const RELEASE_CHECKLIST = /\brelease (?:checklist|roadmap|plan)\b/;
19
+ function requestedAction(phrase) {
20
+ return new RegExp('(?:^|[.;!?\\n]|\\b(?:and|then|also|but|please|can you|could you|would you)\\s+)\\s*(?:' + phrase + ')\\b');
21
+ }
22
+ const REQUESTED_EDIT = requestedAction('fix|implement|repair|patch|apply|edit|update|change|modify');
23
+ const SIDE_EFFECTS = [
24
+ ['publish', requestedAction('publish|push\\s+(?:it|to|the|this|our)|upload\\b[^.!?\\n]{0,65}\\b(?:npm|github|repository)')],
25
+ ['deploy', requestedAction('deploy|roll out')],
26
+ ['destructive-change', requestedAction('force[- ]push|(?:delete|drop|purge|erase|wipe|remove)\\s+(?:all\\s+|the\\s+|our\\s+|a\\s+)*(?:production|database|accounts?|repositories|repository|backups?|customer data)')],
27
+ ['send-external-message', requestedAction('send\\s+(?:an?\\s+|the\\s+|this\\s+)?(?:message|email|notice)|email\\s+(?:our|the|all)|notify\\s+(?:our|the|all)')],
28
+ ['spend-money', requestedAction('purchase|buy|place (?:an?|the) order|subscribe to')],
29
+ ];
30
+ function actionText(request) {
31
+ return request
32
+ .replace(/\x60{3}[\s\S]*?(?:\x60{3}|$)|\x60[^\x60\n]*\x60|“[^”\n]*”|"[^"\n]*"|(^|\s)'[^'\n]*'(?=\s|[.!?,;]|$)/g, ' ')
33
+ .toLowerCase()
34
+ .trim();
35
+ }
36
+ function step(id, title, completion) {
37
+ return { id, title, completion };
38
+ }
39
+ function buildSteps(taskType, mode, mayEdit, external) {
40
+ if (mode === 'plan-only') {
41
+ return [
42
+ step('inspect', 'Inspect the relevant context', 'Identify the requested outcome, constraints, and current state using available evidence.'),
43
+ step('plan', 'Write the requested plan', 'Describe the proposed actions and verification, then stop at the plan.'),
44
+ ];
45
+ }
46
+ const steps = [];
47
+ if (mode === 'plan-then-execute') {
48
+ steps.push(step('plan', 'Plan the scoped work', 'Identify dependencies, material risks, and how to verify the requested outcome.'));
49
+ }
50
+ switch (taskType) {
51
+ case 'direct':
52
+ steps.push(step('respond', 'Complete the request', 'Return the requested result in the requested format.'));
53
+ break;
54
+ case 'implement':
55
+ steps.push(step('inspect', 'Inspect the relevant code and constraints', 'Identify existing behavior and the acceptance criteria for the change.'));
56
+ if (mayEdit) {
57
+ steps.push(step('implement', 'Implement the scoped change', 'Deliver the requested behavior through its normal entry points.'), step('verify', 'Verify the affected behavior', 'Check the result against the request and report any remaining gap.'));
58
+ }
59
+ break;
60
+ case 'debug':
61
+ steps.push(step('reproduce', 'Reproduce or isolate the failure', 'Identify the failing behavior and the evidence for its cause.'));
62
+ if (mayEdit) {
63
+ steps.push(step('fix', 'Fix the isolated cause', 'Make the smallest change that resolves the requested failure.'), step('verify', 'Verify the original failure', 'Repeat the failing path and check the related behavior for regressions.'));
64
+ }
65
+ else {
66
+ steps.push(step('diagnosis', 'Report the diagnosis', 'State the cause supported by the evidence and any remaining uncertainty.'));
67
+ }
68
+ break;
69
+ case 'review':
70
+ steps.push(step('review', 'Review the requested scope', 'Inspect the relevant changes and prioritize actionable findings with evidence.'));
71
+ if (mayEdit) {
72
+ steps.push(step('fix', 'Fix the requested findings', 'Apply scoped changes for findings the user asked to fix.'), step('verify', 'Verify the fixes', 'Confirm the observed problems are resolved in the affected paths.'));
73
+ }
74
+ steps.push(step('findings', 'Report the review findings', 'Give evidence and locations for actionable findings, with remaining verification gaps.'));
75
+ break;
76
+ case 'research':
77
+ steps.push(step('sources', 'Check the relevant sources', 'Use available primary evidence and identify gaps or conflicting information.'), step('answer', 'Answer the research question', 'State what the evidence supports and identify material uncertainty.'));
78
+ break;
79
+ case 'release':
80
+ steps.push(step('artifact', 'Prepare and verify the release artifact', 'Confirm version, artifact identity, destination when specified, and relevant checks.'));
81
+ if (external.some(action => action === 'publish' || action === 'deploy')) {
82
+ steps.push(step('release', 'Carry out the authorized release action', 'Use the intended destination and the verified artifact with existing authorization.'), step('verify', 'Verify the destination independently', 'Confirm the actual remote version, artifact, or deployed result.'));
83
+ }
84
+ else {
85
+ steps.push(step('report', 'Report the release preparation', 'Provide the requested checklist or release materials and any remaining dependencies.'));
86
+ }
87
+ break;
88
+ }
89
+ return steps;
90
+ }
91
+ /** Return advisory routing based on the request and explicit options. */
92
+ export function analyzeTask(request, options = {}) {
93
+ if (typeof request !== 'string' || !request.trim())
94
+ throw new TypeError('A nonempty task request is required.');
95
+ const { mode = 'auto', taskType: selectedType = 'auto', complexity = 'auto' } = options;
96
+ if (!['auto', 'plan-only', 'execute'].includes(mode))
97
+ throw new TypeError('Unknown workflow mode.');
98
+ if (!['auto', 'implement', 'debug', 'review', 'research', 'release'].includes(selectedType)) {
99
+ throw new TypeError('Unknown workflow task type.');
100
+ }
101
+ if (!['auto', 'simple', 'complex'].includes(complexity))
102
+ throw new TypeError('Unknown workflow complexity.');
103
+ const text = actionText(request);
104
+ const positive = text.replace(NEGATIVE_CLAUSE, ' ');
105
+ const noEdits = NO_EDITS.test(text) || DIAGNOSIS_ONLY.test(text) || /\bno (?:code|file|source) changes\b/.test(text);
106
+ const explicitPlan = PLAN_ONLY.test(text);
107
+ const thenExecute = PLAN_THEN_EXECUTE.test(positive);
108
+ const planRequested = ASK_FOR_PLAN.test(text) || RELEASE_CHECKLIST.test(text);
109
+ const planOnly = mode === 'plan-only' || explicitPlan || (planRequested && noEdits) ||
110
+ (mode === 'auto' && !thenExecute && planRequested);
111
+ const engineeringTransform = TRANSFORMATION.test(text) && ENGINEERING_SCOPE.test(text);
112
+ const directRequest = SMALL_EDIT.test(text) || (TRANSFORMATION.test(text) && !engineeringTransform) ||
113
+ (EXPLANATION.test(text) && !RESEARCH_REQUEST.test(text));
114
+ let taskType;
115
+ const reasons = [];
116
+ if (selectedType !== 'auto') {
117
+ taskType = selectedType;
118
+ reasons.push('The task type was selected explicitly.');
119
+ }
120
+ else if (directRequest) {
121
+ taskType = 'direct';
122
+ reasons.push('The request is a direct answer or small transformation.');
123
+ }
124
+ else if (REVIEW_REQUEST.test(positive)) {
125
+ taskType = 'review';
126
+ reasons.push('The request asks for findings from a review.');
127
+ }
128
+ else if (RESEARCH_REQUEST.test(positive)) {
129
+ taskType = 'research';
130
+ reasons.push('The request asks for source-based information or comparison.');
131
+ }
132
+ else if (RELEASE_REQUEST.test(positive)) {
133
+ taskType = 'release';
134
+ reasons.push('The request concerns release preparation or delivery.');
135
+ }
136
+ else if (DEBUG_REQUEST.test(positive)) {
137
+ taskType = 'debug';
138
+ reasons.push('The request identifies a failure or regression.');
139
+ }
140
+ else if (IMPLEMENT_REQUEST.test(positive) || thenExecute) {
141
+ taskType = 'implement';
142
+ reasons.push('The request asks for a scoped implementation.');
143
+ }
144
+ else {
145
+ taskType = 'direct';
146
+ reasons.push('The request has no clear specialized workflow cue.');
147
+ }
148
+ if (noEdits)
149
+ reasons.push('The request limits the work to inspection.');
150
+ const complex = complexity === 'complex' ||
151
+ (complexity === 'auto' && taskType !== 'direct' &&
152
+ (taskType === 'release' || engineeringTransform || COMPLEX_REQUEST.test(positive)));
153
+ const resultMode = planOnly ? 'plan-only' : thenExecute || complex ? 'plan-then-execute' : 'direct';
154
+ if (planOnly)
155
+ reasons.push('The workflow stops after planning.');
156
+ else if (thenExecute)
157
+ reasons.push('The request explicitly asks to plan and then act.');
158
+ else if (complex)
159
+ reasons.push('The scope benefits from a short plan before work starts.');
160
+ const requestedEdit = REQUESTED_EDIT.test(positive);
161
+ const mayEdit = !noEdits && (taskType !== 'review' || requestedEdit) &&
162
+ (taskType !== 'debug' || !DIAGNOSIS_REQUEST.test(positive) || requestedEdit);
163
+ const sideEffects = planOnly || noEdits || taskType === 'research' || (taskType === 'review' && !mayEdit) || directRequest
164
+ ? []
165
+ : SIDE_EFFECTS.filter(([, pattern]) => pattern.test(positive)).map(([id]) => id);
166
+ const skills = taskType === 'direct'
167
+ ? (resultMode === 'direct' ? [] : ['shadow-workflow'])
168
+ : ['shadow-workflow', 'shadow-' + taskType];
169
+ return {
170
+ taskType,
171
+ mode: resultMode,
172
+ skills,
173
+ steps: buildSteps(taskType, resultMode, mayEdit, sideEffects),
174
+ reasons,
175
+ requiresAuthorization: sideEffects,
176
+ limitations: [
177
+ 'Routing uses English request cues and explicit options.',
178
+ 'The host performs the suggested work and checks authorization already present in the conversation.',
179
+ ],
180
+ };
181
+ }
182
+ //# source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