@causyne/agent 1.20.116 → 1.20.117

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.
package/src/perception.js CHANGED
@@ -30,10 +30,20 @@ export class WorkspacePerception {
30
30
  }
31
31
  // 2b. Design system detection (Anti-Slop: tells the brain what's already installed)
32
32
  context.designSystem = await this.detectDesignContext(resolvedPath);
33
- // 2c. Subprojects detection (find subfolders like 'pixel2d games', 'causyne-agent', etc.)
33
+ // 2c. Subprojects & nested stacks discovery
34
34
  context.subprojects = await this.detectSubprojects(resolvedPath);
35
- // 2d. Key files discovery
36
- context.keyFiles = await this.detectKeyFiles(resolvedPath);
35
+ const repoArtifacts = await this.detectRepoArtifacts(resolvedPath, context.subprojects);
36
+ context.subprojectStacks = repoArtifacts.subprojectStacks;
37
+ context.docFiles = repoArtifacts.docFiles;
38
+ context.buildFiles = repoArtifacts.buildFiles;
39
+ context.topEntries = repoArtifacts.topEntries;
40
+ // 2d. Key files discovery (root entrypoints + key docs & build scripts)
41
+ const rootKeyFiles = await this.detectKeyFiles(resolvedPath);
42
+ context.keyFiles = [...new Set([
43
+ ...rootKeyFiles,
44
+ ...repoArtifacts.buildFiles.slice(0, 8),
45
+ ...repoArtifacts.docFiles.slice(0, 8)
46
+ ])];
37
47
  // 2e. Package manager detection
38
48
  context.packageManager = await this.detectPackageManager(resolvedPath);
39
49
  // 2f. Git branch and status
@@ -196,6 +206,114 @@ export class WorkspacePerception {
196
206
  }
197
207
  return subprojects;
198
208
  }
209
+ async detectRepoArtifacts(dir, subprojects) {
210
+ const subprojectStacks = [];
211
+ const docFiles = [];
212
+ const buildFiles = [];
213
+ const topEntries = [];
214
+ const existsFile = async (rel) => {
215
+ try {
216
+ const stat = await fs.stat(path.join(dir, rel));
217
+ return stat.isFile();
218
+ }
219
+ catch {
220
+ return false;
221
+ }
222
+ };
223
+ try {
224
+ const entries = await fs.readdir(dir, { withFileTypes: true });
225
+ for (const entry of entries) {
226
+ if (entry.name.startsWith('.') || SKIP_DIRECTORIES.has(entry.name))
227
+ continue;
228
+ if (topEntries.length >= 25)
229
+ break;
230
+ topEntries.push(entry.isDirectory() ? `${entry.name}/` : entry.name);
231
+ }
232
+ }
233
+ catch {
234
+ // ignore
235
+ }
236
+ const rootDocs = ['AGENTS.md', 'CLAUDE.md', 'README.md', 'ARCHITECTURE.md', 'CONTRIBUTING.md', 'RELEASE.md', 'ANDROID_RELEASE.md', 'ENGINEERING.md'];
237
+ for (const rel of rootDocs) {
238
+ if (await existsFile(rel))
239
+ docFiles.push(rel);
240
+ }
241
+ const priorityDocScore = (name) => {
242
+ const lower = name.toLowerCase();
243
+ if (/(?:release|android|build|architecture|engineering)/.test(lower))
244
+ return 0;
245
+ if (/(?:readme|agents|claude|work_log|qa|guide)/.test(lower))
246
+ return 1;
247
+ return 2;
248
+ };
249
+ for (const docDir of ['docs', 'doc']) {
250
+ try {
251
+ const docEntries = await fs.readdir(path.join(dir, docDir), { withFileTypes: true });
252
+ const mdFiles = docEntries
253
+ .filter(e => e.isFile() && /\.(?:md|txt)$/i.test(e.name) && !e.name.startsWith('.'))
254
+ .map(e => `${docDir}/${e.name}`)
255
+ .sort((a, b) => priorityDocScore(a) - priorityDocScore(b) || a.localeCompare(b));
256
+ for (const rel of mdFiles) {
257
+ if (docFiles.length >= 16)
258
+ break;
259
+ if (!docFiles.includes(rel))
260
+ docFiles.push(rel);
261
+ }
262
+ }
263
+ catch {
264
+ // ignore missing docs dir
265
+ }
266
+ }
267
+ const rootBuildCandidates = [
268
+ 'Makefile', 'CMakeLists.txt', 'package.json', 'tsconfig.json',
269
+ 'project.godot', 'export_presets.cfg', 'build.gradle', 'build.gradle.kts',
270
+ 'settings.gradle', 'settings.gradle.kts', 'Cargo.toml', 'pyproject.toml',
271
+ 'go.mod', 'pubspec.yaml', 'Dockerfile', 'docker-compose.yml', 'wrangler.toml'
272
+ ];
273
+ for (const rel of rootBuildCandidates) {
274
+ if (await existsFile(rel))
275
+ buildFiles.push(rel);
276
+ }
277
+ try {
278
+ const scriptEntries = await fs.readdir(path.join(dir, 'scripts'), { withFileTypes: true });
279
+ for (const entry of scriptEntries.sort((a, b) => a.name.localeCompare(b.name))) {
280
+ if (!entry.isFile() || entry.name.startsWith('.'))
281
+ continue;
282
+ if (/\.(?:sh|bash|py|js|cjs|mjs|ts|ps1)$/i.test(entry.name)) {
283
+ const rel = `scripts/${entry.name}`;
284
+ if (!buildFiles.includes(rel) && buildFiles.length < 18)
285
+ buildFiles.push(rel);
286
+ }
287
+ }
288
+ }
289
+ catch {
290
+ // ignore missing scripts dir
291
+ }
292
+ const nestedCheckDirs = [...new Set([...subprojects, 'godot', 'android', 'app', 'mobile', 'desktop', 'server', 'backend', 'frontend', 'web'])];
293
+ for (const sub of nestedCheckDirs) {
294
+ if (sub.includes('..') || path.isAbsolute(sub))
295
+ continue;
296
+ const subBuildChecks = [
297
+ { rel: `${sub}/project.godot`, stack: `godot (gdscript) @ ${sub}/` },
298
+ { rel: `${sub}/export_presets.cfg` },
299
+ { rel: `${sub}/build.gradle.kts`, stack: `android (kotlin/gradle) @ ${sub}/` },
300
+ { rel: `${sub}/build.gradle`, stack: `android (gradle) @ ${sub}/` },
301
+ { rel: `${sub}/Cargo.toml`, stack: `rust @ ${sub}/` },
302
+ { rel: `${sub}/go.mod`, stack: `go @ ${sub}/` },
303
+ { rel: `${sub}/pyproject.toml`, stack: `python @ ${sub}/` },
304
+ { rel: `${sub}/package.json`, stack: `node @ ${sub}/` }
305
+ ];
306
+ for (const check of subBuildChecks) {
307
+ if (await existsFile(check.rel)) {
308
+ if (!buildFiles.includes(check.rel) && buildFiles.length < 22)
309
+ buildFiles.push(check.rel);
310
+ if (check.stack && !subprojectStacks.includes(check.stack))
311
+ subprojectStacks.push(check.stack);
312
+ }
313
+ }
314
+ }
315
+ return { subprojectStacks, docFiles, buildFiles, topEntries };
316
+ }
199
317
  async detectKeyFiles(dir) {
200
318
  const candidateFiles = [
201
319
  'package.json', 'tsconfig.json', 'index.html', 'main.js',
@@ -285,6 +403,9 @@ export class WorkspacePerception {
285
403
  catch {
286
404
  // ignore
287
405
  }
406
+ if (context.subprojectStacks?.some(s => s.startsWith('godot '))) {
407
+ return 'Godot Game Project';
408
+ }
288
409
  // Check directory name or key files for game patterns
289
410
  const baseName = path.basename(dir).toLowerCase();
290
411
  if (baseName.includes('game') || baseName.includes('pixel') || baseName.includes('arcade')) {
package/src/perception.ts CHANGED
@@ -44,6 +44,10 @@ export interface WorkspaceContextData {
44
44
  framework: FrameworkInfo | null;
45
45
  designSystem: string[] | null;
46
46
  subprojects: string[];
47
+ subprojectStacks?: string[];
48
+ docFiles?: string[];
49
+ buildFiles?: string[];
50
+ topEntries?: string[];
47
51
  keyFiles: string[];
48
52
  packageManager: string | null;
49
53
  gitBranch?: string;
@@ -82,11 +86,21 @@ export class WorkspacePerception {
82
86
  // 2b. Design system detection (Anti-Slop: tells the brain what's already installed)
83
87
  context.designSystem = await this.detectDesignContext(resolvedPath);
84
88
 
85
- // 2c. Subprojects detection (find subfolders like 'pixel2d games', 'causyne-agent', etc.)
89
+ // 2c. Subprojects & nested stacks discovery
86
90
  context.subprojects = await this.detectSubprojects(resolvedPath);
87
-
88
- // 2d. Key files discovery
89
- context.keyFiles = await this.detectKeyFiles(resolvedPath);
91
+ const repoArtifacts = await this.detectRepoArtifacts(resolvedPath, context.subprojects);
92
+ context.subprojectStacks = repoArtifacts.subprojectStacks;
93
+ context.docFiles = repoArtifacts.docFiles;
94
+ context.buildFiles = repoArtifacts.buildFiles;
95
+ context.topEntries = repoArtifacts.topEntries;
96
+
97
+ // 2d. Key files discovery (root entrypoints + key docs & build scripts)
98
+ const rootKeyFiles = await this.detectKeyFiles(resolvedPath);
99
+ context.keyFiles = [...new Set([
100
+ ...rootKeyFiles,
101
+ ...repoArtifacts.buildFiles.slice(0, 8),
102
+ ...repoArtifacts.docFiles.slice(0, 8)
103
+ ])];
90
104
 
91
105
  // 2e. Package manager detection
92
106
  context.packageManager = await this.detectPackageManager(resolvedPath);
@@ -266,6 +280,112 @@ export class WorkspacePerception {
266
280
  return subprojects;
267
281
  }
268
282
 
283
+ async detectRepoArtifacts(dir: string, subprojects: string[]): Promise<{
284
+ subprojectStacks: string[];
285
+ docFiles: string[];
286
+ buildFiles: string[];
287
+ topEntries: string[];
288
+ }> {
289
+ const subprojectStacks: string[] = [];
290
+ const docFiles: string[] = [];
291
+ const buildFiles: string[] = [];
292
+ const topEntries: string[] = [];
293
+
294
+ const existsFile = async (rel: string): Promise<boolean> => {
295
+ try {
296
+ const stat = await fs.stat(path.join(dir, rel));
297
+ return stat.isFile();
298
+ } catch {
299
+ return false;
300
+ }
301
+ };
302
+
303
+ try {
304
+ const entries = await fs.readdir(dir, { withFileTypes: true });
305
+ for (const entry of entries) {
306
+ if (entry.name.startsWith('.') || SKIP_DIRECTORIES.has(entry.name)) continue;
307
+ if (topEntries.length >= 25) break;
308
+ topEntries.push(entry.isDirectory() ? `${entry.name}/` : entry.name);
309
+ }
310
+ } catch {
311
+ // ignore
312
+ }
313
+
314
+ const rootDocs = ['AGENTS.md', 'CLAUDE.md', 'README.md', 'ARCHITECTURE.md', 'CONTRIBUTING.md', 'RELEASE.md', 'ANDROID_RELEASE.md', 'ENGINEERING.md'];
315
+ for (const rel of rootDocs) {
316
+ if (await existsFile(rel)) docFiles.push(rel);
317
+ }
318
+
319
+ const priorityDocScore = (name: string): number => {
320
+ const lower = name.toLowerCase();
321
+ if (/(?:release|android|build|architecture|engineering)/.test(lower)) return 0;
322
+ if (/(?:readme|agents|claude|work_log|qa|guide)/.test(lower)) return 1;
323
+ return 2;
324
+ };
325
+
326
+ for (const docDir of ['docs', 'doc']) {
327
+ try {
328
+ const docEntries = await fs.readdir(path.join(dir, docDir), { withFileTypes: true });
329
+ const mdFiles = docEntries
330
+ .filter(e => e.isFile() && /\.(?:md|txt)$/i.test(e.name) && !e.name.startsWith('.'))
331
+ .map(e => `${docDir}/${e.name}`)
332
+ .sort((a, b) => priorityDocScore(a) - priorityDocScore(b) || a.localeCompare(b));
333
+ for (const rel of mdFiles) {
334
+ if (docFiles.length >= 16) break;
335
+ if (!docFiles.includes(rel)) docFiles.push(rel);
336
+ }
337
+ } catch {
338
+ // ignore missing docs dir
339
+ }
340
+ }
341
+
342
+ const rootBuildCandidates = [
343
+ 'Makefile', 'CMakeLists.txt', 'package.json', 'tsconfig.json',
344
+ 'project.godot', 'export_presets.cfg', 'build.gradle', 'build.gradle.kts',
345
+ 'settings.gradle', 'settings.gradle.kts', 'Cargo.toml', 'pyproject.toml',
346
+ 'go.mod', 'pubspec.yaml', 'Dockerfile', 'docker-compose.yml', 'wrangler.toml'
347
+ ];
348
+ for (const rel of rootBuildCandidates) {
349
+ if (await existsFile(rel)) buildFiles.push(rel);
350
+ }
351
+
352
+ try {
353
+ const scriptEntries = await fs.readdir(path.join(dir, 'scripts'), { withFileTypes: true });
354
+ for (const entry of scriptEntries.sort((a, b) => a.name.localeCompare(b.name))) {
355
+ if (!entry.isFile() || entry.name.startsWith('.')) continue;
356
+ if (/\.(?:sh|bash|py|js|cjs|mjs|ts|ps1)$/i.test(entry.name)) {
357
+ const rel = `scripts/${entry.name}`;
358
+ if (!buildFiles.includes(rel) && buildFiles.length < 18) buildFiles.push(rel);
359
+ }
360
+ }
361
+ } catch {
362
+ // ignore missing scripts dir
363
+ }
364
+
365
+ const nestedCheckDirs = [...new Set([...subprojects, 'godot', 'android', 'app', 'mobile', 'desktop', 'server', 'backend', 'frontend', 'web'])];
366
+ for (const sub of nestedCheckDirs) {
367
+ if (sub.includes('..') || path.isAbsolute(sub)) continue;
368
+ const subBuildChecks: Array<{ rel: string; stack?: string }> = [
369
+ { rel: `${sub}/project.godot`, stack: `godot (gdscript) @ ${sub}/` },
370
+ { rel: `${sub}/export_presets.cfg` },
371
+ { rel: `${sub}/build.gradle.kts`, stack: `android (kotlin/gradle) @ ${sub}/` },
372
+ { rel: `${sub}/build.gradle`, stack: `android (gradle) @ ${sub}/` },
373
+ { rel: `${sub}/Cargo.toml`, stack: `rust @ ${sub}/` },
374
+ { rel: `${sub}/go.mod`, stack: `go @ ${sub}/` },
375
+ { rel: `${sub}/pyproject.toml`, stack: `python @ ${sub}/` },
376
+ { rel: `${sub}/package.json`, stack: `node @ ${sub}/` }
377
+ ];
378
+ for (const check of subBuildChecks) {
379
+ if (await existsFile(check.rel)) {
380
+ if (!buildFiles.includes(check.rel) && buildFiles.length < 22) buildFiles.push(check.rel);
381
+ if (check.stack && !subprojectStacks.includes(check.stack)) subprojectStacks.push(check.stack);
382
+ }
383
+ }
384
+ }
385
+
386
+ return { subprojectStacks, docFiles, buildFiles, topEntries };
387
+ }
388
+
269
389
  async detectKeyFiles(dir: string): Promise<string[]> {
270
390
  const candidateFiles = [
271
391
  'package.json', 'tsconfig.json', 'index.html', 'main.js',
@@ -358,6 +478,10 @@ export class WorkspacePerception {
358
478
  // ignore
359
479
  }
360
480
 
481
+ if (context.subprojectStacks?.some(s => s.startsWith('godot '))) {
482
+ return 'Godot Game Project';
483
+ }
484
+
361
485
  // Check directory name or key files for game patterns
362
486
  const baseName = path.basename(dir).toLowerCase();
363
487
  if (baseName.includes('game') || baseName.includes('pixel') || baseName.includes('arcade')) {
package/src/planCache.js CHANGED
@@ -81,6 +81,18 @@ const STOPWORDS = new Set([
81
81
  // deliberately NOT here: those DO separate tasks inside one archetype.
82
82
  'make', 'create', 'creating', 'made', 'generate'
83
83
  ]);
84
+ /** Generic noise/filler tokens that never uniquely identify a reusable multi-step procedure on their own. */
85
+ const LOW_SIGNAL_PLAN_WORDS = new Set([
86
+ 'fix', 'test', 'testing', 'check', 'run', 'build', 'update', 'change',
87
+ 'help', 'issue', 'bug', 'error', 'work', 'working', 'thing', 'file',
88
+ 'code', 'pleae', 'pls', 'plz', 'halp', 'hello', 'hey', 'thanks', 'thank',
89
+ 'okay', 'yes', 'none', 'something', 'anything', 'everything'
90
+ ]);
91
+ function hasSpecificPlanKeywords(keywords) {
92
+ if (keywords.length < 2)
93
+ return false;
94
+ return keywords.some((word) => !LOW_SIGNAL_PLAN_WORDS.has(word));
95
+ }
84
96
  // HONEST LIMIT. Matching is LEXICAL.
85
97
  // This path is deterministic, instant, and works on a machine with no embedding model
86
98
  // provisioned. Cortex is the semantic route and already carries embeddings;
@@ -517,7 +529,7 @@ export function failureClass(result) {
517
529
  export function lookupPlan(query) {
518
530
  const startedAt = performance.now();
519
531
  const keywords = extractKeywords(query?.prompt);
520
- if (keywords.length === 0) {
532
+ if (!hasSpecificPlanKeywords(keywords)) {
521
533
  recordLookupTelemetry({ hit: false, durationMs: performance.now() - startedAt });
522
534
  return null;
523
535
  }
@@ -530,7 +542,7 @@ export function lookupPlan(query) {
530
542
  }
531
543
  // Tier 1: Exact signature matching (O(1) hash index, Table 5 in APC paper)
532
544
  const exact = exactIndex.get(planSignature(archetype, keywords));
533
- if (exact) {
545
+ if (exact && hasSpecificPlanKeywords(exact.keywords)) {
534
546
  const durationMs = performance.now() - startedAt;
535
547
  recordLookupTelemetry({ hit: true, matchType: 'exact', durationMs });
536
548
  return {
@@ -559,6 +571,8 @@ export function lookupPlan(query) {
559
571
  // three words with "debug the build" is not a plan for it.
560
572
  if (archetype && template.archetype && template.archetype !== archetype)
561
573
  continue;
574
+ if (!hasSpecificPlanKeywords(template.keywords))
575
+ continue;
562
576
  const score = similarity(keywords, template.keywords);
563
577
  if (score < threshold)
564
578
  continue;
@@ -597,7 +611,7 @@ export function recordPlan(outcome) {
597
611
  if (steps.length < 2)
598
612
  return null;
599
613
  const keywords = extractKeywords(outcome?.prompt);
600
- if (keywords.length === 0)
614
+ if (!hasSpecificPlanKeywords(keywords))
601
615
  return null;
602
616
  const plans = readAll();
603
617
  const archetype = String(outcome?.archetype || '');
package/src/planCache.ts CHANGED
@@ -208,6 +208,19 @@ const STOPWORDS: ReadonlySet<string> = new Set([
208
208
  'make', 'create', 'creating', 'made', 'generate'
209
209
  ]);
210
210
 
211
+ /** Generic noise/filler tokens that never uniquely identify a reusable multi-step procedure on their own. */
212
+ const LOW_SIGNAL_PLAN_WORDS: ReadonlySet<string> = new Set([
213
+ 'fix', 'test', 'testing', 'check', 'run', 'build', 'update', 'change',
214
+ 'help', 'issue', 'bug', 'error', 'work', 'working', 'thing', 'file',
215
+ 'code', 'pleae', 'pls', 'plz', 'halp', 'hello', 'hey', 'thanks', 'thank',
216
+ 'okay', 'yes', 'none', 'something', 'anything', 'everything'
217
+ ]);
218
+
219
+ function hasSpecificPlanKeywords(keywords: readonly string[]): boolean {
220
+ if (keywords.length < 2) return false;
221
+ return keywords.some((word) => !LOW_SIGNAL_PLAN_WORDS.has(word));
222
+ }
223
+
211
224
  // HONEST LIMIT. Matching is LEXICAL.
212
225
  // This path is deterministic, instant, and works on a machine with no embedding model
213
226
  // provisioned. Cortex is the semantic route and already carries embeddings;
@@ -640,7 +653,7 @@ export function failureClass(result: unknown): PlanFailureClass | '' {
640
653
  export function lookupPlan(query: PlanLookupQuery | null | undefined): PlanMatch | null {
641
654
  const startedAt = performance.now();
642
655
  const keywords = extractKeywords(query?.prompt);
643
- if (keywords.length === 0) {
656
+ if (!hasSpecificPlanKeywords(keywords)) {
644
657
  recordLookupTelemetry({ hit: false, durationMs: performance.now() - startedAt });
645
658
  return null;
646
659
  }
@@ -655,7 +668,7 @@ export function lookupPlan(query: PlanLookupQuery | null | undefined): PlanMatch
655
668
 
656
669
  // Tier 1: Exact signature matching (O(1) hash index, Table 5 in APC paper)
657
670
  const exact = exactIndex.get(planSignature(archetype, keywords));
658
- if (exact) {
671
+ if (exact && hasSpecificPlanKeywords(exact.keywords)) {
659
672
  const durationMs = performance.now() - startedAt;
660
673
  recordLookupTelemetry({ hit: true, matchType: 'exact', durationMs });
661
674
  return {
@@ -687,6 +700,7 @@ export function lookupPlan(query: PlanLookupQuery | null | undefined): PlanMatch
687
700
  // Archetype is a hard gate, not a score. A "build a 3D scene" plan sharing
688
701
  // three words with "debug the build" is not a plan for it.
689
702
  if (archetype && template.archetype && template.archetype !== archetype) continue;
703
+ if (!hasSpecificPlanKeywords(template.keywords)) continue;
690
704
 
691
705
  const score = similarity(keywords, template.keywords);
692
706
  if (score < threshold) continue;
@@ -727,7 +741,7 @@ export function recordPlan(outcome: PlanRecordInput | null | undefined): PlanTem
727
741
  if (steps.length < 2) return null;
728
742
 
729
743
  const keywords = extractKeywords(outcome?.prompt);
730
- if (keywords.length === 0) return null;
744
+ if (!hasSpecificPlanKeywords(keywords)) return null;
731
745
 
732
746
  const plans = readAll();
733
747
  const archetype = String(outcome?.archetype || '');
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Authorship: Strict TypeScript (Causyne Agent).
9
9
  */
10
- import { PACK_PLAYBOOKS, isWebIntent } from './toolPacks.js';
10
+ import { PACK_PLAYBOOKS, isReverseEngineeringIntent, isWebIntent } from './toolPacks.js';
11
11
  import { isMutatingToolCall, isPureSkillOrCapabilityLookup, redactSkillAndQueryLiterals } from './decisionPolicy.js';
12
12
  const INSPECTION_TOOLS = new Set([
13
13
  'fs_read', 'fs_list', 'fs_find', 'fs_search', 'grep_search', 'code_searcher',
@@ -134,10 +134,9 @@ const EXPLICIT_MEDIA_GENERATION_PATTERN = /\b(blender|3d model|render 3d|render
134
134
  const EXPLICIT_WEB_ENGINEERING_PATTERN = /\b(build|create|make|design|develop|implement|redesign|buat\w*)\b[\s\S]*(?:\b(web|website|webpage|webapp|landing page|dashboard|ui|frontend|webgl|canvas|cad view|cad viewer|cad style view|3d view|3d viewer|3d configurator|3d visualizer)\b|(?:threejs|three\.js|thre\.?js|3js|babylon\.?js|pixi\.js|d3\.js|p5\.js|chart\.js)\b)/i;
135
135
  // Explicit game development intent
136
136
  const EXPLICIT_GAME_DEV_PATTERN = /(?:\b(?:build|create|make|design|develop|scaffold|render|animate|code|program|buat\w*|bikin\w*)[\s\S]*(?:game|simulation|simulator|simulasi|interactive|3d|three\.?js|threejs|webgl|canvas3d|babylonjs|godot|unity|unreal|platformer|rpg|arcade)\b|\b(?:game|gamedev|godot|unity|unreal|platformer|rpg|arcade|simulator|simulation|simulasi|interactive)\b|\b3d\s*(?:game|app|simulator|simulation|scene|city|world|view|body|human|anatomy|model|mesh|character|rendering|visualization|experience|space|environment)\b|\bin 3d\b|[-_]3d\b|\b3d[-_]|\b(?:threejs|three\.js|webgl|canvas3d|babylonjs)\b)/i;
137
- // Explicit reverse engineering and binary analysis intent
138
- const EXPLICIT_REVERSE_ENGINEERING_PATTERN = /\b(reverse[-_ ]?engineering|decompile|disassemble|disasm|apk|aab|dex|radare|rizin|ghidra|jadx|apktool|mach-o|elf binary|portable executable|\.apk\b|\.aab\b|\.dex\b|\.so\b|\.dylib\b|\.wasm\b|\.asar\b)\b/i;
137
+ // Explicit reverse engineering and binary analysis intent is defined in toolPacks.ts (isReverseEngineeringIntent).
139
138
  // Explicit software and systems engineering intent (backend, APIs, refactoring, algorithms, testing, architecture, CLI tools, Android/mobile)
140
- const EXPLICIT_SOFTWARE_ENGINEERING_PATTERN = /(?:\b(?:build|create|code|program|develop|refactor|debug|fix|implement|test|optimize|write|add|modify|migrate|architect|architecture|engineer|benchmark|profile|audit|scaffold)\b[\s\S]*\b(?:api|backend|service|microservice|server|database|schema|endpoint|controller|auth|test|spec|algorithm|function|module|class|feature|script|pipeline|codebase|repo|repository|bug|issue|engine|tool|cli|library|sdk|migration|handler|worker|queue|stream|app|application|compose|jetpack|android|gradle|package)\b|\b(?:python|rust|golang|c\+\+|cpp|java|kotlin|swift|csharp|typescript|javascript|ruby|php|sql|bash|shell|docker|k8s|kubernetes|gradle|compose|android)\b)/i;
139
+ const EXPLICIT_SOFTWARE_ENGINEERING_PATTERN = /(?:\b(?:build|create|code|program|develop|refactor|debug|fix|implement|test|optimize|write|add|modify|migrate|architect|architecture|engineer|benchmark|profile|audit|scaffold|bump|export)\b[\s\S]*\b(?:api|backend|service|microservice|server|database|schema|endpoint|controller|auth|test|spec|algorithm|function|module|class|feature|script|pipeline|codebase|repo|repository|bug|issue|engine|tool|cli|library|sdk|migration|handler|worker|queue|stream|app|application|compose|jetpack|android|gradle|package|apk|aab|bundle|version)\b|\b(?:python|rust|golang|c\+\+|cpp|java|kotlin|swift|csharp|typescript|javascript|ruby|php|sql|bash|shell|docker|k8s|kubernetes|gradle|compose|android|apk|aab)\b)/i;
141
140
  /**
142
141
  * Select tools to preload based on prompt intent. This is never an allowlist:
143
142
  * tool_search can add capabilities as the task develops.
@@ -165,7 +164,7 @@ export function determineToolScope(prompt, _taskShape) {
165
164
  }
166
165
  const effectiveText = redactSkillAndQueryLiterals(text);
167
166
  // 1. Reverse engineering & binary analysis intent
168
- if (EXPLICIT_REVERSE_ENGINEERING_PATTERN.test(effectiveText)) {
167
+ if (isReverseEngineeringIntent(effectiveText)) {
169
168
  const tools = new Set([
170
169
  'reverse_engineering',
171
170
  'fs_read',
@@ -8,7 +8,7 @@
8
8
  * Authorship: Strict TypeScript (Causyne Agent).
9
9
  */
10
10
 
11
- import { PACK_PLAYBOOKS, isWebIntent } from './toolPacks.js';
11
+ import { PACK_PLAYBOOKS, isReverseEngineeringIntent, isWebIntent } from './toolPacks.js';
12
12
  import {
13
13
  isMutatingToolCall,
14
14
  isPureSkillOrCapabilityLookup,
@@ -185,13 +185,11 @@ const EXPLICIT_WEB_ENGINEERING_PATTERN =
185
185
  const EXPLICIT_GAME_DEV_PATTERN =
186
186
  /(?:\b(?:build|create|make|design|develop|scaffold|render|animate|code|program|buat\w*|bikin\w*)[\s\S]*(?:game|simulation|simulator|simulasi|interactive|3d|three\.?js|threejs|webgl|canvas3d|babylonjs|godot|unity|unreal|platformer|rpg|arcade)\b|\b(?:game|gamedev|godot|unity|unreal|platformer|rpg|arcade|simulator|simulation|simulasi|interactive)\b|\b3d\s*(?:game|app|simulator|simulation|scene|city|world|view|body|human|anatomy|model|mesh|character|rendering|visualization|experience|space|environment)\b|\bin 3d\b|[-_]3d\b|\b3d[-_]|\b(?:threejs|three\.js|webgl|canvas3d|babylonjs)\b)/i;
187
187
 
188
- // Explicit reverse engineering and binary analysis intent
189
- const EXPLICIT_REVERSE_ENGINEERING_PATTERN =
190
- /\b(reverse[-_ ]?engineering|decompile|disassemble|disasm|apk|aab|dex|radare|rizin|ghidra|jadx|apktool|mach-o|elf binary|portable executable|\.apk\b|\.aab\b|\.dex\b|\.so\b|\.dylib\b|\.wasm\b|\.asar\b)\b/i;
188
+ // Explicit reverse engineering and binary analysis intent is defined in toolPacks.ts (isReverseEngineeringIntent).
191
189
 
192
190
  // Explicit software and systems engineering intent (backend, APIs, refactoring, algorithms, testing, architecture, CLI tools, Android/mobile)
193
191
  const EXPLICIT_SOFTWARE_ENGINEERING_PATTERN =
194
- /(?:\b(?:build|create|code|program|develop|refactor|debug|fix|implement|test|optimize|write|add|modify|migrate|architect|architecture|engineer|benchmark|profile|audit|scaffold)\b[\s\S]*\b(?:api|backend|service|microservice|server|database|schema|endpoint|controller|auth|test|spec|algorithm|function|module|class|feature|script|pipeline|codebase|repo|repository|bug|issue|engine|tool|cli|library|sdk|migration|handler|worker|queue|stream|app|application|compose|jetpack|android|gradle|package)\b|\b(?:python|rust|golang|c\+\+|cpp|java|kotlin|swift|csharp|typescript|javascript|ruby|php|sql|bash|shell|docker|k8s|kubernetes|gradle|compose|android)\b)/i;
192
+ /(?:\b(?:build|create|code|program|develop|refactor|debug|fix|implement|test|optimize|write|add|modify|migrate|architect|architecture|engineer|benchmark|profile|audit|scaffold|bump|export)\b[\s\S]*\b(?:api|backend|service|microservice|server|database|schema|endpoint|controller|auth|test|spec|algorithm|function|module|class|feature|script|pipeline|codebase|repo|repository|bug|issue|engine|tool|cli|library|sdk|migration|handler|worker|queue|stream|app|application|compose|jetpack|android|gradle|package|apk|aab|bundle|version)\b|\b(?:python|rust|golang|c\+\+|cpp|java|kotlin|swift|csharp|typescript|javascript|ruby|php|sql|bash|shell|docker|k8s|kubernetes|gradle|compose|android|apk|aab)\b)/i;
195
193
 
196
194
  /**
197
195
  * Select tools to preload based on prompt intent. This is never an allowlist:
@@ -226,7 +224,7 @@ export function determineToolScope(
226
224
  const effectiveText = redactSkillAndQueryLiterals(text);
227
225
 
228
226
  // 1. Reverse engineering & binary analysis intent
229
- if (EXPLICIT_REVERSE_ENGINEERING_PATTERN.test(effectiveText)) {
227
+ if (isReverseEngineeringIntent(effectiveText)) {
230
228
  const tools = new Set([
231
229
  'reverse_engineering',
232
230
  'fs_read',
package/src/taskShape.js CHANGED
@@ -85,6 +85,19 @@ const ARCHETYPES = {
85
85
  { name: 'Report', tools: [], note: 'Answer concisely and cite exact file paths or URLs. Do not modify anything unless asked.' }
86
86
  ]
87
87
  },
88
+ modify_repo: {
89
+ label: 'Inspect and update an existing project or build release artifact',
90
+ match: {
91
+ strong: ['bump', 'version code', 'version name', 'aab', 'apk', 'release', 'export', 'synchronize', 'sync', 'upgrade', 'migrate', 'rebuild'],
92
+ weak: ['version', 'bundle', 'existing', 'repo', 'repository', 'docs']
93
+ },
94
+ phases: [
95
+ { name: 'Orient in docs and structure', tools: ['fs_read', 'fs_list'], note: 'Read the workspace README, docs/ guides (e.g. ANDROID_RELEASE.md, ENGINEERING.md), and build scripts/manifests FIRST to follow the repository conventions.' },
96
+ { name: 'Apply targeted updates', tools: ['fs_read', 'fs_edit', 'MultiEdit'], note: 'Modify only the exact configuration, version fields, or source files required by the user request.' },
97
+ { name: 'Run documented build', tools: ['sysRun'], note: 'Execute the project’s documented build/export command for the requested deliverable only. Do not build unrelated web or side targets.' },
98
+ { name: 'Verify artifact', tools: ['sysRun', 'fs_read'], note: 'Verify the exact produced output (version, signature, alignment, tests) before reporting.' }
99
+ ]
100
+ },
88
101
  maintain: {
89
102
  label: 'Operate on files, processes or the machine itself',
90
103
  match: {
@@ -123,6 +136,12 @@ function scoreSignals(text, signals) {
123
136
  }
124
137
  return { score, hits };
125
138
  }
139
+ function isPureGreeting(prompt) {
140
+ const cleaned = String(prompt || '').trim().toLowerCase().replace(/[!?.]+$/g, '');
141
+ if (!cleaned)
142
+ return false;
143
+ return /^(?:hi+|hello+|hey+|yo+|sup|greetings|good\s+(?:morning|afternoon|evening)|thanks|thank\s+you|ok(?:ay)?)$/.test(cleaned);
144
+ }
126
145
  /**
127
146
  * Analyse a request into the shape of the work it implies.
128
147
  *
@@ -130,10 +149,12 @@ function scoreSignals(text, signals) {
130
149
  export function analyzeTask(prompt, workspaceContext = null) {
131
150
  const rawPrompt = String(prompt || '');
132
151
  const pureSkillLookup = isPureSkillOrCapabilityLookup(rawPrompt);
152
+ const pureGreeting = !pureSkillLookup && isPureGreeting(rawPrompt);
153
+ const lightweightLookup = pureSkillLookup || pureGreeting;
133
154
  const text = (pureSkillLookup ? redactSkillAndQueryLiterals(rawPrompt) : rawPrompt).toLowerCase();
134
155
  // Which capability packs are worth their token cost for this request.
135
156
  const packScores = [];
136
- if (!pureSkillLookup) {
157
+ if (!lightweightLookup) {
137
158
  for (const packName of Object.keys(PACK_SIGNALS)) {
138
159
  const signals = PACK_SIGNALS[packName];
139
160
  if (!signals)
@@ -147,12 +168,14 @@ export function analyzeTask(prompt, workspaceContext = null) {
147
168
  // Workspace evidence outranks keywords: a Godot project on disk is far more
148
169
  // reliable than any phrasing in the prompt. Pure skill/capability lookups
149
170
  // stay lightweight and never preload workspace app packs.
150
- if (workspaceContext && !pureSkillLookup) {
171
+ if (workspaceContext && !lightweightLookup) {
151
172
  const signals = [
152
173
  workspaceContext.framework,
153
174
  workspaceContext.projectType,
154
175
  workspaceContext.designSystem,
155
- Array.isArray(workspaceContext.keyFiles) ? workspaceContext.keyFiles.join(' ') : ''
176
+ Array.isArray(workspaceContext.keyFiles) ? workspaceContext.keyFiles.join(' ') : '',
177
+ Array.isArray(workspaceContext.subprojectStacks) ? workspaceContext.subprojectStacks.join(' ') : '',
178
+ Array.isArray(workspaceContext.buildFiles) ? workspaceContext.buildFiles.join(' ') : ''
156
179
  ].filter(Boolean).join(' ').toLowerCase();
157
180
  const bump = (name, amount) => {
158
181
  const existing = packScores.find(p => p.name === name);
@@ -161,10 +184,15 @@ export function analyzeTask(prompt, workspaceContext = null) {
161
184
  else
162
185
  packScores.push({ name, score: amount });
163
186
  };
164
- if (/godot|project\.godot|unity|\.tscn/.test(signals))
187
+ const hasGameProject = /godot|project\.godot|unity|\.tscn/.test(signals);
188
+ const hasExplicitWebFramework = /\b(react|vue|svelte|next|nuxt|astro|angular|tailwind|vite)\b/.test(signals);
189
+ const explicitNonWebTarget = /\b(aab|apk|gradle|android|godot|export_presets|tscn|gdscript|xcode|ipa|ios|rust|cargo)\b/.test(text);
190
+ const hasPromptWebSignal = /\b(web|website|html|css|browser|frontend|page|ui|dom|react|vue|svelte|vite|next|playwright|lighthouse|localhost)\b/.test(text);
191
+ if (hasGameProject)
165
192
  bump('game', 5);
166
- if (/react|vue|svelte|next|nuxt|astro|angular|tailwind|vite|index\.html/.test(signals))
193
+ if (!explicitNonWebTarget && (hasExplicitWebFramework || (!hasGameProject && /index\.html/.test(signals)) || (hasGameProject && /index\.html/.test(signals) && hasPromptWebSignal))) {
167
194
  bump('web', 4);
195
+ }
168
196
  }
169
197
  packScores.sort((a, b) => b.score - a.score);
170
198
  // Which archetype the work follows.
@@ -191,11 +219,25 @@ export function analyzeTask(prompt, workspaceContext = null) {
191
219
  bestArchetype = 'integrate';
192
220
  bestScore = integrationScore;
193
221
  }
194
- if (pureSkillLookup) {
222
+ const hasExistingRepo = Boolean(workspaceContext && ((Array.isArray(workspaceContext.keyFiles) && workspaceContext.keyFiles.length > 0)
223
+ || (Array.isArray(workspaceContext.buildFiles) && workspaceContext.buildFiles.length > 0)
224
+ || (Array.isArray(workspaceContext.docFiles) && workspaceContext.docFiles.length > 0)
225
+ || (Array.isArray(workspaceContext.subprojectStacks) && workspaceContext.subprojectStacks.length > 0)
226
+ || (workspaceContext.framework && !/^(?:none|unknown)$/i.test(String(workspaceContext.framework)))
227
+ || (workspaceContext.projectType && !/^(?:none|unknown)$/i.test(String(workspaceContext.projectType)))));
228
+ const explicitGreenfield = /\b(?:from\s+scratch|new\s+app(?:lication)?|new\s+project|greenfield|scaffold)\b/.test(text);
229
+ const explicitRepoReleaseOrModify = /\b(?:aab|apk|gradle|android|release|bump|versioncode|version|export|rebuild|update|upgrade|modify|extend|add\s+feature|existing|script)\b/.test(text);
230
+ if (!lightweightLookup && hasExistingRepo && (bestArchetype === 'build_app' || !bestArchetype) && !explicitGreenfield) {
231
+ if (bestArchetype !== 'build_app' || explicitRepoReleaseOrModify) {
232
+ bestArchetype = 'modify_repo';
233
+ bestScore = Math.max(bestScore, STRONG_WEIGHT);
234
+ }
235
+ }
236
+ if (lightweightLookup) {
195
237
  bestArchetype = 'research';
196
238
  bestScore = Math.max(bestScore, STRONG_WEIGHT);
197
239
  }
198
- const archetype = bestArchetype || 'build_app';
240
+ const archetype = bestArchetype || (hasExistingRepo ? 'modify_repo' : 'build_app');
199
241
  const confidence = bestScore >= 6 ? 'high' : (bestScore >= 3 ? 'medium' : 'low');
200
242
  const definition = ARCHETYPES[archetype];
201
243
  if (!definition)