@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.
Files changed (84) hide show
  1. package/dist/cli/autonav.d.ts +1 -0
  2. package/dist/cli/autonav.d.ts.map +1 -1
  3. package/dist/cli/autonav.js +7 -0
  4. package/dist/cli/autonav.js.map +1 -1
  5. package/dist/cli/nav-init.js +17 -3
  6. package/dist/cli/nav-init.js.map +1 -1
  7. package/dist/cli/nav-memento.d.ts +20 -0
  8. package/dist/cli/nav-memento.d.ts.map +1 -0
  9. package/dist/cli/nav-memento.js +179 -0
  10. package/dist/cli/nav-memento.js.map +1 -0
  11. package/dist/cli/nav-mend.js +7 -0
  12. package/dist/cli/nav-mend.js.map +1 -1
  13. package/dist/memento/git-operations.d.ts +95 -0
  14. package/dist/memento/git-operations.d.ts.map +1 -0
  15. package/dist/memento/git-operations.js +256 -0
  16. package/dist/memento/git-operations.js.map +1 -0
  17. package/dist/memento/index.d.ts +31 -0
  18. package/dist/memento/index.d.ts.map +1 -0
  19. package/dist/memento/index.js +38 -0
  20. package/dist/memento/index.js.map +1 -0
  21. package/dist/memento/loop.d.ts +33 -0
  22. package/dist/memento/loop.d.ts.map +1 -0
  23. package/dist/memento/loop.js +535 -0
  24. package/dist/memento/loop.js.map +1 -0
  25. package/dist/memento/matrix-animation.d.ts +77 -0
  26. package/dist/memento/matrix-animation.d.ts.map +1 -0
  27. package/dist/memento/matrix-animation.js +228 -0
  28. package/dist/memento/matrix-animation.js.map +1 -0
  29. package/dist/memento/nav-protocol.d.ts +30 -0
  30. package/dist/memento/nav-protocol.d.ts.map +1 -0
  31. package/dist/memento/nav-protocol.js +79 -0
  32. package/dist/memento/nav-protocol.js.map +1 -0
  33. package/dist/memento/prompts.d.ts +44 -0
  34. package/dist/memento/prompts.d.ts.map +1 -0
  35. package/dist/memento/prompts.js +168 -0
  36. package/dist/memento/prompts.js.map +1 -0
  37. package/dist/memento/state.d.ts +56 -0
  38. package/dist/memento/state.d.ts.map +1 -0
  39. package/dist/memento/state.js +156 -0
  40. package/dist/memento/state.js.map +1 -0
  41. package/dist/memento/types.d.ts +123 -0
  42. package/dist/memento/types.d.ts.map +1 -0
  43. package/dist/memento/types.js +30 -0
  44. package/dist/memento/types.js.map +1 -0
  45. package/dist/memento/worker-agent.d.ts +30 -0
  46. package/dist/memento/worker-agent.d.ts.map +1 -0
  47. package/dist/memento/worker-agent.js +109 -0
  48. package/dist/memento/worker-agent.js.map +1 -0
  49. package/dist/mend/index.d.ts +6 -0
  50. package/dist/mend/index.d.ts.map +1 -1
  51. package/dist/mend/index.js +92 -1
  52. package/dist/mend/index.js.map +1 -1
  53. package/dist/mend/llm-review.d.ts +18 -0
  54. package/dist/mend/llm-review.d.ts.map +1 -0
  55. package/dist/mend/llm-review.js +81 -0
  56. package/dist/mend/llm-review.js.map +1 -0
  57. package/dist/migrations/index.d.ts.map +1 -1
  58. package/dist/migrations/index.js +4 -0
  59. package/dist/migrations/index.js.map +1 -1
  60. package/dist/migrations/versions/v1.4.0-rfc2119-skills.d.ts +18 -0
  61. package/dist/migrations/versions/v1.4.0-rfc2119-skills.d.ts.map +1 -0
  62. package/dist/migrations/versions/v1.4.0-rfc2119-skills.js +207 -0
  63. package/dist/migrations/versions/v1.4.0-rfc2119-skills.js.map +1 -0
  64. package/dist/migrations/versions/v1.5.1-mend-instruction.d.ts +13 -0
  65. package/dist/migrations/versions/v1.5.1-mend-instruction.d.ts.map +1 -0
  66. package/dist/migrations/versions/v1.5.1-mend-instruction.js +156 -0
  67. package/dist/migrations/versions/v1.5.1-mend-instruction.js.map +1 -0
  68. package/package.json +1 -1
  69. package/dist/skill-generator/index.d.ts +0 -142
  70. package/dist/skill-generator/index.d.ts.map +0 -1
  71. package/dist/skill-generator/index.js +0 -510
  72. package/dist/skill-generator/index.js.map +0 -1
  73. package/dist/templates/.gitignore.template +0 -26
  74. package/dist/templates/CLAUDE-pack.md.template +0 -114
  75. package/dist/templates/CLAUDE.md.template +0 -153
  76. package/dist/templates/README.md.template +0 -174
  77. package/dist/templates/config-pack.json.template +0 -16
  78. package/dist/templates/config.json.template +0 -11
  79. package/dist/templates/index.d.ts +0 -22
  80. package/dist/templates/index.d.ts.map +0 -1
  81. package/dist/templates/index.js +0 -32
  82. package/dist/templates/index.js.map +0 -1
  83. package/dist/templates/plugins.json.template +0 -33
  84. package/dist/templates/system-configuration.md.template +0 -70
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Matrix-style Digital Rain Animation for CLI
3
+ *
4
+ * A non-React version of the matrix animation for use in pure CLI scripts.
5
+ * Uses direct stdout writes with ANSI escape codes.
6
+ */
7
+ import chalk from "chalk";
8
+ /** Glyph set: blocks and numbers */
9
+ const GLYPHS = [
10
+ "░", "▒", "▓", "█", "▀", "▄", "■", "□",
11
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
12
+ "░", "▒", "▓", "█", "▀", "▄", "■", "□",
13
+ ];
14
+ /** Brightness levels (RGB) for green fade */
15
+ const BRIGHTNESS = [
16
+ { r: 0, g: 255, b: 70 }, // Bright
17
+ { r: 0, g: 190, b: 0 }, // Medium
18
+ { r: 0, g: 100, b: 0 }, // Dim
19
+ { r: 0, g: 40, b: 0 }, // Darkest
20
+ ];
21
+ /** Color functions for each brightness level */
22
+ const COLORS = BRIGHTNESS.map(({ r, g, b }) => chalk.rgb(r, g, b));
23
+ /**
24
+ * Get a random glyph
25
+ */
26
+ function randomGlyph() {
27
+ return GLYPHS[Math.floor(Math.random() * GLYPHS.length)] ?? "█";
28
+ }
29
+ /**
30
+ * Calculate brightness based on position and time
31
+ */
32
+ function calculateBrightness(position, tick, lineOffset) {
33
+ const wave = Math.sin((position + tick + lineOffset * 10) / 4);
34
+ return Math.floor((wave + 1) * 1.5) % 4;
35
+ }
36
+ /**
37
+ * Create a strip of matrix characters
38
+ */
39
+ function createStrip(width, tick, lineOffset) {
40
+ return Array.from({ length: width }, (_, i) => ({
41
+ char: randomGlyph(),
42
+ brightness: calculateBrightness(i, tick, lineOffset),
43
+ }));
44
+ }
45
+ /**
46
+ * Update strip with new brightness wave and random char changes
47
+ */
48
+ function updateStrip(strip, tick, lineOffset) {
49
+ return strip.map((item, i) => ({
50
+ char: Math.random() < 0.2 ? randomGlyph() : item.char,
51
+ brightness: calculateBrightness(i, tick, lineOffset),
52
+ }));
53
+ }
54
+ /**
55
+ * Render a strip to a colored string
56
+ */
57
+ function renderStrip(strip) {
58
+ return strip
59
+ .map((item) => {
60
+ const colorFn = COLORS[item.brightness] ?? COLORS[3];
61
+ return colorFn(item.char);
62
+ })
63
+ .join("");
64
+ }
65
+ /**
66
+ * Format stats for display
67
+ */
68
+ function formatStats(stats) {
69
+ const tool = stats.lastTool ? chalk.cyan(stats.lastTool) : chalk.dim("--");
70
+ const added = stats.linesAdded > 0 ? chalk.green(`+${stats.linesAdded}`) : chalk.dim("+0");
71
+ const removed = stats.linesRemoved > 0 ? chalk.red(`-${stats.linesRemoved}`) : chalk.dim("-0");
72
+ const diff = `${added}/${removed}`;
73
+ const tokenPct = stats.tokensMax > 0
74
+ ? Math.round((stats.tokensUsed / stats.tokensMax) * 100)
75
+ : 0;
76
+ const tokenColor = tokenPct > 80 ? chalk.red : tokenPct > 50 ? chalk.yellow : chalk.green;
77
+ const tokens = `${tokenColor(stats.tokensUsed.toLocaleString())}/${chalk.dim(stats.tokensMax.toLocaleString())}`;
78
+ return `${chalk.dim("Tool:")} ${tool} ${chalk.dim("Diff:")} ${diff} ${chalk.dim("Tokens:")} ${tokens}`;
79
+ }
80
+ /**
81
+ * Matrix animation controller with status line
82
+ */
83
+ export class MatrixAnimation {
84
+ strips = [];
85
+ tick = 0;
86
+ timer = null;
87
+ message;
88
+ width;
89
+ lines;
90
+ interval;
91
+ stats;
92
+ totalLines; // rain + message + status
93
+ constructor(options = {}) {
94
+ this.message = options.message ?? "Processing...";
95
+ this.width = options.width ?? 50;
96
+ this.lines = options.lines ?? 3;
97
+ this.interval = options.interval ?? 80;
98
+ this.stats = {
99
+ linesAdded: 0,
100
+ linesRemoved: 0,
101
+ tokensUsed: 0,
102
+ tokensMax: 200000, // Default Claude context
103
+ };
104
+ this.totalLines = this.lines + 1; // rain lines + status line
105
+ // Initialize strips
106
+ this.strips = Array.from({ length: this.lines }, (_, i) => createStrip(this.width, 0, i));
107
+ }
108
+ /**
109
+ * Start the animation
110
+ */
111
+ start() {
112
+ if (this.timer)
113
+ return;
114
+ // Hide cursor
115
+ process.stdout.write("\x1B[?25l");
116
+ // Initial render
117
+ this.render();
118
+ // Start animation loop
119
+ this.timer = setInterval(() => {
120
+ this.tick += 1;
121
+ this.strips = this.strips.map((strip, i) => updateStrip(strip, this.tick, i));
122
+ this.render();
123
+ }, this.interval);
124
+ }
125
+ /**
126
+ * Update the message
127
+ */
128
+ setMessage(message) {
129
+ this.message = message;
130
+ }
131
+ /**
132
+ * Update stats
133
+ */
134
+ setStats(stats) {
135
+ this.stats = { ...this.stats, ...stats };
136
+ }
137
+ /**
138
+ * Update last tool
139
+ */
140
+ setLastTool(tool) {
141
+ this.stats.lastTool = tool;
142
+ }
143
+ /**
144
+ * Add to line counts
145
+ */
146
+ addLines(added, removed) {
147
+ this.stats.linesAdded += added;
148
+ this.stats.linesRemoved += removed;
149
+ }
150
+ /**
151
+ * Update token usage
152
+ */
153
+ setTokens(used, max) {
154
+ this.stats.tokensUsed = used;
155
+ if (max !== undefined) {
156
+ this.stats.tokensMax = max;
157
+ }
158
+ }
159
+ /**
160
+ * Get current stats
161
+ */
162
+ getStats() {
163
+ return { ...this.stats };
164
+ }
165
+ /**
166
+ * Render current state
167
+ */
168
+ render() {
169
+ // Move cursor up to overwrite previous output
170
+ if (this.tick > 0) {
171
+ process.stdout.write(`\x1B[${this.totalLines}A`);
172
+ }
173
+ // Render rain lines
174
+ for (let i = 0; i < this.lines; i++) {
175
+ const strip = this.strips[i];
176
+ if (!strip)
177
+ continue;
178
+ const rendered = renderStrip(strip);
179
+ // Add message on last rain line
180
+ if (i === this.lines - 1) {
181
+ process.stdout.write(`\r${rendered} ${chalk.gray(this.message)}\x1B[K\n`);
182
+ }
183
+ else {
184
+ process.stdout.write(`\r${rendered}\x1B[K\n`);
185
+ }
186
+ }
187
+ // Render status line
188
+ process.stdout.write(`\r${formatStats(this.stats)}\x1B[K\n`);
189
+ }
190
+ /**
191
+ * Stop the animation and show final message
192
+ */
193
+ stop(finalMessage) {
194
+ if (this.timer) {
195
+ clearInterval(this.timer);
196
+ this.timer = null;
197
+ }
198
+ // Move cursor up and clear lines
199
+ process.stdout.write(`\x1B[${this.totalLines}A`);
200
+ for (let i = 0; i < this.totalLines; i++) {
201
+ process.stdout.write(`\r\x1B[K\n`);
202
+ }
203
+ process.stdout.write(`\x1B[${this.totalLines}A`);
204
+ // Show cursor
205
+ process.stdout.write("\x1B[?25h");
206
+ // Print final message if provided
207
+ if (finalMessage) {
208
+ console.log(finalMessage);
209
+ }
210
+ }
211
+ }
212
+ /**
213
+ * Run animation while a promise executes
214
+ */
215
+ export async function withMatrixAnimation(promise, message) {
216
+ const animation = new MatrixAnimation({ message });
217
+ animation.start();
218
+ try {
219
+ const result = await promise;
220
+ animation.stop();
221
+ return result;
222
+ }
223
+ catch (error) {
224
+ animation.stop();
225
+ throw error;
226
+ }
227
+ }
228
+ //# sourceMappingURL=matrix-animation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix-animation.js","sourceRoot":"","sources":["../../src/memento/matrix-animation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,oCAAoC;AACpC,MAAM,MAAM,GAAG;IACb,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IACtC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IACh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C,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QAEjD,cAAc;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAElC,kCAAkC;QAClC,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAAmB,EACnB,OAAe;IAEf,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IACnD,SAAS,CAAC,KAAK,EAAE,CAAC;IAElB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;QAC7B,SAAS,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,SAAS,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Navigator Protocol for Memento Loop
3
+ *
4
+ * MCP server providing the submit_implementation_plan tool
5
+ * for navigators to submit structured implementation plans.
6
+ */
7
+ import { type ImplementationPlan } from "./types.js";
8
+ /**
9
+ * Tool name for plan submission
10
+ */
11
+ export declare const SUBMIT_PLAN_TOOL = "submit_implementation_plan";
12
+ /**
13
+ * Result captured from plan submission
14
+ */
15
+ export interface PlanSubmissionResult {
16
+ plan: ImplementationPlan;
17
+ submitted: boolean;
18
+ }
19
+ /**
20
+ * Create an MCP server with the submit_implementation_plan tool
21
+ *
22
+ * The tool validates plans against the ImplementationPlanSchema
23
+ * and returns structured data for the memento loop.
24
+ */
25
+ export declare function createNavProtocolMcpServer(): {
26
+ server: import("@anthropic-ai/claude-agent-sdk").McpSdkServerConfigWithInstance;
27
+ getCapturedPlan: () => ImplementationPlan | null;
28
+ resetCapturedPlan: () => void;
29
+ };
30
+ //# sourceMappingURL=nav-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nav-protocol.d.ts","sourceRoot":"","sources":["../../src/memento/nav-protocol.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAA4B,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B;;2BA+EjB,kBAAkB,GAAG,IAAI;;EAKjD"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Navigator Protocol for Memento Loop
3
+ *
4
+ * MCP server providing the submit_implementation_plan tool
5
+ * for navigators to submit structured implementation plans.
6
+ */
7
+ import { z } from "zod";
8
+ import { tool, createSdkMcpServer } from "@anthropic-ai/claude-agent-sdk";
9
+ import { ImplementationPlanSchema } from "./types.js";
10
+ /**
11
+ * Tool name for plan submission
12
+ */
13
+ export const SUBMIT_PLAN_TOOL = "submit_implementation_plan";
14
+ /**
15
+ * Create an MCP server with the submit_implementation_plan tool
16
+ *
17
+ * The tool validates plans against the ImplementationPlanSchema
18
+ * and returns structured data for the memento loop.
19
+ */
20
+ export function createNavProtocolMcpServer() {
21
+ // We'll capture the submitted plan via closure
22
+ let capturedPlan = null;
23
+ const submitPlanTool = tool(SUBMIT_PLAN_TOOL, `Submit your implementation plan for the current iteration. You MUST use this tool to provide your plan.
24
+
25
+ This tool allows you to:
26
+ 1. Define concrete implementation steps for the worker agent
27
+ 2. Specify validation criteria to verify the implementation
28
+ 3. Signal when the overall task is complete
29
+
30
+ When the task is fully complete, set isComplete to true and provide a completionMessage.
31
+
32
+ Do NOT respond with plain text - always use this tool to submit your plan.`, {
33
+ summary: z.string().min(10).describe("Brief summary of what this plan will accomplish in this iteration. Be specific about the goal."),
34
+ steps: z.array(z.object({
35
+ description: z.string().min(5).describe("Clear description of what this step accomplishes"),
36
+ files: z.array(z.string()).optional().describe("Specific files to create or modify (relative paths)"),
37
+ commands: z.array(z.string()).optional().describe("Shell commands to run (e.g., 'npm install', 'npm test')"),
38
+ })).min(1).describe("Ordered list of implementation steps. Each step should be atomic and verifiable."),
39
+ validationCriteria: z.array(z.string()).min(1).describe("How to verify the implementation worked. Include specific checks like 'npm test passes' or 'file X exists with content Y'."),
40
+ isComplete: z.boolean().describe("Set to true when the OVERALL TASK is complete and no more iterations are needed. " +
41
+ "Only set this to true when all requirements have been fulfilled."),
42
+ completionMessage: z.string().optional().describe("Message to display when isComplete is true. Summarize what was accomplished."),
43
+ }, async (args) => {
44
+ // Validate against the full schema
45
+ const plan = ImplementationPlanSchema.parse(args);
46
+ // Capture the plan for extraction
47
+ capturedPlan = plan;
48
+ // Return success message
49
+ return {
50
+ content: [
51
+ {
52
+ type: "text",
53
+ text: JSON.stringify({
54
+ success: true,
55
+ message: plan.isComplete
56
+ ? "Task marked as complete. Memento loop will end."
57
+ : `Plan submitted with ${plan.steps.length} steps. Worker will implement this.`,
58
+ plan,
59
+ }),
60
+ },
61
+ ],
62
+ isError: false,
63
+ };
64
+ });
65
+ const server = createSdkMcpServer({
66
+ name: "autonav-nav-protocol",
67
+ version: "1.0.0",
68
+ tools: [submitPlanTool],
69
+ });
70
+ // Expose method to get captured plan
71
+ return {
72
+ server,
73
+ getCapturedPlan: () => capturedPlan,
74
+ resetCapturedPlan: () => {
75
+ capturedPlan = null;
76
+ },
77
+ };
78
+ }
79
+ //# sourceMappingURL=nav-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nav-protocol.js","sourceRoot":"","sources":["../../src/memento/nav-protocol.ts"],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,CAC9B,mFAAmF;YACjF,kEAAkE,CACrE;QACD,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAC/C,8EAA8E,CAC/E;KACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,mCAAmC;QACnC,MAAM,IAAI,GAAG,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAElD,kCAAkC;QAClC,YAAY,GAAG,IAAI,CAAC;QAEpB,yBAAyB;QACzB,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,OAAO,EAAE,IAAI;wBACb,OAAO,EAAE,IAAI,CAAC,UAAU;4BACtB,CAAC,CAAC,iDAAiD;4BACnD,CAAC,CAAC,uBAAuB,IAAI,CAAC,KAAK,CAAC,MAAM,qCAAqC;wBACjF,IAAI;qBACL,CAAC;iBACH;aACF;YACD,OAAO,EAAE,KAAK;SACf,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,MAAM,MAAM,GAAG,kBAAkB,CAAC;QAChC,IAAI,EAAE,sBAAsB;QAC5B,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,CAAC,cAAc,CAAC;KACxB,CAAC,CAAC;IAEH,qCAAqC;IACrC,OAAO;QACL,MAAM;QACN,eAAe,EAAE,GAA8B,EAAE,CAAC,YAAY;QAC9D,iBAAiB,EAAE,GAAG,EAAE;YACtB,YAAY,GAAG,IAAI,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,44 @@
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 { type NavigatorIdentity } from "@autonav/communication-layer";
12
+ import type { ImplementationPlan } from "./types.js";
13
+ export type { NavigatorIdentity };
14
+ /**
15
+ * Minimal context passed to nav prompt (no persisted state)
16
+ */
17
+ interface NavPromptContext {
18
+ codeDirectory: string;
19
+ task: string;
20
+ iteration: number;
21
+ maxIterations: number;
22
+ branch?: string;
23
+ }
24
+ /**
25
+ * Build the prompt for the navigator to provide an implementation plan
26
+ *
27
+ * Uses Agent Identity Protocol when navigator identity is available.
28
+ * Git history is provided as context about what the worker has done,
29
+ * but the navigator maintains its own knowledge and memory.
30
+ */
31
+ export declare function buildNavPlanPrompt(context: NavPromptContext, gitLog: string, navigatorIdentity?: NavigatorIdentity | null): string;
32
+ /**
33
+ * Build the system prompt for the navigator agent
34
+ */
35
+ export declare function buildNavSystemPrompt(navSystemPrompt: string): string;
36
+ /**
37
+ * Build the prompt for the worker agent to implement a plan
38
+ */
39
+ export declare function buildWorkerPrompt(codeDirectory: string, plan: ImplementationPlan): string;
40
+ /**
41
+ * Build the system prompt for the worker agent
42
+ */
43
+ export declare function buildWorkerSystemPrompt(codeDirectory: string): string;
44
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/memento/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGrD,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC;;GAEG;AACH,UAAU,gBAAgB;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,MAAM,EACd,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,IAAI,GAC3C,MAAM,CAoDR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAqBpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,kBAAkB,GACvB,MAAM,CA8CR;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CA0BrE"}
@@ -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,GAAG,eAAe;;;;;;;;;;;;;;;;;;;2GAmBgF,CAAC;AAC5G,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,aAAqB,EACrB,IAAwB;IAExB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK;SACzB,GAAG,CACF,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CACV,YAAY,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,WAAW;EAC5C,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;EAC7D,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,eAAe,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CACrE;SACA,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB;SAC3C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;SAC/B,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;;;;EAIP,IAAI,CAAC,OAAO;;;;EAIZ,SAAS;;;;;EAKT,cAAc;;;;;;;;;;;;;;;;yBAgBS,aAAa;;0BAEZ,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,aAAqB;IAC3D,OAAO;;;;;;;;;;;;;;;;kCAgByB,aAAa;;;;;;;;kFAQmC,CAAC;AACnF,CAAC"}
@@ -0,0 +1,56 @@
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 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;;GAE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