@autonav/core 1.5.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-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/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/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/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,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts for Memento Loop
|
|
3
|
+
*
|
|
4
|
+
* System prompts and user prompts for navigator and worker agents.
|
|
5
|
+
* Uses shared Agent Identity Protocol from communication-layer.
|
|
6
|
+
*
|
|
7
|
+
* Design principle: The WORKER forgets between iterations (memento pattern).
|
|
8
|
+
* The NAVIGATOR maintains its own memory and knowledge base - we just provide
|
|
9
|
+
* git history as context about what the worker has accomplished so far.
|
|
10
|
+
*/
|
|
11
|
+
import { buildAgentIdentityProtocol, } from "@autonav/communication-layer";
|
|
12
|
+
/**
|
|
13
|
+
* Build the prompt for the navigator to provide an implementation plan
|
|
14
|
+
*
|
|
15
|
+
* Uses Agent Identity Protocol when navigator identity is available.
|
|
16
|
+
* Git history is provided as context about what the worker has done,
|
|
17
|
+
* but the navigator maintains its own knowledge and memory.
|
|
18
|
+
*/
|
|
19
|
+
export function buildNavPlanPrompt(context, gitLog, navigatorIdentity) {
|
|
20
|
+
const iterationInfo = context.maxIterations > 0
|
|
21
|
+
? `Iteration ${context.iteration} of ${context.maxIterations}`
|
|
22
|
+
: `Iteration ${context.iteration}`;
|
|
23
|
+
// Agent Identity Protocol: Explicit role identification and mutual acknowledgment
|
|
24
|
+
const identityProtocol = buildAgentIdentityProtocol(navigatorIdentity, {
|
|
25
|
+
name: "Autonav Memento Loop",
|
|
26
|
+
request: "The memento loop is coordinating implementation work on behalf of the user. Please provide the next implementation plan using the `submit_implementation_plan` tool.",
|
|
27
|
+
});
|
|
28
|
+
return `${identityProtocol}# Memento Loop - Planning Phase
|
|
29
|
+
|
|
30
|
+
You are the **Navigator** guiding a memento loop. Your job is to provide the next implementation plan for the worker agent.
|
|
31
|
+
|
|
32
|
+
## Task
|
|
33
|
+
|
|
34
|
+
${context.task}
|
|
35
|
+
|
|
36
|
+
## Current State
|
|
37
|
+
|
|
38
|
+
- **${iterationInfo}**
|
|
39
|
+
- **Code Directory:** ${context.codeDirectory}
|
|
40
|
+
- **Branch:** ${context.branch || "(default branch)"}
|
|
41
|
+
|
|
42
|
+
## Recent Git History (Worker's Progress)
|
|
43
|
+
|
|
44
|
+
The worker agent has made the following commits. Use this to understand what has been implemented so far:
|
|
45
|
+
|
|
46
|
+
\`\`\`
|
|
47
|
+
${gitLog || "(No commits yet)"}
|
|
48
|
+
\`\`\`
|
|
49
|
+
|
|
50
|
+
## Instructions
|
|
51
|
+
|
|
52
|
+
1. **Analyze** the current state - you may explore the codebase, consult your knowledge base, or use any resources you have
|
|
53
|
+
2. **Determine** what work remains to complete the task
|
|
54
|
+
3. **Create** a focused implementation plan for the next iteration
|
|
55
|
+
4. **Use the submit_implementation_plan tool** to submit your plan
|
|
56
|
+
|
|
57
|
+
### About the Memento Loop
|
|
58
|
+
|
|
59
|
+
- The **worker agent forgets** between iterations (it has no memory of previous work)
|
|
60
|
+
- **You** (the navigator) maintain continuity - use your knowledge and judgment
|
|
61
|
+
- The git history shows what the worker has accomplished so far
|
|
62
|
+
- Keep plans focused and incremental - the worker implements one plan at a time
|
|
63
|
+
- Set \`isComplete: true\` when the entire task is done
|
|
64
|
+
- The worker agent will implement your plan, not you
|
|
65
|
+
|
|
66
|
+
Submit your implementation plan now using the \`submit_implementation_plan\` tool.`;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Build the system prompt for the navigator agent
|
|
70
|
+
*/
|
|
71
|
+
export function buildNavSystemPrompt(navSystemPrompt) {
|
|
72
|
+
return `${navSystemPrompt}
|
|
73
|
+
|
|
74
|
+
# Memento Loop Navigator Role
|
|
75
|
+
|
|
76
|
+
You are acting as the **Navigator** in a memento loop. Your responsibilities:
|
|
77
|
+
|
|
78
|
+
1. **Analyze** the current state of the codebase
|
|
79
|
+
2. **Plan** the next implementation steps
|
|
80
|
+
3. **Submit** structured plans via the \`submit_implementation_plan\` tool
|
|
81
|
+
4. **Determine** when the task is complete
|
|
82
|
+
|
|
83
|
+
You do NOT implement code yourself. You provide plans for the worker agent.
|
|
84
|
+
|
|
85
|
+
## Key Principles
|
|
86
|
+
|
|
87
|
+
- Be specific and actionable in your plans
|
|
88
|
+
- Reference concrete files and commands
|
|
89
|
+
- Include clear validation criteria
|
|
90
|
+
- Only mark complete when ALL requirements are met
|
|
91
|
+
- Use conventional commit style for plan summaries (e.g., "feat: add user auth", "fix: resolve login bug")`;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Build the prompt for the worker agent to implement a plan
|
|
95
|
+
*/
|
|
96
|
+
export function buildWorkerPrompt(codeDirectory, plan) {
|
|
97
|
+
const stepsText = plan.steps
|
|
98
|
+
.map((step, i) => `### Step ${i + 1}: ${step.description}
|
|
99
|
+
${step.files?.length ? `- Files: ${step.files.join(", ")}` : ""}
|
|
100
|
+
${step.commands?.length ? `- Commands: ${step.commands.join(", ")}` : ""}`)
|
|
101
|
+
.join("\n\n");
|
|
102
|
+
const validationText = plan.validationCriteria
|
|
103
|
+
.map((c, i) => `${i + 1}. ${c}`)
|
|
104
|
+
.join("\n");
|
|
105
|
+
return `# Implementation Task
|
|
106
|
+
|
|
107
|
+
## Plan Summary
|
|
108
|
+
|
|
109
|
+
${plan.summary}
|
|
110
|
+
|
|
111
|
+
## Steps to Implement
|
|
112
|
+
|
|
113
|
+
${stepsText}
|
|
114
|
+
|
|
115
|
+
## Validation Criteria
|
|
116
|
+
|
|
117
|
+
After implementation, verify:
|
|
118
|
+
${validationText}
|
|
119
|
+
|
|
120
|
+
## Instructions
|
|
121
|
+
|
|
122
|
+
1. Implement each step in order
|
|
123
|
+
2. After completing all steps, run the validation checks
|
|
124
|
+
3. **Review your code** - read through what you wrote and check for:
|
|
125
|
+
- Bugs or logic errors
|
|
126
|
+
- Missing error handling
|
|
127
|
+
- Code style issues
|
|
128
|
+
- Incomplete implementations
|
|
129
|
+
4. Fix any issues before finishing
|
|
130
|
+
5. Report what you accomplished
|
|
131
|
+
|
|
132
|
+
**Important:** Your changes will be committed automatically after you finish. Make sure the code is ready for commit - review and fix before completing.
|
|
133
|
+
|
|
134
|
+
**Working Directory:** ${codeDirectory}
|
|
135
|
+
|
|
136
|
+
Begin implementation now.`;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Build the system prompt for the worker agent
|
|
140
|
+
*/
|
|
141
|
+
export function buildWorkerSystemPrompt(codeDirectory) {
|
|
142
|
+
return `You are a **Worker Agent** implementing code changes.
|
|
143
|
+
|
|
144
|
+
## Your Role
|
|
145
|
+
|
|
146
|
+
You receive implementation plans from the Navigator and execute them precisely.
|
|
147
|
+
|
|
148
|
+
## Guidelines
|
|
149
|
+
|
|
150
|
+
1. **Execute** each step in the plan
|
|
151
|
+
2. **Verify** your work against the validation criteria
|
|
152
|
+
3. **Review** your code before finishing - check for bugs, missing error handling, style issues
|
|
153
|
+
4. **Fix** any issues you find
|
|
154
|
+
5. **Report** what you accomplished
|
|
155
|
+
|
|
156
|
+
## Working Directory
|
|
157
|
+
|
|
158
|
+
All file paths are relative to: ${codeDirectory}
|
|
159
|
+
|
|
160
|
+
## Important
|
|
161
|
+
|
|
162
|
+
- Focus on implementing the plan, not redesigning it
|
|
163
|
+
- If something is unclear, make reasonable assumptions
|
|
164
|
+
- Report any blockers or issues clearly
|
|
165
|
+
- Do not add features beyond what the plan specifies
|
|
166
|
+
- **Review your code** - your changes are committed automatically when you finish`;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/memento/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,0BAA0B,GAE3B,MAAM,8BAA8B,CAAC;AAiBtC;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAyB,EACzB,MAAc,EACd,iBAA4C;IAE5C,MAAM,aAAa,GACjB,OAAO,CAAC,aAAa,GAAG,CAAC;QACvB,CAAC,CAAC,aAAa,OAAO,CAAC,SAAS,OAAO,OAAO,CAAC,aAAa,EAAE;QAC9D,CAAC,CAAC,aAAa,OAAO,CAAC,SAAS,EAAE,CAAC;IAEvC,kFAAkF;IAClF,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,iBAAiB,EAAE;QACrE,IAAI,EAAE,sBAAsB;QAC5B,OAAO,EACL,sKAAsK;KACzK,CAAC,CAAC;IAEH,OAAO,GAAG,gBAAgB;;;;;;EAM1B,OAAO,CAAC,IAAI;;;;MAIR,aAAa;wBACK,OAAO,CAAC,aAAa;gBAC7B,OAAO,CAAC,MAAM,IAAI,kBAAkB;;;;;;;EAOlD,MAAM,IAAI,kBAAkB;;;;;;;;;;;;;;;;;;;mFAmBqD,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,eAAuB;IAC1D,OAAO,G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7
|
+
import type { MementoState, MementoOptions } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Get the path to the state file for a code directory
|
|
10
|
+
*/
|
|
11
|
+
export declare function getStatePath(codeDirectory: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a memento state file exists
|
|
14
|
+
*/
|
|
15
|
+
export declare function stateExists(codeDirectory: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Load existing state from disk
|
|
18
|
+
*
|
|
19
|
+
* @throws {Error} If state file doesn't exist or is invalid
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadState(codeDirectory: string): MementoState;
|
|
22
|
+
/**
|
|
23
|
+
* Save state to disk atomically
|
|
24
|
+
*
|
|
25
|
+
* Uses temp file + rename pattern to prevent corruption
|
|
26
|
+
*/
|
|
27
|
+
export declare function saveState(state: MementoState): void;
|
|
28
|
+
/**
|
|
29
|
+
* Initialize a new memento state
|
|
30
|
+
*/
|
|
31
|
+
export declare function initializeState(codeDirectory: string, navDirectory: string, task: string, options: MementoOptions): MementoState;
|
|
32
|
+
/**
|
|
33
|
+
* Increment iteration counter and record timestamp
|
|
34
|
+
*/
|
|
35
|
+
export declare function incrementIteration(state: MementoState): MementoState;
|
|
36
|
+
/**
|
|
37
|
+
* Record a plan in history
|
|
38
|
+
*/
|
|
39
|
+
export declare function recordPlan(state: MementoState, summary: string): MementoState;
|
|
40
|
+
/**
|
|
41
|
+
* Mark the loop as completed
|
|
42
|
+
*/
|
|
43
|
+
export declare function completeLoop(state: MementoState, completionMessage?: string): MementoState;
|
|
44
|
+
/**
|
|
45
|
+
* Check if the loop should continue
|
|
46
|
+
*/
|
|
47
|
+
export declare function shouldContinue(state: MementoState): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Delete state file (cleanup after successful completion)
|
|
50
|
+
*/
|
|
51
|
+
export declare function deleteState(codeDirectory: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get or initialize state based on options
|
|
54
|
+
*/
|
|
55
|
+
export declare function getOrInitializeState(codeDirectory: string, navDirectory: string, task: string, options: MementoOptions): MementoState;
|
|
56
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/memento/state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAM/D;;GAEG;AACH,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,YAAY,CAmB7D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAgBnD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,GACtB,YAAY,CAmBd;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,CAKpE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,CAQ7E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,YAAY,CAK1F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAU3D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAMvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,GACtB,YAAY,CAsBd"}
|
|
@@ -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;QAC9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AAE,CAAC;QAClD,OAAO,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;;;;;;;;;;;;;;;;;;;;;;;;;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
@@ -0,0 +1,30 @@
|
|
|
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"}
|