@causyne/agent 1.20.116 → 1.20.118
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/package.json +7 -2
- package/src/agentLoop.js +81 -31
- package/src/agentLoop.ts +82 -33
- package/src/browser/causyneBrowser.js +30 -7
- package/src/browser/causyneBrowser.ts +29 -7
- package/src/cliMode.js +24 -4
- package/src/commands.js +7 -1
- package/src/memory/scopedFacts.js +171 -0
- package/src/memory/scopedFacts.ts +214 -0
- package/src/memory.d.ts +13 -1
- package/src/memory.js +9 -12
- package/src/perception.js +124 -3
- package/src/perception.ts +128 -4
- package/src/planCache.js +17 -3
- package/src/planCache.ts +17 -3
- package/src/plugins/pluginManager.js +74 -0
- package/src/reporting.js +12 -4
- package/src/skillsManager.js +3 -2
- package/src/skillsManager.ts +3 -2
- package/src/smartToolsUse.js +4 -5
- package/src/smartToolsUse.ts +4 -6
- package/src/taskShape.js +49 -7
- package/src/taskShape.ts +55 -7
- package/src/toolPacks.js +27 -5
- package/src/toolPacks.ts +32 -5
- package/src/tools/memoryWrite.js +8 -10
- package/src/tools/memoryWrite.ts +13 -11
- package/src/tools/pluginManager.js +17 -2
- package/src/tui/chatRenderer.js +4 -1
- package/src/tui/codeProgress.js +3 -2
- package/src/tui/codeProgress.ts +3 -2
- package/src/tui/codeStreamRenderer.js +41 -15
- package/src/tui/codeStreamRenderer.ts +40 -15
- package/src/tui/composerControls.js +16 -3
- package/src/tui/composerControls.ts +14 -3
- package/src/tui/keys.js +3 -1
- package/src/tui/prompt.js +146 -16
- package/src/tui/scrollInteraction.js +2 -2
- package/src/tui/scrollInteraction.ts +2 -2
- package/src/tui/stageSurface.js +114 -4
- package/src/tui/turnRail.js +21 -14
- package/src/tui/turnRail.ts +19 -14
- package/src/tui/usageCard.js +164 -71
- package/src/tui/usageCard.ts +187 -96
- package/src/tui/workspaceSwitch.js +2 -0
- package/src/tui/workspaceSwitch.ts +1 -0
- package/src/types/contracts.ts +3 -0
- package/src/verification/boundedExplorer.js +119 -0
- package/src/verification/cliProbe.js +116 -0
- package/src/verification/featureMap.js +78 -0
- package/src/verification/interactivePty.js +188 -0
- package/src/verification/propertyProbe.js +121 -0
- package/src/verification/ptyProbe.js +125 -0
- package/src/verification/skillCatalog.d.ts +1 -0
- package/src/verification/skillCatalog.js +60 -0
- package/src/verification/statechart.js +143 -0
- package/src/verification/uiRuntime.js +57 -0
- package/src/verificationPlan.js +1 -1
- package/src/verificationPlan.ts +1 -1
package/src/memory.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
3
|
import { causyneHome } from './utils/paths.js';
|
|
4
|
+
import { formatMemoryContext, normalizeMemoryData, recordScopedFact } from './memory/scopedFacts.js';
|
|
5
5
|
|
|
6
6
|
const MEMORY_FILE_PATH = path.join(causyneHome(), 'memory.json');
|
|
7
7
|
|
|
@@ -20,7 +20,7 @@ export function getMemory() {
|
|
|
20
20
|
try {
|
|
21
21
|
initMemory();
|
|
22
22
|
const data = fs.readFileSync(MEMORY_FILE_PATH, 'utf-8');
|
|
23
|
-
return JSON.parse(data);
|
|
23
|
+
return normalizeMemoryData(JSON.parse(data));
|
|
24
24
|
} catch (e) {
|
|
25
25
|
console.error("Failed to read memory.json:", e.message);
|
|
26
26
|
return { facts: [] };
|
|
@@ -36,27 +36,24 @@ export function saveMemory(data) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export function addFact(factStr) {
|
|
39
|
+
export function addFact(factStr, options = {}) {
|
|
40
40
|
const mem = getMemory();
|
|
41
|
-
|
|
42
|
-
if (!
|
|
43
|
-
|
|
44
|
-
saveMemory(mem);
|
|
41
|
+
const { memory, alreadyKnown } = recordScopedFact(mem, factStr, options);
|
|
42
|
+
if (!alreadyKnown || options.workspace) {
|
|
43
|
+
saveMemory(memory);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
export function clearMemory() {
|
|
49
48
|
try {
|
|
50
49
|
initMemory();
|
|
51
|
-
fs.writeFileSync(MEMORY_FILE_PATH, JSON.stringify({ facts: [] }, null, 2));
|
|
50
|
+
fs.writeFileSync(MEMORY_FILE_PATH, JSON.stringify({ facts: [], entries: [] }, null, 2));
|
|
52
51
|
} catch (e) {
|
|
53
52
|
console.error("Failed to clear memory:", e.message);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
export function getMemoryContextString() {
|
|
56
|
+
export function getMemoryContextString(options = undefined) {
|
|
58
57
|
const mem = getMemory();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return mem.facts.map((fact, index) => `${index + 1}. ${fact}`).join("\n");
|
|
58
|
+
return formatMemoryContext(mem, options);
|
|
62
59
|
}
|
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
|
|
33
|
+
// 2c. Subprojects & nested stacks discovery
|
|
34
34
|
context.subprojects = await this.detectSubprojects(resolvedPath);
|
|
35
|
-
|
|
36
|
-
context.
|
|
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
|
|
89
|
+
// 2c. Subprojects & nested stacks discovery
|
|
86
90
|
context.subprojects = await this.detectSubprojects(resolvedPath);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
context.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
744
|
+
if (!hasSpecificPlanKeywords(keywords)) return null;
|
|
731
745
|
|
|
732
746
|
const plans = readAll();
|
|
733
747
|
const archetype = String(outcome?.archetype || '');
|
|
@@ -304,6 +304,80 @@ export function createPlugin({ name, description, toolName, toolDescription, par
|
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
|
|
308
|
+
export function createSkillPlugin({
|
|
309
|
+
name, description, skillId, skillName, skillDescription, skillContent, licenseText
|
|
310
|
+
} = {}) {
|
|
311
|
+
if (!NAME.test(name || '')) return { ok: false, error: 'Invalid plugin name' };
|
|
312
|
+
if (!NAME.test(skillId || '')) return { ok: false, error: 'Invalid skill id' };
|
|
313
|
+
if (typeof description !== 'string' || !description.trim() || description.length > 1000) {
|
|
314
|
+
return { ok: false, error: 'Plugin description must be 1..1000 characters' };
|
|
315
|
+
}
|
|
316
|
+
if (typeof skillName !== 'string' || !skillName.trim() || skillName.length > 120) {
|
|
317
|
+
return { ok: false, error: 'Skill name must be 1..120 characters' };
|
|
318
|
+
}
|
|
319
|
+
if (typeof skillDescription !== 'string' || !skillDescription.trim()
|
|
320
|
+
|| skillDescription.length > 400) {
|
|
321
|
+
return { ok: false, error: 'Skill description must be 1..400 characters' };
|
|
322
|
+
}
|
|
323
|
+
if (typeof skillContent !== 'string' || !skillContent.trim()
|
|
324
|
+
|| Buffer.byteLength(skillContent, 'utf8') > 32 * 1024) {
|
|
325
|
+
return { ok: false, error: 'Skill content must be nonempty and at most 32 KB' };
|
|
326
|
+
}
|
|
327
|
+
if (typeof licenseText !== 'string' || licenseText.length > 32 * 1024) {
|
|
328
|
+
return { ok: false, error: 'Full third-party license text is required' };
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const isMit = /^MIT License\s*$/mi.test(licenseText)
|
|
332
|
+
&& /Permission is hereby granted, free of charge/i.test(licenseText)
|
|
333
|
+
&& /above copyright notice/i.test(licenseText);
|
|
334
|
+
const isApache = /Apache License\s*Version 2\.0/i.test(licenseText)
|
|
335
|
+
&& /TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION/i.test(licenseText);
|
|
336
|
+
if (!isMit && !isApache) {
|
|
337
|
+
return { ok: false, error: 'Only reviewed MIT or Apache-2.0 license text is accepted' };
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const manifest = {
|
|
341
|
+
schemaVersion: 1, name, version: '0.1.0', description: description.trim(),
|
|
342
|
+
capabilities: [], tools: [],
|
|
343
|
+
skills: [{
|
|
344
|
+
id: skillId, name: skillName.trim(),
|
|
345
|
+
description: skillDescription.trim(), file: 'SKILL.md'
|
|
346
|
+
}]
|
|
347
|
+
};
|
|
348
|
+
ensureRoot();
|
|
349
|
+
const directory = path.join(PLUGIN_ROOT, name);
|
|
350
|
+
if (fs.existsSync(directory)) return { ok: false, error: 'Plugin already exists' };
|
|
351
|
+
let created = false;
|
|
352
|
+
try {
|
|
353
|
+
fs.mkdirSync(directory, { mode: 0o700 });
|
|
354
|
+
created = true;
|
|
355
|
+
fs.writeFileSync(path.join(directory, 'SKILL.md'), skillContent, {
|
|
356
|
+
mode: 0o600, flag: 'wx'
|
|
357
|
+
});
|
|
358
|
+
fs.writeFileSync(path.join(directory, 'LICENSE'), licenseText, {
|
|
359
|
+
mode: 0o600, flag: 'wx'
|
|
360
|
+
});
|
|
361
|
+
fs.writeFileSync(path.join(directory, 'plugin.json'),
|
|
362
|
+
JSON.stringify(manifest, null, 2) + '\n', {
|
|
363
|
+
mode: 0o600, flag: 'wx'
|
|
364
|
+
});
|
|
365
|
+
const reviewed = readPlugin(directory);
|
|
366
|
+
return {
|
|
367
|
+
ok: true, name, enabled: false, tools: [],
|
|
368
|
+
skills: reviewed.skills.map(entry => entry.domain + '/' + entry.id),
|
|
369
|
+
license: isMit ? 'MIT' : 'Apache-2.0',
|
|
370
|
+
digest: reviewed.digest, path: directory,
|
|
371
|
+
message: 'Skill packaged disabled. Review its instructions and license before explicit enablement.'
|
|
372
|
+
};
|
|
373
|
+
} catch (error) {
|
|
374
|
+
if (created) {
|
|
375
|
+
try { fs.rmSync(directory, { recursive: true, force: true }); } catch {}
|
|
376
|
+
}
|
|
377
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
307
381
|
function enabledTools() {
|
|
308
382
|
const state = readState();
|
|
309
383
|
const tools = [];
|
package/src/reporting.js
CHANGED
|
@@ -339,20 +339,28 @@ export function formatUptime(ms) {
|
|
|
339
339
|
*/
|
|
340
340
|
export function buildStatusText({ loop = null } = {}) {
|
|
341
341
|
const config = loadConfig();
|
|
342
|
+
const liveConfig = loop?.config || {};
|
|
343
|
+
const provider = liveConfig.provider || config.provider || 'default';
|
|
344
|
+
const model = liveConfig.model || config.model || 'default';
|
|
345
|
+
const autonomyMode = liveConfig.autonomyMode || config.autonomyMode || 'C';
|
|
346
|
+
const tier = liveConfig.tier || config.tier || 'premium';
|
|
342
347
|
const lines = ['Status'];
|
|
343
348
|
|
|
344
349
|
lines.push(' Runtime : local desktop');
|
|
345
350
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
351
|
+
if (loop?.memoryManager?.sessionId) {
|
|
352
|
+
lines.push(` Session : ${loop.memoryManager.sessionId}`);
|
|
353
|
+
}
|
|
354
|
+
lines.push(` Provider / model : ${provider} / ${model}`);
|
|
355
|
+
lines.push(` Autonomy mode : ${autonomyMode}`);
|
|
356
|
+
lines.push(` Tier : ${tier}`);
|
|
349
357
|
|
|
350
358
|
if (loop && loop.sandbox) {
|
|
351
359
|
const sandbox = loop.sandbox;
|
|
352
360
|
lines.push(` Workspace scope : ${sandbox.grantAllAccess ? 'ALL ACCESS' : (sandbox.workspacePaths || []).join(', ')}`);
|
|
353
361
|
}
|
|
354
362
|
|
|
355
|
-
if (!
|
|
363
|
+
if (!liveConfig.apiKey && !config.apiKey && provider !== 'ollama' && !isAcpProvider(provider) && !isAntigravityProvider(provider)) {
|
|
356
364
|
lines.push('');
|
|
357
365
|
lines.push(' No API key is set. Run `causyne config`.');
|
|
358
366
|
}
|
package/src/skillsManager.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { COMPILED_SKILLS } from './compiledSkills.js';
|
|
4
|
+
import { VERIFICATION_SKILLS } from './verification/skillCatalog.js';
|
|
4
5
|
import { loadUserSkills } from './userSkills.js';
|
|
5
6
|
import { getPluginSkills } from './plugins/pluginManager.js';
|
|
6
|
-
const compiledSkillsCatalog = COMPILED_SKILLS;
|
|
7
|
+
const compiledSkillsCatalog = { ...COMPILED_SKILLS, verification: VERIFICATION_SKILLS };
|
|
7
8
|
// User skills are read from disk, and the disk is slow relative to how often
|
|
8
9
|
// these functions are called (every completion keystroke asks for the
|
|
9
10
|
// catalogue). Cache for a moment so typing stays instant, but keep the window
|
|
@@ -80,7 +81,7 @@ const DOMAIN_INDICATORS = {
|
|
|
80
81
|
// Design and security are not properties of a file layout — an agent writing a
|
|
81
82
|
// UI needs the anti-slop direction whether or not a tailwind config exists, and
|
|
82
83
|
// input validation matters whether or not the repository has a SECURITY.md.
|
|
83
|
-
const UNIVERSAL_DOMAINS = ['design', 'security'];
|
|
84
|
+
const UNIVERSAL_DOMAINS = ['design', 'security', 'verification'];
|
|
84
85
|
// Ceiling on how many skill descriptions may enter the system prompt.
|
|
85
86
|
//
|
|
86
87
|
// With 100 skills, injecting every description of every detected domain would
|
package/src/skillsManager.ts
CHANGED
|
@@ -2,6 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
import { COMPILED_SKILLS } from './compiledSkills.js';
|
|
5
|
+
import { VERIFICATION_SKILLS } from './verification/skillCatalog.js';
|
|
5
6
|
import { loadUserSkills, type UserSkill } from './userSkills.js';
|
|
6
7
|
import { getPluginSkills } from './plugins/pluginManager.js';
|
|
7
8
|
|
|
@@ -19,7 +20,7 @@ interface CompiledSkillItem {
|
|
|
19
20
|
content: string;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
const compiledSkillsCatalog = COMPILED_SKILLS as unknown as Record<string, Record<string, CompiledSkillItem>>;
|
|
23
|
+
const compiledSkillsCatalog = { ...COMPILED_SKILLS, verification: VERIFICATION_SKILLS } as unknown as Record<string, Record<string, CompiledSkillItem>>;
|
|
23
24
|
|
|
24
25
|
// User skills are read from disk, and the disk is slow relative to how often
|
|
25
26
|
// these functions are called (every completion keystroke asks for the
|
|
@@ -100,7 +101,7 @@ const DOMAIN_INDICATORS: Record<string, string[]> = {
|
|
|
100
101
|
// Design and security are not properties of a file layout — an agent writing a
|
|
101
102
|
// UI needs the anti-slop direction whether or not a tailwind config exists, and
|
|
102
103
|
// input validation matters whether or not the repository has a SECURITY.md.
|
|
103
|
-
const UNIVERSAL_DOMAINS = ['design', 'security'];
|
|
104
|
+
const UNIVERSAL_DOMAINS = ['design', 'security', 'verification'];
|
|
104
105
|
|
|
105
106
|
// Ceiling on how many skill descriptions may enter the system prompt.
|
|
106
107
|
//
|