@autonav/core 1.4.0 → 1.6.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/cli/autonav.d.ts +1 -0
- package/dist/cli/autonav.d.ts.map +1 -1
- package/dist/cli/autonav.js +7 -0
- package/dist/cli/autonav.js.map +1 -1
- package/dist/cli/nav-init.js +17 -3
- package/dist/cli/nav-init.js.map +1 -1
- package/dist/cli/nav-memento.d.ts +20 -0
- package/dist/cli/nav-memento.d.ts.map +1 -0
- package/dist/cli/nav-memento.js +179 -0
- package/dist/cli/nav-memento.js.map +1 -0
- package/dist/cli/nav-mend.js +7 -0
- package/dist/cli/nav-mend.js.map +1 -1
- package/dist/memento/git-operations.d.ts +95 -0
- package/dist/memento/git-operations.d.ts.map +1 -0
- package/dist/memento/git-operations.js +256 -0
- package/dist/memento/git-operations.js.map +1 -0
- package/dist/memento/index.d.ts +31 -0
- package/dist/memento/index.d.ts.map +1 -0
- package/dist/memento/index.js +38 -0
- package/dist/memento/index.js.map +1 -0
- package/dist/memento/loop.d.ts +33 -0
- package/dist/memento/loop.d.ts.map +1 -0
- package/dist/memento/loop.js +535 -0
- package/dist/memento/loop.js.map +1 -0
- package/dist/memento/matrix-animation.d.ts +77 -0
- package/dist/memento/matrix-animation.d.ts.map +1 -0
- package/dist/memento/matrix-animation.js +228 -0
- package/dist/memento/matrix-animation.js.map +1 -0
- package/dist/memento/nav-protocol.d.ts +30 -0
- package/dist/memento/nav-protocol.d.ts.map +1 -0
- package/dist/memento/nav-protocol.js +79 -0
- package/dist/memento/nav-protocol.js.map +1 -0
- package/dist/memento/prompts.d.ts +44 -0
- package/dist/memento/prompts.d.ts.map +1 -0
- package/dist/memento/prompts.js +168 -0
- package/dist/memento/prompts.js.map +1 -0
- package/dist/memento/state.d.ts +56 -0
- package/dist/memento/state.d.ts.map +1 -0
- package/dist/memento/state.js +156 -0
- package/dist/memento/state.js.map +1 -0
- package/dist/memento/types.d.ts +123 -0
- package/dist/memento/types.d.ts.map +1 -0
- package/dist/memento/types.js +30 -0
- package/dist/memento/types.js.map +1 -0
- package/dist/memento/worker-agent.d.ts +30 -0
- package/dist/memento/worker-agent.d.ts.map +1 -0
- package/dist/memento/worker-agent.js +109 -0
- package/dist/memento/worker-agent.js.map +1 -0
- package/dist/mend/index.d.ts +6 -0
- package/dist/mend/index.d.ts.map +1 -1
- package/dist/mend/index.js +92 -1
- package/dist/mend/index.js.map +1 -1
- package/dist/mend/llm-review.d.ts +18 -0
- package/dist/mend/llm-review.d.ts.map +1 -0
- package/dist/mend/llm-review.js +81 -0
- package/dist/mend/llm-review.js.map +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +4 -0
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/versions/v1.4.0-rfc2119-skills.d.ts +18 -0
- package/dist/migrations/versions/v1.4.0-rfc2119-skills.d.ts.map +1 -0
- package/dist/migrations/versions/v1.4.0-rfc2119-skills.js +207 -0
- package/dist/migrations/versions/v1.4.0-rfc2119-skills.js.map +1 -0
- package/dist/migrations/versions/v1.5.1-mend-instruction.d.ts +13 -0
- package/dist/migrations/versions/v1.5.1-mend-instruction.d.ts.map +1 -0
- package/dist/migrations/versions/v1.5.1-mend-instruction.js +156 -0
- package/dist/migrations/versions/v1.5.1-mend-instruction.js.map +1 -0
- package/package.json +1 -1
- package/dist/skill-generator/index.d.ts +0 -142
- package/dist/skill-generator/index.d.ts.map +0 -1
- package/dist/skill-generator/index.js +0 -510
- package/dist/skill-generator/index.js.map +0 -1
- package/dist/templates/.gitignore.template +0 -26
- package/dist/templates/CLAUDE-pack.md.template +0 -114
- package/dist/templates/CLAUDE.md.template +0 -153
- package/dist/templates/README.md.template +0 -174
- package/dist/templates/config-pack.json.template +0 -16
- package/dist/templates/config.json.template +0 -11
- package/dist/templates/index.d.ts +0 -22
- package/dist/templates/index.d.ts.map +0 -1
- package/dist/templates/index.js +0 -32
- package/dist/templates/index.js.map +0 -1
- package/dist/templates/plugins.json.template +0 -33
- package/dist/templates/system-configuration.md.template +0 -70
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memento State Management
|
|
3
|
+
*
|
|
4
|
+
* File-based state persistence for the memento loop.
|
|
5
|
+
* Uses atomic writes to prevent corruption from crashes.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
const STATE_DIR = ".autonav";
|
|
11
|
+
const STATE_FILE = "memento-state.json";
|
|
12
|
+
const STATE_VERSION = "1.0.0";
|
|
13
|
+
/**
|
|
14
|
+
* Get the path to the state file for a code directory
|
|
15
|
+
*/
|
|
16
|
+
export function getStatePath(codeDirectory) {
|
|
17
|
+
return path.join(codeDirectory, STATE_DIR, STATE_FILE);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Check if a memento state file exists
|
|
21
|
+
*/
|
|
22
|
+
export function stateExists(codeDirectory) {
|
|
23
|
+
return fs.existsSync(getStatePath(codeDirectory));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Load existing state from disk
|
|
27
|
+
*
|
|
28
|
+
* @throws {Error} If state file doesn't exist or is invalid
|
|
29
|
+
*/
|
|
30
|
+
export function loadState(codeDirectory) {
|
|
31
|
+
const statePath = getStatePath(codeDirectory);
|
|
32
|
+
if (!fs.existsSync(statePath)) {
|
|
33
|
+
throw new Error(`No memento state found at ${statePath}. Use --resume=false to start a new run.`);
|
|
34
|
+
}
|
|
35
|
+
const content = fs.readFileSync(statePath, "utf-8");
|
|
36
|
+
const state = JSON.parse(content);
|
|
37
|
+
// Validate version
|
|
38
|
+
if (state.version !== STATE_VERSION) {
|
|
39
|
+
throw new Error(`State version mismatch: found ${state.version}, expected ${STATE_VERSION}. ` +
|
|
40
|
+
`Manual migration may be required.`);
|
|
41
|
+
}
|
|
42
|
+
return state;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Save state to disk atomically
|
|
46
|
+
*
|
|
47
|
+
* Uses temp file + rename pattern to prevent corruption
|
|
48
|
+
*/
|
|
49
|
+
export function saveState(state) {
|
|
50
|
+
const statePath = getStatePath(state.codeDirectory);
|
|
51
|
+
const stateDir = path.dirname(statePath);
|
|
52
|
+
const tempPath = path.join(stateDir, `.memento-state-${Date.now()}.tmp`);
|
|
53
|
+
// Ensure .autonav directory exists
|
|
54
|
+
if (!fs.existsSync(stateDir)) {
|
|
55
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
56
|
+
}
|
|
57
|
+
// Update timestamp
|
|
58
|
+
state.lastUpdated = new Date().toISOString();
|
|
59
|
+
// Write to temp file, then rename atomically
|
|
60
|
+
fs.writeFileSync(tempPath, JSON.stringify(state, null, 2));
|
|
61
|
+
fs.renameSync(tempPath, statePath);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Initialize a new memento state
|
|
65
|
+
*/
|
|
66
|
+
export function initializeState(codeDirectory, navDirectory, task, options) {
|
|
67
|
+
const state = {
|
|
68
|
+
version: STATE_VERSION,
|
|
69
|
+
runId: randomUUID(),
|
|
70
|
+
codeDirectory: path.resolve(codeDirectory),
|
|
71
|
+
navDirectory: path.resolve(navDirectory),
|
|
72
|
+
task,
|
|
73
|
+
branch: options.branch,
|
|
74
|
+
iteration: 0,
|
|
75
|
+
maxIterations: options.maxIterations,
|
|
76
|
+
promise: options.promise,
|
|
77
|
+
completed: false,
|
|
78
|
+
lastUpdated: new Date().toISOString(),
|
|
79
|
+
iterationTimestamps: [],
|
|
80
|
+
planHistory: [],
|
|
81
|
+
};
|
|
82
|
+
saveState(state);
|
|
83
|
+
return state;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Increment iteration counter and record timestamp
|
|
87
|
+
*/
|
|
88
|
+
export function incrementIteration(state) {
|
|
89
|
+
state.iteration += 1;
|
|
90
|
+
state.iterationTimestamps.push(new Date().toISOString());
|
|
91
|
+
saveState(state);
|
|
92
|
+
return state;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Record a plan in history
|
|
96
|
+
*/
|
|
97
|
+
export function recordPlan(state, summary) {
|
|
98
|
+
state.planHistory.push({
|
|
99
|
+
iteration: state.iteration,
|
|
100
|
+
summary,
|
|
101
|
+
timestamp: new Date().toISOString(),
|
|
102
|
+
});
|
|
103
|
+
saveState(state);
|
|
104
|
+
return state;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Mark the loop as completed
|
|
108
|
+
*/
|
|
109
|
+
export function completeLoop(state, completionMessage) {
|
|
110
|
+
state.completed = true;
|
|
111
|
+
state.completionMessage = completionMessage;
|
|
112
|
+
saveState(state);
|
|
113
|
+
return state;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Check if the loop should continue
|
|
117
|
+
*/
|
|
118
|
+
export function shouldContinue(state) {
|
|
119
|
+
if (state.completed) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
if (state.maxIterations > 0 && state.iteration >= state.maxIterations) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Delete state file (cleanup after successful completion)
|
|
129
|
+
*/
|
|
130
|
+
export function deleteState(codeDirectory) {
|
|
131
|
+
const statePath = getStatePath(codeDirectory);
|
|
132
|
+
if (fs.existsSync(statePath)) {
|
|
133
|
+
fs.unlinkSync(statePath);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get or initialize state based on options
|
|
138
|
+
*/
|
|
139
|
+
export function getOrInitializeState(codeDirectory, navDirectory, task, options) {
|
|
140
|
+
if (options.resume && stateExists(codeDirectory)) {
|
|
141
|
+
const state = loadState(codeDirectory);
|
|
142
|
+
// Validate that the resumed state matches current parameters
|
|
143
|
+
if (state.navDirectory !== path.resolve(navDirectory)) {
|
|
144
|
+
throw new Error(`Navigator directory mismatch: state has ${state.navDirectory}, ` +
|
|
145
|
+
`but ${navDirectory} was provided. Delete state file to start fresh.`);
|
|
146
|
+
}
|
|
147
|
+
return state;
|
|
148
|
+
}
|
|
149
|
+
// If state exists but not resuming, warn and overwrite
|
|
150
|
+
if (stateExists(codeDirectory) && !options.resume) {
|
|
151
|
+
console.warn(`Warning: Existing state found. Starting fresh (use --resume to continue).`);
|
|
152
|
+
deleteState(codeDirectory);
|
|
153
|
+
}
|
|
154
|
+
return initializeState(codeDirectory, navDirectory, task, options);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/memento/state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,SAAS,GAAG,UAAU,CAAC;AAC7B,MAAM,UAAU,GAAG,oBAAoB,CAAC;AACxC,MAAM,aAAa,GAAG,OAAgB,CAAC;AAEvC;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,aAAqB;IAChD,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACzD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,aAAqB;IAC/C,OAAO,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,aAAqB;IAC7C,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IAE9C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CA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CAAC,IAAI,CAAC,2EAA2E,CAAC,CAAC;QAC1F,WAAW,CAAC,aAAa,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,eAAe,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memento Loop Types
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the context-clearing iterative development loop
|
|
5
|
+
* that coordinates navigator (planning) and worker (implementation) agents.
|
|
6
|
+
*
|
|
7
|
+
* Design principle: The WORKER forgets between iterations (memento pattern).
|
|
8
|
+
* The NAVIGATOR maintains its own memory. Git commits track worker progress.
|
|
9
|
+
* All types here are for in-memory use during loop execution.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
/**
|
|
13
|
+
* Schema for implementation plan steps
|
|
14
|
+
*/
|
|
15
|
+
export declare const ImplementationStepSchema: z.ZodObject<{
|
|
16
|
+
description: z.ZodString;
|
|
17
|
+
files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
18
|
+
commands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
description: string;
|
|
21
|
+
files?: string[] | undefined;
|
|
22
|
+
commands?: string[] | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
description: string;
|
|
25
|
+
files?: string[] | undefined;
|
|
26
|
+
commands?: string[] | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Schema for implementation plan returned by navigator
|
|
30
|
+
*/
|
|
31
|
+
export declare const ImplementationPlanSchema: z.ZodObject<{
|
|
32
|
+
summary: z.ZodString;
|
|
33
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
34
|
+
description: z.ZodString;
|
|
35
|
+
files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
36
|
+
commands: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
description: string;
|
|
39
|
+
files?: string[] | undefined;
|
|
40
|
+
commands?: string[] | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
description: string;
|
|
43
|
+
files?: string[] | undefined;
|
|
44
|
+
commands?: string[] | undefined;
|
|
45
|
+
}>, "many">;
|
|
46
|
+
validationCriteria: z.ZodArray<z.ZodString, "many">;
|
|
47
|
+
isComplete: z.ZodBoolean;
|
|
48
|
+
completionMessage: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
summary: string;
|
|
51
|
+
steps: {
|
|
52
|
+
description: string;
|
|
53
|
+
files?: string[] | undefined;
|
|
54
|
+
commands?: string[] | undefined;
|
|
55
|
+
}[];
|
|
56
|
+
validationCriteria: string[];
|
|
57
|
+
isComplete: boolean;
|
|
58
|
+
completionMessage?: string | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
summary: string;
|
|
61
|
+
steps: {
|
|
62
|
+
description: string;
|
|
63
|
+
files?: string[] | undefined;
|
|
64
|
+
commands?: string[] | undefined;
|
|
65
|
+
}[];
|
|
66
|
+
validationCriteria: string[];
|
|
67
|
+
isComplete: boolean;
|
|
68
|
+
completionMessage?: string | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
export type ImplementationStep = z.infer<typeof ImplementationStepSchema>;
|
|
71
|
+
export type ImplementationPlan = z.infer<typeof ImplementationPlanSchema>;
|
|
72
|
+
/**
|
|
73
|
+
* Result from worker agent execution
|
|
74
|
+
*/
|
|
75
|
+
export interface WorkerResult {
|
|
76
|
+
/** Whether the worker completed successfully */
|
|
77
|
+
success: boolean;
|
|
78
|
+
/** Summary of what was done */
|
|
79
|
+
summary: string;
|
|
80
|
+
/** Files that were modified */
|
|
81
|
+
filesModified: string[];
|
|
82
|
+
/** Any errors encountered */
|
|
83
|
+
errors?: string[];
|
|
84
|
+
/** Duration in milliseconds */
|
|
85
|
+
durationMs: number;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Command line options for memento command
|
|
89
|
+
*/
|
|
90
|
+
export interface MementoOptions {
|
|
91
|
+
/** Create and push to a new PR when complete */
|
|
92
|
+
pr?: boolean;
|
|
93
|
+
/** Maximum iterations (0 = unlimited) */
|
|
94
|
+
maxIterations: number;
|
|
95
|
+
/** Completion signal text */
|
|
96
|
+
promise: string;
|
|
97
|
+
/** Git branch name for work */
|
|
98
|
+
branch?: string;
|
|
99
|
+
/** Task description (overrides TASK.md) */
|
|
100
|
+
task?: string;
|
|
101
|
+
/** Show detailed logging */
|
|
102
|
+
verbose?: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Final result of memento loop execution
|
|
106
|
+
*/
|
|
107
|
+
export interface MementoResult {
|
|
108
|
+
/** Whether the task completed successfully */
|
|
109
|
+
success: boolean;
|
|
110
|
+
/** Number of iterations performed */
|
|
111
|
+
iterations: number;
|
|
112
|
+
/** Completion message from nav */
|
|
113
|
+
completionMessage?: string;
|
|
114
|
+
/** PR URL if --pr was used */
|
|
115
|
+
prUrl?: string;
|
|
116
|
+
/** Git branch name */
|
|
117
|
+
branch?: string;
|
|
118
|
+
/** Total duration in milliseconds */
|
|
119
|
+
durationMs: number;
|
|
120
|
+
/** Any errors that occurred */
|
|
121
|
+
errors?: string[];
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/memento/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAInC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMnC,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|
|
1
|
+
/**
|
|
2
|
+
* Memento Loop Types
|
|
3
|
+
*
|
|
4
|
+
* Core type definitions for the context-clearing iterative development loop
|
|
5
|
+
* that coordinates navigator (planning) and worker (implementation) agents.
|
|
6
|
+
*
|
|
7
|
+
* Design principle: The WORKER forgets between iterations (memento pattern).
|
|
8
|
+
* The NAVIGATOR maintains its own memory. Git commits track worker progress.
|
|
9
|
+
* All types here are for in-memory use during loop execution.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
/**
|
|
13
|
+
* Schema for implementation plan steps
|
|
14
|
+
*/
|
|
15
|
+
export const ImplementationStepSchema = z.object({
|
|
16
|
+
description: z.string().describe("What this step accomplishes"),
|
|
17
|
+
files: z.array(z.string()).optional().describe("Files to create or modify"),
|
|
18
|
+
commands: z.array(z.string()).optional().describe("Commands to run"),
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Schema for implementation plan returned by navigator
|
|
22
|
+
*/
|
|
23
|
+
export const ImplementationPlanSchema = z.object({
|
|
24
|
+
summary: z.string().describe("Brief summary of what this plan will accomplish"),
|
|
25
|
+
steps: z.array(ImplementationStepSchema).describe("Ordered implementation steps"),
|
|
26
|
+
validationCriteria: z.array(z.string()).describe("How to verify the implementation worked"),
|
|
27
|
+
isComplete: z.boolean().describe("True if the overall task is complete and no more iterations needed"),
|
|
28
|
+
completionMessage: z.string().optional().describe("Message to display when isComplete is true"),
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/memento/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IAC/D,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IAC3E,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;CACrE,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IAC/E,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IACjF,kBAAkB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IAC3F,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,oEAAoE,CAAC;IACtG,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;CAChG,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Agent for Memento Loop
|
|
3
|
+
*
|
|
4
|
+
* Executes implementation plans using the Claude Agent SDK.
|
|
5
|
+
*/
|
|
6
|
+
import type { ImplementationPlan, WorkerResult } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Minimal context for worker (no persisted state)
|
|
9
|
+
*/
|
|
10
|
+
interface WorkerContext {
|
|
11
|
+
codeDirectory: string;
|
|
12
|
+
task: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Options for worker agent execution
|
|
16
|
+
*/
|
|
17
|
+
export interface WorkerAgentOptions {
|
|
18
|
+
/** Show detailed logging */
|
|
19
|
+
verbose?: boolean;
|
|
20
|
+
/** Model to use (defaults to claude-sonnet-4-5) */
|
|
21
|
+
model?: string;
|
|
22
|
+
/** Maximum turns for worker agent */
|
|
23
|
+
maxTurns?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Run the worker agent to implement a plan
|
|
27
|
+
*/
|
|
28
|
+
export declare function runWorkerAgent(context: WorkerContext, plan: ImplementationPlan, options?: WorkerAgentOptions): Promise<WorkerResult>;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=worker-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-agent.d.ts","sourceRoot":"","sources":["../../src/memento/worker-agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGnE;;GAEG;AACH,UAAU,aAAa;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,kBAAkB,EACxB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,YAAY,CAAC,CAoHvB"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Agent for Memento Loop
|
|
3
|
+
*
|
|
4
|
+
* Executes implementation plans using the Claude Agent SDK.
|
|
5
|
+
*/
|
|
6
|
+
import { query } from "@anthropic-ai/claude-agent-sdk";
|
|
7
|
+
import { buildWorkerPrompt, buildWorkerSystemPrompt } from "./prompts.js";
|
|
8
|
+
/**
|
|
9
|
+
* Run the worker agent to implement a plan
|
|
10
|
+
*/
|
|
11
|
+
export async function runWorkerAgent(context, plan, options = {}) {
|
|
12
|
+
const startTime = Date.now();
|
|
13
|
+
const { verbose = false, model = "claude-sonnet-4-5", maxTurns = 50, } = options;
|
|
14
|
+
const prompt = buildWorkerPrompt(context.codeDirectory, plan);
|
|
15
|
+
const systemPrompt = buildWorkerSystemPrompt(context.codeDirectory);
|
|
16
|
+
if (verbose) {
|
|
17
|
+
console.log("\n[Worker] Starting implementation...");
|
|
18
|
+
console.log(`[Worker] Plan: ${plan.summary}`);
|
|
19
|
+
console.log(`[Worker] Steps: ${plan.steps.length}`);
|
|
20
|
+
}
|
|
21
|
+
const filesModified = [];
|
|
22
|
+
let lastAssistantText = "";
|
|
23
|
+
let resultMessage;
|
|
24
|
+
try {
|
|
25
|
+
const queryIterator = query({
|
|
26
|
+
prompt,
|
|
27
|
+
options: {
|
|
28
|
+
model,
|
|
29
|
+
maxTurns,
|
|
30
|
+
systemPrompt,
|
|
31
|
+
cwd: context.codeDirectory,
|
|
32
|
+
permissionMode: "bypassPermissions",
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
for await (const message of queryIterator) {
|
|
36
|
+
if (message.type === "assistant") {
|
|
37
|
+
const content = message.message.content;
|
|
38
|
+
for (const block of content) {
|
|
39
|
+
if (block.type === "tool_use") {
|
|
40
|
+
// Track file operations
|
|
41
|
+
if (verbose) {
|
|
42
|
+
console.log(`[Worker] Tool: ${block.name}`);
|
|
43
|
+
}
|
|
44
|
+
// Extract file paths from common tools
|
|
45
|
+
if (block.name === "Write" ||
|
|
46
|
+
block.name === "Edit" ||
|
|
47
|
+
block.name === "str_replace_based_edit_tool") {
|
|
48
|
+
const input = block.input;
|
|
49
|
+
const filePath = input.file_path || input.path;
|
|
50
|
+
if (typeof filePath === "string" && !filesModified.includes(filePath)) {
|
|
51
|
+
filesModified.push(filePath);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (block.type === "text") {
|
|
56
|
+
lastAssistantText = block.text;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (message.type === "result") {
|
|
61
|
+
resultMessage = message;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const durationMs = Date.now() - startTime;
|
|
65
|
+
if (!resultMessage) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
summary: "No result message received from worker agent",
|
|
69
|
+
filesModified,
|
|
70
|
+
errors: ["No result message received"],
|
|
71
|
+
durationMs,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (resultMessage.subtype !== "success") {
|
|
75
|
+
const errorDetails = "errors" in resultMessage
|
|
76
|
+
? resultMessage.errors.join(", ")
|
|
77
|
+
: "Unknown error";
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
summary: `Worker failed: ${resultMessage.subtype}`,
|
|
81
|
+
filesModified,
|
|
82
|
+
errors: [errorDetails],
|
|
83
|
+
durationMs,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (verbose) {
|
|
87
|
+
console.log(`[Worker] Completed in ${durationMs}ms`);
|
|
88
|
+
console.log(`[Worker] Files modified: ${filesModified.length}`);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
success: true,
|
|
92
|
+
summary: resultMessage.result || lastAssistantText || "Implementation completed",
|
|
93
|
+
filesModified,
|
|
94
|
+
durationMs,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
const durationMs = Date.now() - startTime;
|
|
99
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
100
|
+
return {
|
|
101
|
+
success: false,
|
|
102
|
+
summary: `Worker error: ${errorMessage}`,
|
|
103
|
+
filesModified,
|
|
104
|
+
errors: [errorMessage],
|
|
105
|
+
durationMs,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=worker-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-agent.js","sourceRoot":"","sources":["../../src/memento/worker-agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAyB,MAAM,gCAAgC,CAAC;AAE9E,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAwB1E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAsB,EACtB,IAAwB,EACxB,UAA8B,EAAE;IAEhC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,EACJ,OAAO,GAAG,KAAK,EACf,KAAK,GAAG,mBAAmB,EAC3B,QAAQ,GAAG,EAAE,GACd,GAAG,OAAO,CAAC;IAEZ,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAC9D,MAAM,YAAY,GAAG,uBAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAEpE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,aAA2C,CAAC;IAEhD,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,KAAK,CAAC;YAC1B,MAAM;YACN,OAAO,EAAE;gBACP,KAAK;gBACL,QAAQ;gBACR,YAAY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C,aAAa;YACb,MAAM,EAAE,CAAC,YAAY,CAAC;YACtB,UAAU;SACX,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/mend/index.d.ts
CHANGED
|
@@ -31,11 +31,17 @@ export declare function autoFixNavigator(navPath: string, checks: MendCheckResul
|
|
|
31
31
|
action: string;
|
|
32
32
|
success: boolean;
|
|
33
33
|
}>>;
|
|
34
|
+
/**
|
|
35
|
+
* Run LLM-powered quality review on CLAUDE.md
|
|
36
|
+
* Uses Claude Opus to check for contradictions, best practices, hallucination risks, etc.
|
|
37
|
+
*/
|
|
38
|
+
export declare function reviewNavigatorQuality(navPath: string): Promise<MendCheckResult[]>;
|
|
34
39
|
/**
|
|
35
40
|
* Run full mend operation: check health and auto-fix issues
|
|
36
41
|
*/
|
|
37
42
|
export declare function mendNavigator(navPath: string, options?: {
|
|
38
43
|
autoFix?: boolean;
|
|
39
44
|
quiet?: boolean;
|
|
45
|
+
review?: boolean;
|
|
40
46
|
}): Promise<MendResult>;
|
|
41
47
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mend/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mend/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mend/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACnE;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CA6Q/E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,eAAe,EAAE,GACxB,OAAO,CAAC,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,CAwGrE;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA4CxF;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CACb,GACL,OAAO,CAAC,UAAU,CAAC,CA6BrB"}
|
package/dist/mend/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import * as fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import { NavigatorConfigSchema, getSkillName, getUpdateSkillName, localSkillExists, skillExists, isSkillSymlink, createAndSymlinkSkill, createAndSymlinkUpdateSkill, } from "@autonav/communication-layer";
|
|
9
|
+
import { reviewClaudeMd } from "./llm-review.js";
|
|
9
10
|
/**
|
|
10
11
|
* Run all health checks on a navigator
|
|
11
12
|
*/
|
|
@@ -73,6 +74,7 @@ export async function checkNavigatorHealth(navPath) {
|
|
|
73
74
|
}
|
|
74
75
|
// 3. Check CLAUDE.md exists
|
|
75
76
|
const claudeMdPath = path.join(navPath, "CLAUDE.md");
|
|
77
|
+
let claudeMdContent = null;
|
|
76
78
|
if (!fs.existsSync(claudeMdPath)) {
|
|
77
79
|
checks.push({
|
|
78
80
|
check: "CLAUDE.md",
|
|
@@ -83,7 +85,7 @@ export async function checkNavigatorHealth(navPath) {
|
|
|
83
85
|
}
|
|
84
86
|
else {
|
|
85
87
|
// Check for required sections
|
|
86
|
-
|
|
88
|
+
claudeMdContent = fs.readFileSync(claudeMdPath, "utf-8");
|
|
87
89
|
const requiredSections = ["## Grounding Rules"];
|
|
88
90
|
const missingSections = requiredSections.filter(section => !claudeMdContent.includes(section));
|
|
89
91
|
if (missingSections.length > 0) {
|
|
@@ -103,6 +105,43 @@ export async function checkNavigatorHealth(navPath) {
|
|
|
103
105
|
autoFixable: false,
|
|
104
106
|
});
|
|
105
107
|
}
|
|
108
|
+
// 3a. Check CLAUDE.md doesn't have submit_answer instructions
|
|
109
|
+
// (submit_answer is injected at query-time by createAnswerQuestionPrompt)
|
|
110
|
+
if (claudeMdContent.includes("submit_answer")) {
|
|
111
|
+
checks.push({
|
|
112
|
+
check: "submit_answer in CLAUDE.md",
|
|
113
|
+
status: "warning",
|
|
114
|
+
message: "CLAUDE.md contains submit_answer instructions",
|
|
115
|
+
details: "submit_answer is injected at query-time and should not be in CLAUDE.md. Run 'autonav migrate' to fix, or manually remove the references.",
|
|
116
|
+
autoFixable: false, // Migration v1.3.1 handles this
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
checks.push({
|
|
121
|
+
check: "submit_answer in CLAUDE.md",
|
|
122
|
+
status: "pass",
|
|
123
|
+
message: "CLAUDE.md correctly omits submit_answer (injected at query-time)",
|
|
124
|
+
autoFixable: false,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// 3b. Check CLAUDE.md has autonav mend instruction
|
|
128
|
+
if (!claudeMdContent.includes("autonav mend")) {
|
|
129
|
+
checks.push({
|
|
130
|
+
check: "autonav mend instruction",
|
|
131
|
+
status: "warning",
|
|
132
|
+
message: "CLAUDE.md missing 'autonav mend' instruction",
|
|
133
|
+
details: "Navigators should remind users to run mend after config changes. Consider regenerating CLAUDE.md or adding the instruction manually.",
|
|
134
|
+
autoFixable: false,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
checks.push({
|
|
139
|
+
check: "autonav mend instruction",
|
|
140
|
+
status: "pass",
|
|
141
|
+
message: "CLAUDE.md includes mend instruction",
|
|
142
|
+
autoFixable: false,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
106
145
|
}
|
|
107
146
|
// 4. Check knowledge base directory exists
|
|
108
147
|
const knowledgePath = config.knowledgeBasePath
|
|
@@ -343,6 +382,51 @@ export async function autoFixNavigator(navPath, checks) {
|
|
|
343
382
|
}
|
|
344
383
|
return fixes;
|
|
345
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Run LLM-powered quality review on CLAUDE.md
|
|
387
|
+
* Uses Claude Opus to check for contradictions, best practices, hallucination risks, etc.
|
|
388
|
+
*/
|
|
389
|
+
export async function reviewNavigatorQuality(navPath) {
|
|
390
|
+
const checks = [];
|
|
391
|
+
const claudeMdPath = path.join(navPath, "CLAUDE.md");
|
|
392
|
+
if (!fs.existsSync(claudeMdPath)) {
|
|
393
|
+
return checks; // Skip review if no CLAUDE.md
|
|
394
|
+
}
|
|
395
|
+
const content = fs.readFileSync(claudeMdPath, "utf-8");
|
|
396
|
+
const review = await reviewClaudeMd(content);
|
|
397
|
+
if (review.passed && review.issues.length === 0) {
|
|
398
|
+
checks.push({
|
|
399
|
+
check: "CLAUDE.md quality review",
|
|
400
|
+
status: "pass",
|
|
401
|
+
message: review.summary,
|
|
402
|
+
autoFixable: false,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
// Add a check for each issue
|
|
407
|
+
for (const issue of review.issues) {
|
|
408
|
+
checks.push({
|
|
409
|
+
check: `CLAUDE.md: ${issue.category}`,
|
|
410
|
+
status: issue.severity === "error" ? "fail" : "warning",
|
|
411
|
+
message: issue.description,
|
|
412
|
+
details: issue.suggestion
|
|
413
|
+
? `${issue.location ? `Location: ${issue.location}. ` : ""}Suggestion: ${issue.suggestion}`
|
|
414
|
+
: issue.location,
|
|
415
|
+
autoFixable: false,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
// Add summary as info
|
|
419
|
+
if (review.summary) {
|
|
420
|
+
checks.push({
|
|
421
|
+
check: "CLAUDE.md quality summary",
|
|
422
|
+
status: review.passed ? "pass" : "warning",
|
|
423
|
+
message: review.summary,
|
|
424
|
+
autoFixable: false,
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return checks;
|
|
429
|
+
}
|
|
346
430
|
/**
|
|
347
431
|
* Run full mend operation: check health and auto-fix issues
|
|
348
432
|
*/
|
|
@@ -361,6 +445,13 @@ export async function mendNavigator(navPath, options = {}) {
|
|
|
361
445
|
result.checks = recheckResult.checks;
|
|
362
446
|
}
|
|
363
447
|
}
|
|
448
|
+
// Run LLM quality review if requested
|
|
449
|
+
if (options.review) {
|
|
450
|
+
const reviewChecks = await reviewNavigatorQuality(navPath);
|
|
451
|
+
result.checks.push(...reviewChecks);
|
|
452
|
+
// Re-evaluate overall health (review errors can affect health)
|
|
453
|
+
result.healthy = !result.checks.some(c => c.status === "fail");
|
|
454
|
+
}
|
|
364
455
|
return result;
|
|
365
456
|
}
|
|
366
457
|
//# sourceMappingURL=index.js.map
|