@miller-tech/uap 1.10.0 → 1.11.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/benchmarks/benchmark.d.ts +14 -14
- package/dist/bin/cli.js +5 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/bin/llama-server-optimize.js +0 -0
- package/dist/bin/policy.js +0 -0
- package/dist/cli/task.d.ts +1 -1
- package/dist/cli/task.d.ts.map +1 -1
- package/dist/cli/task.js +65 -0
- package/dist/cli/task.js.map +1 -1
- package/dist/dashboard/data-service.d.ts +10 -0
- package/dist/dashboard/data-service.d.ts.map +1 -1
- package/dist/dashboard/data-service.js +22 -1
- package/dist/dashboard/data-service.js.map +1 -1
- package/dist/dashboard/server.d.ts.map +1 -1
- package/dist/dashboard/server.js +51 -5
- package/dist/dashboard/server.js.map +1 -1
- package/dist/models/profile-loader.d.ts +1 -1
- package/dist/models/types.d.ts +45 -45
- package/dist/policies/schemas/policy.d.ts +5 -5
- package/dist/tasks/types.d.ts +22 -22
- package/dist/types/config.d.ts +170 -170
- package/dist/types/coordination.d.ts +22 -22
- package/dist/uap-droids-strict.d.ts +4 -4
- package/package.json +1 -1
- package/scripts/maintenance/verify-compliance.sh +12 -12
- package/templates/hooks/session-start.sh +1 -1
- package/dist/bin/tool-calls.d.ts +0 -3
- package/dist/bin/tool-calls.d.ts.map +0 -1
- package/dist/bin/tool-calls.js +0 -4
- package/dist/bin/tool-calls.js.map +0 -1
- package/dist/cli/completion-gates.d.ts +0 -51
- package/dist/cli/completion-gates.d.ts.map +0 -1
- package/dist/cli/completion-gates.js +0 -201
- package/dist/cli/completion-gates.js.map +0 -1
- package/dist/cli/rtk-validation.d.ts +0 -24
- package/dist/cli/rtk-validation.d.ts.map +0 -1
- package/dist/cli/rtk-validation.js +0 -138
- package/dist/cli/rtk-validation.js.map +0 -1
- package/dist/cli/uap.d.ts +0 -10
- package/dist/cli/uap.d.ts.map +0 -1
- package/dist/cli/uap.js +0 -457
- package/dist/cli/uap.js.map +0 -1
- package/dist/coordination/droid-validator.d.ts +0 -59
- package/dist/coordination/droid-validator.d.ts.map +0 -1
- package/dist/coordination/droid-validator.js +0 -142
- package/dist/coordination/droid-validator.js.map +0 -1
- package/dist/coordination/worktree-enforcer.d.ts +0 -22
- package/dist/coordination/worktree-enforcer.d.ts.map +0 -1
- package/dist/coordination/worktree-enforcer.js +0 -71
- package/dist/coordination/worktree-enforcer.js.map +0 -1
- package/dist/generators/template-loader.d.ts +0 -105
- package/dist/generators/template-loader.d.ts.map +0 -1
- package/dist/generators/template-loader.js +0 -291
- package/dist/generators/template-loader.js.map +0 -1
- package/dist/memory/active-context.d.ts +0 -65
- package/dist/memory/active-context.d.ts.map +0 -1
- package/dist/memory/active-context.js +0 -126
- package/dist/memory/active-context.js.map +0 -1
- package/dist/memory/agent-scoped-memory.d.ts +0 -67
- package/dist/memory/agent-scoped-memory.d.ts.map +0 -1
- package/dist/memory/agent-scoped-memory.js +0 -126
- package/dist/memory/agent-scoped-memory.js.map +0 -1
- package/dist/memory/dedup-detector.d.ts +0 -57
- package/dist/memory/dedup-detector.d.ts.map +0 -1
- package/dist/memory/dedup-detector.js +0 -107
- package/dist/memory/dedup-detector.js.map +0 -1
- package/dist/memory/dedup-memory.d.ts +0 -89
- package/dist/memory/dedup-memory.d.ts.map +0 -1
- package/dist/memory/dedup-memory.js +0 -173
- package/dist/memory/dedup-memory.js.map +0 -1
- package/dist/memory/generic-uap-patterns.d.ts +0 -7
- package/dist/memory/generic-uap-patterns.d.ts.map +0 -1
- package/dist/memory/generic-uap-patterns.js +0 -43
- package/dist/memory/generic-uap-patterns.js.map +0 -1
- package/dist/memory/merge-claude-md.d.ts +0 -45
- package/dist/memory/merge-claude-md.d.ts.map +0 -1
- package/dist/memory/merge-claude-md.js +0 -118
- package/dist/memory/merge-claude-md.js.map +0 -1
- package/dist/memory/multi-view-memory.d.ts +0 -134
- package/dist/memory/multi-view-memory.d.ts.map +0 -1
- package/dist/memory/multi-view-memory.js +0 -430
- package/dist/memory/multi-view-memory.js.map +0 -1
- package/dist/memory/patterns.d.ts +0 -37
- package/dist/memory/patterns.d.ts.map +0 -1
- package/dist/memory/patterns.js +0 -81
- package/dist/memory/patterns.js.map +0 -1
- package/dist/memory/semantic-edge-graph.d.ts +0 -86
- package/dist/memory/semantic-edge-graph.d.ts.map +0 -1
- package/dist/memory/semantic-edge-graph.js +0 -168
- package/dist/memory/semantic-edge-graph.js.map +0 -1
- package/dist/memory/semantic-retrieval.d.ts +0 -70
- package/dist/memory/semantic-retrieval.d.ts.map +0 -1
- package/dist/memory/semantic-retrieval.js +0 -112
- package/dist/memory/semantic-retrieval.js.map +0 -1
- package/dist/memory/short-term/factory.d.ts +0 -26
- package/dist/memory/short-term/factory.d.ts.map +0 -1
- package/dist/memory/short-term/factory.js +0 -28
- package/dist/memory/short-term/factory.js.map +0 -1
- package/dist/memory/short-term/indexeddb.d.ts +0 -25
- package/dist/memory/short-term/indexeddb.d.ts.map +0 -1
- package/dist/memory/short-term/indexeddb.js +0 -64
- package/dist/memory/short-term/indexeddb.js.map +0 -1
- package/dist/memory/smart-consolidator.d.ts +0 -53
- package/dist/memory/smart-consolidator.d.ts.map +0 -1
- package/dist/memory/smart-consolidator.js +0 -144
- package/dist/memory/smart-consolidator.js.map +0 -1
- package/dist/memory/view-memory.d.ts +0 -80
- package/dist/memory/view-memory.d.ts.map +0 -1
- package/dist/memory/view-memory.js +0 -130
- package/dist/memory/view-memory.js.map +0 -1
- package/dist/memory/wrapped-memory.d.ts +0 -77
- package/dist/memory/wrapped-memory.d.ts.map +0 -1
- package/dist/memory/wrapped-memory.js +0 -127
- package/dist/memory/wrapped-memory.js.map +0 -1
- package/dist/models/api-client.d.ts +0 -46
- package/dist/models/api-client.d.ts.map +0 -1
- package/dist/models/api-client.js +0 -182
- package/dist/models/api-client.js.map +0 -1
- package/dist/utils/config-manager.d.ts +0 -30
- package/dist/utils/config-manager.d.ts.map +0 -1
- package/dist/utils/config-manager.js +0 -41
- package/dist/utils/config-manager.js.map +0 -1
- package/dist/utils/fetch-with-retry.d.ts +0 -5
- package/dist/utils/fetch-with-retry.d.ts.map +0 -1
- package/dist/utils/fetch-with-retry.js +0 -61
- package/dist/utils/fetch-with-retry.js.map +0 -1
- package/dist/utils/file-discovery.d.ts +0 -38
- package/dist/utils/file-discovery.d.ts.map +0 -1
- package/dist/utils/file-discovery.js +0 -100
- package/dist/utils/file-discovery.js.map +0 -1
- package/dist/utils/validate-json.d.ts +0 -51
- package/dist/utils/validate-json.d.ts.map +0 -1
- package/dist/utils/validate-json.js +0 -94
- package/dist/utils/validate-json.js.map +0 -1
- package/tools/agents/scripts/__pycache__/tool_call_wrapper.cpython-313.pyc +0 -0
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-Agent Workspace Isolation
|
|
3
|
-
*
|
|
4
|
-
* Each registered agent gets its own working memory partition within the
|
|
5
|
-
* shared SQLite database. Agent-specific context stays isolated; shared
|
|
6
|
-
* memories require explicit cross-agent promotion.
|
|
7
|
-
*
|
|
8
|
-
* Inspired by Clawe's per-agent isolated workspaces.
|
|
9
|
-
*/
|
|
10
|
-
import Database from 'better-sqlite3';
|
|
11
|
-
import { existsSync, mkdirSync } from 'fs';
|
|
12
|
-
import { dirname } from 'path';
|
|
13
|
-
/**
|
|
14
|
-
* Ensure the agent-scoped memory table exists.
|
|
15
|
-
*/
|
|
16
|
-
export function ensureAgentScopedSchema(db) {
|
|
17
|
-
db.exec(`
|
|
18
|
-
CREATE TABLE IF NOT EXISTS agent_memories (
|
|
19
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
20
|
-
agent_id TEXT NOT NULL,
|
|
21
|
-
timestamp TEXT NOT NULL,
|
|
22
|
-
type TEXT NOT NULL DEFAULT 'observation',
|
|
23
|
-
content TEXT NOT NULL,
|
|
24
|
-
importance INTEGER NOT NULL DEFAULT 5,
|
|
25
|
-
shared INTEGER NOT NULL DEFAULT 0
|
|
26
|
-
);
|
|
27
|
-
CREATE INDEX IF NOT EXISTS idx_agent_mem_agent ON agent_memories(agent_id);
|
|
28
|
-
CREATE INDEX IF NOT EXISTS idx_agent_mem_shared ON agent_memories(shared);
|
|
29
|
-
CREATE INDEX IF NOT EXISTS idx_agent_mem_importance ON agent_memories(agent_id, importance DESC);
|
|
30
|
-
`);
|
|
31
|
-
}
|
|
32
|
-
export class AgentScopedMemory {
|
|
33
|
-
db;
|
|
34
|
-
constructor(dbPath) {
|
|
35
|
-
const dir = dirname(dbPath);
|
|
36
|
-
if (!existsSync(dir)) {
|
|
37
|
-
mkdirSync(dir, { recursive: true });
|
|
38
|
-
}
|
|
39
|
-
this.db = new Database(dbPath);
|
|
40
|
-
ensureAgentScopedSchema(this.db);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Store a memory scoped to a specific agent.
|
|
44
|
-
*/
|
|
45
|
-
store(agentId, content, type = 'observation', importance = 5) {
|
|
46
|
-
const stmt = this.db.prepare(`
|
|
47
|
-
INSERT INTO agent_memories (agent_id, timestamp, type, content, importance)
|
|
48
|
-
VALUES (?, ?, ?, ?, ?)
|
|
49
|
-
`);
|
|
50
|
-
const result = stmt.run(agentId, new Date().toISOString(), type, content, importance);
|
|
51
|
-
return Number(result.lastInsertRowid);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Query memories for a specific agent (includes shared memories).
|
|
55
|
-
*/
|
|
56
|
-
query(agentId, search, limit = 10) {
|
|
57
|
-
const stmt = this.db.prepare(`
|
|
58
|
-
SELECT id, agent_id as agentId, timestamp, type, content, importance, shared
|
|
59
|
-
FROM agent_memories
|
|
60
|
-
WHERE (agent_id = ? OR shared = 1) AND content LIKE ?
|
|
61
|
-
ORDER BY importance DESC, id DESC
|
|
62
|
-
LIMIT ?
|
|
63
|
-
`);
|
|
64
|
-
return stmt.all(agentId, `%${search}%`, limit);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get all memories for a specific agent (includes shared).
|
|
68
|
-
*/
|
|
69
|
-
getForAgent(agentId, limit = 50) {
|
|
70
|
-
const stmt = this.db.prepare(`
|
|
71
|
-
SELECT id, agent_id as agentId, timestamp, type, content, importance, shared
|
|
72
|
-
FROM agent_memories
|
|
73
|
-
WHERE agent_id = ? OR shared = 1
|
|
74
|
-
ORDER BY id DESC
|
|
75
|
-
LIMIT ?
|
|
76
|
-
`);
|
|
77
|
-
return stmt.all(agentId, limit);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Promote a memory to shared (visible to all agents).
|
|
81
|
-
*/
|
|
82
|
-
share(entryId) {
|
|
83
|
-
this.db.prepare('UPDATE agent_memories SET shared = 1 WHERE id = ?').run(entryId);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Unshare a memory (make agent-private again).
|
|
87
|
-
*/
|
|
88
|
-
unshare(entryId) {
|
|
89
|
-
this.db.prepare('UPDATE agent_memories SET shared = 0 WHERE id = ?').run(entryId);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Get partition statistics per agent.
|
|
93
|
-
*/
|
|
94
|
-
getPartitions() {
|
|
95
|
-
const rows = this.db.prepare(`
|
|
96
|
-
SELECT agent_id as agentId,
|
|
97
|
-
agent_id as agentName,
|
|
98
|
-
COUNT(*) as entryCount,
|
|
99
|
-
MAX(timestamp) as lastActivity
|
|
100
|
-
FROM agent_memories
|
|
101
|
-
GROUP BY agent_id
|
|
102
|
-
ORDER BY lastActivity DESC
|
|
103
|
-
`).all();
|
|
104
|
-
return rows;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Count memories for a specific agent.
|
|
108
|
-
*/
|
|
109
|
-
countForAgent(agentId) {
|
|
110
|
-
const result = this.db.prepare(`
|
|
111
|
-
SELECT COUNT(*) as c FROM agent_memories WHERE agent_id = ?
|
|
112
|
-
`).get(agentId);
|
|
113
|
-
return result.c;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Delete all memories for a specific agent (used on deregister).
|
|
117
|
-
*/
|
|
118
|
-
clearAgent(agentId) {
|
|
119
|
-
const result = this.db.prepare('DELETE FROM agent_memories WHERE agent_id = ?').run(agentId);
|
|
120
|
-
return result.changes;
|
|
121
|
-
}
|
|
122
|
-
close() {
|
|
123
|
-
this.db.close();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=agent-scoped-memory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-scoped-memory.js","sourceRoot":"","sources":["../../src/memory/agent-scoped-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAmB/B;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,EAAqB;IAC3D,EAAE,CAAC,IAAI,CAAC;;;;;;;;;;;;;GAaP,CAAC,CAAC;AACL,CAAC;AAED,MAAM,OAAO,iBAAiB;IACpB,EAAE,CAAoB;IAE9B,YAAY,MAAc;QACxB,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACrB,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,EAAE,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/B,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,OAAe,EAAE,OAAe,aAAa,EAAE,aAAqB,CAAC;QAC1F,MAAM,IAAI,GAAG,IAAI,C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AG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;KAE9B,CAAC,CAAC,GAAG,CAAC,OAAO,CAAkB,CAAC;QACjC,OAAO,MAAM,CAAC,CAAC,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAAe;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,+CAA+C,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7F,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dedup Detector Module for UAP
|
|
3
|
-
*
|
|
4
|
-
* Detects duplicate and near-duplicate content in memory entries.
|
|
5
|
-
*/
|
|
6
|
-
export interface MemoryEntry {
|
|
7
|
-
id: string;
|
|
8
|
-
content: string;
|
|
9
|
-
type: string;
|
|
10
|
-
timestamp: string;
|
|
11
|
-
}
|
|
12
|
-
export interface DuplicateResult {
|
|
13
|
-
primaryId: string;
|
|
14
|
-
duplicateIds: string[];
|
|
15
|
-
similarity: number;
|
|
16
|
-
}
|
|
17
|
-
export interface DedupDetectorConfig {
|
|
18
|
-
similarityThreshold: number;
|
|
19
|
-
minContentLength: number;
|
|
20
|
-
exactMatch: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Dedup Detector
|
|
24
|
-
* Detects duplicate content in memory entries
|
|
25
|
-
*/
|
|
26
|
-
export declare class DedupDetector {
|
|
27
|
-
private config;
|
|
28
|
-
constructor(config?: Partial<DedupDetectorConfig>);
|
|
29
|
-
/**
|
|
30
|
-
* Detect duplicates in a batch of entries
|
|
31
|
-
*/
|
|
32
|
-
detectDuplicates(entries: MemoryEntry[]): DuplicateResult[];
|
|
33
|
-
/**
|
|
34
|
-
* Check if two pieces of content are duplicates
|
|
35
|
-
*/
|
|
36
|
-
isDuplicate(content1: string, content2: string): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Compute similarity between two contents
|
|
39
|
-
*/
|
|
40
|
-
computeSimilarity(content1: string, content2: string): number;
|
|
41
|
-
/**
|
|
42
|
-
* Find the most similar entry to a query
|
|
43
|
-
*/
|
|
44
|
-
findMostSimilar(query: string, entries: MemoryEntry[]): {
|
|
45
|
-
id: string;
|
|
46
|
-
similarity: number;
|
|
47
|
-
} | null;
|
|
48
|
-
/**
|
|
49
|
-
* Get duplicate statistics
|
|
50
|
-
*/
|
|
51
|
-
getStats(entries: MemoryEntry[]): {
|
|
52
|
-
totalEntries: number;
|
|
53
|
-
duplicatesFound: number;
|
|
54
|
-
uniqueEntries: number;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=dedup-detector.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dedup-detector.d.ts","sourceRoot":"","sources":["../../src/memory/dedup-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;CACrB;AAQD;;;GAGG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAsB;gBAExB,MAAM,GAAE,OAAO,CAAC,mBAAmB,CAAM;IAIrD;;OAEG;IACH,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE;IAkC3D;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAmBxD;;OAEG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAI7D;;OAEG;IACH,eAAe,CACb,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,WAAW,EAAE,GACrB;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAiB5C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG;QAChC,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;KACvB;CAcF"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dedup Detector Module for UAP
|
|
3
|
-
*
|
|
4
|
-
* Detects duplicate and near-duplicate content in memory entries.
|
|
5
|
-
*/
|
|
6
|
-
import { jaccardSimilarity } from '../utils/string-similarity.js';
|
|
7
|
-
const DEFAULT_CONFIG = {
|
|
8
|
-
similarityThreshold: 0.85,
|
|
9
|
-
minContentLength: 20,
|
|
10
|
-
exactMatch: true,
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Dedup Detector
|
|
14
|
-
* Detects duplicate content in memory entries
|
|
15
|
-
*/
|
|
16
|
-
export class DedupDetector {
|
|
17
|
-
config;
|
|
18
|
-
constructor(config = {}) {
|
|
19
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Detect duplicates in a batch of entries
|
|
23
|
-
*/
|
|
24
|
-
detectDuplicates(entries) {
|
|
25
|
-
const results = [];
|
|
26
|
-
const processed = new Set();
|
|
27
|
-
for (let i = 0; i < entries.length; i++) {
|
|
28
|
-
if (processed.has(entries[i].id))
|
|
29
|
-
continue;
|
|
30
|
-
const primary = entries[i];
|
|
31
|
-
const duplicates = [];
|
|
32
|
-
for (let j = i + 1; j < entries.length; j++) {
|
|
33
|
-
const other = entries[j];
|
|
34
|
-
if (this.isDuplicate(primary.content, other.content)) {
|
|
35
|
-
duplicates.push(other.id);
|
|
36
|
-
processed.add(other.id);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (duplicates.length > 0) {
|
|
40
|
-
const dupEntry = entries.find((e) => e.id === duplicates[0]);
|
|
41
|
-
results.push({
|
|
42
|
-
primaryId: primary.id,
|
|
43
|
-
duplicateIds: duplicates,
|
|
44
|
-
similarity: this.computeSimilarity(primary.content, dupEntry.content),
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
processed.add(primary.id);
|
|
48
|
-
}
|
|
49
|
-
return results;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Check if two pieces of content are duplicates
|
|
53
|
-
*/
|
|
54
|
-
isDuplicate(content1, content2) {
|
|
55
|
-
// Exact match
|
|
56
|
-
if (this.config.exactMatch && content1 === content2) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
// Length check
|
|
60
|
-
if (content1.length < this.config.minContentLength ||
|
|
61
|
-
content2.length < this.config.minContentLength) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
// Similarity check
|
|
65
|
-
const similarity = jaccardSimilarity(content1, content2);
|
|
66
|
-
return similarity >= this.config.similarityThreshold;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Compute similarity between two contents
|
|
70
|
-
*/
|
|
71
|
-
computeSimilarity(content1, content2) {
|
|
72
|
-
return jaccardSimilarity(content1, content2);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Find the most similar entry to a query
|
|
76
|
-
*/
|
|
77
|
-
findMostSimilar(query, entries) {
|
|
78
|
-
let bestId = null;
|
|
79
|
-
let bestSimilarity = 0;
|
|
80
|
-
for (const entry of entries) {
|
|
81
|
-
const similarity = this.computeSimilarity(query, entry.content);
|
|
82
|
-
if (similarity > bestSimilarity) {
|
|
83
|
-
bestSimilarity = similarity;
|
|
84
|
-
bestId = entry.id;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return bestSimilarity >= this.config.similarityThreshold
|
|
88
|
-
? { id: bestId, similarity: bestSimilarity }
|
|
89
|
-
: null;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Get duplicate statistics
|
|
93
|
-
*/
|
|
94
|
-
getStats(entries) {
|
|
95
|
-
const duplicates = this.detectDuplicates(entries);
|
|
96
|
-
let totalDuplicates = 0;
|
|
97
|
-
for (const dup of duplicates) {
|
|
98
|
-
totalDuplicates += dup.duplicateIds.length;
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
totalEntries: entries.length,
|
|
102
|
-
duplicatesFound: totalDuplicates,
|
|
103
|
-
uniqueEntries: entries.length - totalDuplicates,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=dedup-detector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dedup-detector.js","sourceRoot":"","sources":["../../src/memory/dedup-detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAqBlE,MAAM,cAAc,GAAwB;IAC1C,mBAAmB,EAAE,IAAI;IACzB,gBAAgB,EAAE,EAAE;IACpB,UAAU,EAAE,IAAI;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAsB;IAEpC,YAAY,SAAuC,EAAE;QACnD,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,OAAsB;QACrC,MAAM,OAAO,GAAsB,E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AAE;YAC7C,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAsB;QAK7B,MAAM,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,eAAe,GAAG,CAAC,CAAC;QAExB,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAC7B,eAAe,IAAI,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC;QAC7C,CAAC;QAED,OAAO;YACL,YAAY,EAAE,OAAO,CAAC,MAAM;YAC5B,eAAe,EAAE,eAAe;YAChC,aAAa,EAAE,OAAO,CAAC,MAAM,GAAG,eAAe;SAChD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deduplicated Memory Module for UAP
|
|
3
|
-
*
|
|
4
|
-
* Implements memory deduplication using content hashing and similarity detection.
|
|
5
|
-
* Prevents redundant memory entries and maintains memory efficiency.
|
|
6
|
-
*/
|
|
7
|
-
export interface MemoryEntry {
|
|
8
|
-
id: string;
|
|
9
|
-
content: string;
|
|
10
|
-
type: string;
|
|
11
|
-
timestamp: string;
|
|
12
|
-
importance?: number;
|
|
13
|
-
}
|
|
14
|
-
export interface DedupConfig {
|
|
15
|
-
similarityThreshold: number;
|
|
16
|
-
minContentLength: number;
|
|
17
|
-
hashAlgorithm: 'jaccard' | 'cosine' | 'exact';
|
|
18
|
-
maxSimilarityWindow: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Deduplicated Memory Manager
|
|
22
|
-
* Prevents duplicate memory entries through content hashing and similarity detection
|
|
23
|
-
*/
|
|
24
|
-
export declare class DeduplicatedMemory {
|
|
25
|
-
private config;
|
|
26
|
-
private memory;
|
|
27
|
-
private contentIndex;
|
|
28
|
-
constructor(config?: Partial<DedupConfig>);
|
|
29
|
-
/**
|
|
30
|
-
* Add a memory entry, checking for duplicates
|
|
31
|
-
*/
|
|
32
|
-
add(entry: MemoryEntry): {
|
|
33
|
-
id: string;
|
|
34
|
-
isNew: boolean;
|
|
35
|
-
duplicateOf?: string;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Get a memory entry by ID
|
|
39
|
-
*/
|
|
40
|
-
get(id: string): MemoryEntry | null;
|
|
41
|
-
/**
|
|
42
|
-
* Update an existing entry
|
|
43
|
-
*/
|
|
44
|
-
update(id: string, content: string): boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Delete a memory entry
|
|
47
|
-
*/
|
|
48
|
-
delete(id: string): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Get all entries
|
|
51
|
-
*/
|
|
52
|
-
getAll(): MemoryEntry[];
|
|
53
|
-
/**
|
|
54
|
-
* Query entries by content (returns most similar)
|
|
55
|
-
*/
|
|
56
|
-
query(query: string, limit?: number): Array<{
|
|
57
|
-
entry: MemoryEntry;
|
|
58
|
-
similarity: number;
|
|
59
|
-
}>;
|
|
60
|
-
/**
|
|
61
|
-
* Get statistics
|
|
62
|
-
*/
|
|
63
|
-
getStats(): {
|
|
64
|
-
totalEntries: number;
|
|
65
|
-
uniqueContent: number;
|
|
66
|
-
duplicatesPrevented: number;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Clear all memory
|
|
70
|
-
*/
|
|
71
|
-
clear(): void;
|
|
72
|
-
/**
|
|
73
|
-
* Compute content hash (simple approach)
|
|
74
|
-
*/
|
|
75
|
-
private computeHash;
|
|
76
|
-
/**
|
|
77
|
-
* Compute similarity between two texts
|
|
78
|
-
*/
|
|
79
|
-
private computeSimilarity;
|
|
80
|
-
/**
|
|
81
|
-
* Find similar content in memory
|
|
82
|
-
*/
|
|
83
|
-
private findSimilarContent;
|
|
84
|
-
/**
|
|
85
|
-
* Update content index
|
|
86
|
-
*/
|
|
87
|
-
private updateIndex;
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=dedup-memory.d.ts.map
|
|
@@ -1 +0,0 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KAAE,CAAC;IAc1F;;OAEG;IACH,QAAQ,IAAI;QACV,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,mBAAmB,EAAE,MAAM,CAAC;KAC7B;IAQD;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,OAAO,CAAC,WAAW;IAWnB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAYzB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;OAEG;IACH,OAAO,CAAC,WAAW;CAMpB"}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deduplicated Memory Module for UAP
|
|
3
|
-
*
|
|
4
|
-
* Implements memory deduplication using content hashing and similarity detection.
|
|
5
|
-
* Prevents redundant memory entries and maintains memory efficiency.
|
|
6
|
-
*/
|
|
7
|
-
import { jaccardSimilarity } from '../utils/string-similarity.js';
|
|
8
|
-
const DEFAULT_CONFIG = {
|
|
9
|
-
similarityThreshold: 0.85,
|
|
10
|
-
minContentLength: 20,
|
|
11
|
-
hashAlgorithm: 'jaccard',
|
|
12
|
-
maxSimilarityWindow: 7,
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Deduplicated Memory Manager
|
|
16
|
-
* Prevents duplicate memory entries through content hashing and similarity detection
|
|
17
|
-
*/
|
|
18
|
-
export class DeduplicatedMemory {
|
|
19
|
-
config;
|
|
20
|
-
memory = new Map();
|
|
21
|
-
contentIndex = new Map(); // hash -> [ids]
|
|
22
|
-
constructor(config = {}) {
|
|
23
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Add a memory entry, checking for duplicates
|
|
27
|
-
*/
|
|
28
|
-
add(entry) {
|
|
29
|
-
const hash = this.computeHash(entry.content);
|
|
30
|
-
// Check if exact duplicate exists
|
|
31
|
-
if (this.memory.has(hash)) {
|
|
32
|
-
return {
|
|
33
|
-
id: hash,
|
|
34
|
-
isNew: false,
|
|
35
|
-
duplicateOf: hash,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
// Check for similar content
|
|
39
|
-
const similarId = this.findSimilarContent(entry.content);
|
|
40
|
-
if (similarId) {
|
|
41
|
-
return {
|
|
42
|
-
id: hash,
|
|
43
|
-
isNew: false,
|
|
44
|
-
duplicateOf: similarId,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
// Add new entry
|
|
48
|
-
const fullEntry = {
|
|
49
|
-
...entry,
|
|
50
|
-
id: hash,
|
|
51
|
-
};
|
|
52
|
-
this.memory.set(hash, fullEntry);
|
|
53
|
-
this.updateIndex(hash, entry.content);
|
|
54
|
-
return { id: hash, isNew: true };
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Get a memory entry by ID
|
|
58
|
-
*/
|
|
59
|
-
get(id) {
|
|
60
|
-
return this.memory.get(id) || null;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Update an existing entry
|
|
64
|
-
*/
|
|
65
|
-
update(id, content) {
|
|
66
|
-
if (!this.memory.has(id)) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
const entry = this.memory.get(id);
|
|
70
|
-
entry.content = content;
|
|
71
|
-
entry.timestamp = new Date().toISOString();
|
|
72
|
-
// Update index
|
|
73
|
-
this.contentIndex.delete(entry.id);
|
|
74
|
-
this.updateIndex(id, content);
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Delete a memory entry
|
|
79
|
-
*/
|
|
80
|
-
delete(id) {
|
|
81
|
-
const deleted = this.memory.delete(id);
|
|
82
|
-
if (deleted) {
|
|
83
|
-
this.contentIndex.delete(id);
|
|
84
|
-
}
|
|
85
|
-
return deleted;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Get all entries
|
|
89
|
-
*/
|
|
90
|
-
getAll() {
|
|
91
|
-
return Array.from(this.memory.values());
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Query entries by content (returns most similar)
|
|
95
|
-
*/
|
|
96
|
-
query(query, limit = 5) {
|
|
97
|
-
const results = [];
|
|
98
|
-
for (const entry of this.memory.values()) {
|
|
99
|
-
const similarity = this.computeSimilarity(query, entry.content);
|
|
100
|
-
if (similarity > 0.5) {
|
|
101
|
-
results.push({ entry, similarity });
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
results.sort((a, b) => b.similarity - a.similarity);
|
|
105
|
-
return results.slice(0, limit);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Get statistics
|
|
109
|
-
*/
|
|
110
|
-
getStats() {
|
|
111
|
-
return {
|
|
112
|
-
totalEntries: this.memory.size,
|
|
113
|
-
uniqueContent: this.memory.size,
|
|
114
|
-
duplicatesPrevented: 0, // Would need to track separately
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Clear all memory
|
|
119
|
-
*/
|
|
120
|
-
clear() {
|
|
121
|
-
this.memory.clear();
|
|
122
|
-
this.contentIndex.clear();
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Compute content hash (simple approach)
|
|
126
|
-
*/
|
|
127
|
-
computeHash(content) {
|
|
128
|
-
// Simple hash - in production, use a proper hashing algorithm
|
|
129
|
-
let hash = 0;
|
|
130
|
-
for (let i = 0; i < content.length; i++) {
|
|
131
|
-
const char = content.charCodeAt(i);
|
|
132
|
-
hash = (hash << 5) - hash + char;
|
|
133
|
-
hash = hash & hash; // Convert to 32bit integer
|
|
134
|
-
}
|
|
135
|
-
return `mem-${Math.abs(hash).toString(36)}-${Date.now()}`;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Compute similarity between two texts
|
|
139
|
-
*/
|
|
140
|
-
computeSimilarity(a, b) {
|
|
141
|
-
if (this.config.hashAlgorithm === 'exact') {
|
|
142
|
-
return a === b ? 1 : 0;
|
|
143
|
-
}
|
|
144
|
-
if (a.length < this.config.minContentLength || b.length < this.config.minContentLength) {
|
|
145
|
-
return 0;
|
|
146
|
-
}
|
|
147
|
-
return jaccardSimilarity(a, b);
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Find similar content in memory
|
|
151
|
-
*/
|
|
152
|
-
findSimilarContent(content) {
|
|
153
|
-
for (const [id, entry] of this.memory) {
|
|
154
|
-
if (entry.id === id)
|
|
155
|
-
continue;
|
|
156
|
-
const similarity = this.computeSimilarity(content, entry.content);
|
|
157
|
-
if (similarity >= this.config.similarityThreshold) {
|
|
158
|
-
return id;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Update content index
|
|
165
|
-
*/
|
|
166
|
-
updateIndex(id, content) {
|
|
167
|
-
if (!this.contentIndex.has(id)) {
|
|
168
|
-
this.contentIndex.set(id, []);
|
|
169
|
-
}
|
|
170
|
-
this.contentIndex.get(id).push(content);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
//# sourceMappingURL=dedup-memory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dedup-memory.js","sourceRoot":"","sources":["../../src/memory/dedup-memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAiBlE,MAAM,cAAc,GAAgB;IAClC,mBAAmB,EAAE,IAAI;IACzB,gBAAgB,EAAE,EAAE;IACpB,aAAa,EAAE,SAAS;IACxB,mBAAmB,EAAE,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAc;IACpB,MAAM,GAA6B,IAAI,GAAG,EAAE,CAAC;IAC7C,YAAY,GAA0B,IAAI,GAAG,EAAE,CAAC,CAAC,gBAAgB;IAEzE,YAAY,SAA+B,EAAE;QAC3C,IAAI,CAAC,MAAM,GAAG,EAAE,GA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gBAAgB,IAAI,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YACvF,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACK,kBAAkB,CAAC,OAAe;QACxC,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACtC,IAAI,KAAK,CAAC,EAAE,KAAK,EAAE;gBAAE,SAAS;YAE9B,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YAClE,IAAI,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;gBAClD,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,EAAU,EAAE,OAAe;QAC7C,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic UAP Patterns - Domain-agnostic best practices
|
|
3
|
-
* NOT specific to any benchmark or test scenario
|
|
4
|
-
*/
|
|
5
|
-
export declare const GENERIC_UAP_PATTERNS: Record<string, string>;
|
|
6
|
-
export declare function getGenericContext(category: string): string;
|
|
7
|
-
//# sourceMappingURL=generic-uap-patterns.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generic-uap-patterns.d.ts","sourceRoot":"","sources":["../../src/memory/generic-uap-patterns.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyCvD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic UAP Patterns - Domain-agnostic best practices
|
|
3
|
-
* NOT specific to any benchmark or test scenario
|
|
4
|
-
*/
|
|
5
|
-
export const GENERIC_UAP_PATTERNS = {
|
|
6
|
-
security: `### Security Best Practices (Generic)
|
|
7
|
-
- **Input Validation**: Always sanitize user input before processing
|
|
8
|
-
- **Credential Handling**: Use established tools/libraries for cryptographic operations
|
|
9
|
-
- **Pattern Recognition**: Understand common attack vectors (injection, XSS, CSRF)
|
|
10
|
-
- **Defense in Depth**: Layer security controls rather than relying on single mechanisms`,
|
|
11
|
-
passwordCracking: `### Password Security Analysis (Generic)
|
|
12
|
-
- **Hash Identification**: Identify hash format before attempting recovery
|
|
13
|
-
- **Tool Chain**: Extract hash first, then apply appropriate cracking method
|
|
14
|
-
- **Method Selection**: Choose between wordlist attacks and brute force`,
|
|
15
|
-
xssFiltering: `### HTML Sanitization (Generic)
|
|
16
|
-
- **Tag Removal**: Strip all script-related tags
|
|
17
|
-
- **Attribute Cleaning**: Remove event handlers
|
|
18
|
-
- **Protocol Blocking**: Block javascript:, data: URL schemes`,
|
|
19
|
-
binaryParsing: `### Binary File Parsing (Generic)
|
|
20
|
-
- **Format Documentation**: Study file format specification first
|
|
21
|
-
- **Byte Order Awareness**: Handle endianness correctly
|
|
22
|
-
- **Offset Calculation**: Use documented offsets for headers`,
|
|
23
|
-
databaseRecovery: `### Database Recovery (Generic)
|
|
24
|
-
- **Log Replay**: Use checkpoint operations to apply transactions
|
|
25
|
-
- **WAL Handling**: Checkpoint before truncating write-ahead logs
|
|
26
|
-
- **Data Integrity**: Verify consistency after recovery`,
|
|
27
|
-
legacyCode: `### Legacy Code Modernization (Generic)
|
|
28
|
-
- **Format Preservation**: Understand original code structure
|
|
29
|
-
- **Semantic Mapping**: Map legacy constructs to modern equivalents
|
|
30
|
-
- **Behavior Verification**: Test with original inputs`,
|
|
31
|
-
mlTraining: `### Machine Learning Development (Generic)
|
|
32
|
-
- **Incremental Validation**: Test with minimal config first
|
|
33
|
-
- **Resource Monitoring**: Track GPU/CPU/memory usage
|
|
34
|
-
- **Early Verification**: Validate data shapes and outputs early`,
|
|
35
|
-
fileOperations: `### File System Operations (Generic)
|
|
36
|
-
- **Path Consistency**: Use absolute paths for reliability
|
|
37
|
-
- **Existence Verification**: Check files before operations
|
|
38
|
-
- **Error Handling**: Handle missing files gracefully`
|
|
39
|
-
};
|
|
40
|
-
export function getGenericContext(category) {
|
|
41
|
-
return GENERIC_UAP_PATTERNS[category] || 'Follow standard development best practices';
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=generic-uap-patterns.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generic-uap-patterns.js","sourceRoot":"","sources":["../../src/memory/generic-uap-patterns.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAA2B;IAC1D,QAAQ,EAAE;;;;yFAI6E;IAEvF,gBAAgB,EAAE;;;wEAGoD;IAEtE,YAAY,EAAE;;;8DAG8C;IAE5D,aAAa,EAAE;;;6DAG4C;IAE3D,gBAAgB,EAAE;;;wDAGoC;IAEtD,UAAU,EAAE;;;uDAGyC;IAErD,UAAU,EAAE;;;iEAGmD;IAE/D,cAAc,EAAE;;;sDAGoC;CACrD,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,IAAI,4CAA4C,CAAC;AACxF,CAAC"}
|