@autonav/core 1.5.0 → 1.7.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/README.md +2 -2
- package/dist/adapter/index.d.ts +3 -3
- package/dist/adapter/index.d.ts.map +1 -1
- package/dist/adapter/index.js +3 -3
- package/dist/adapter/index.js.map +1 -1
- package/dist/adapter/navigator-adapter.d.ts +196 -0
- package/dist/adapter/navigator-adapter.d.ts.map +1 -0
- package/dist/adapter/navigator-adapter.js +579 -0
- package/dist/adapter/navigator-adapter.js.map +1 -0
- package/dist/cli/autonav.d.ts +2 -5
- package/dist/cli/autonav.d.ts.map +1 -1
- package/dist/cli/autonav.js +35 -49
- package/dist/cli/autonav.js.map +1 -1
- package/dist/cli/nav-chat.d.ts +2 -1
- package/dist/cli/nav-chat.d.ts.map +1 -1
- package/dist/cli/nav-chat.js +32 -3
- package/dist/cli/nav-chat.js.map +1 -1
- package/dist/cli/nav-init.d.ts +2 -1
- package/dist/cli/nav-init.d.ts.map +1 -1
- package/dist/cli/nav-init.js +12 -4
- package/dist/cli/nav-init.js.map +1 -1
- package/dist/cli/nav-install.d.ts +2 -1
- package/dist/cli/nav-install.d.ts.map +1 -1
- package/dist/cli/nav-install.js +4 -2
- package/dist/cli/nav-install.js.map +1 -1
- package/dist/cli/nav-memento.d.ts +21 -0
- package/dist/cli/nav-memento.d.ts.map +1 -0
- package/dist/cli/nav-memento.js +185 -0
- package/dist/cli/nav-memento.js.map +1 -0
- package/dist/cli/nav-mend.d.ts +2 -1
- package/dist/cli/nav-mend.d.ts.map +1 -1
- package/dist/cli/nav-mend.js +4 -1
- package/dist/cli/nav-mend.js.map +1 -1
- package/dist/cli/nav-migrate.d.ts +2 -1
- package/dist/cli/nav-migrate.d.ts.map +1 -1
- package/dist/cli/nav-migrate.js +2 -6
- package/dist/cli/nav-migrate.js.map +1 -1
- package/dist/cli/nav-query.d.ts +2 -1
- package/dist/cli/nav-query.d.ts.map +1 -1
- package/dist/cli/nav-query.js +12 -6
- package/dist/cli/nav-query.js.map +1 -1
- package/dist/cli/nav-standup.d.ts +18 -0
- package/dist/cli/nav-standup.d.ts.map +1 -0
- package/dist/cli/nav-standup.js +151 -0
- package/dist/cli/nav-standup.js.map +1 -0
- package/dist/cli/nav-uninstall.d.ts +2 -1
- package/dist/cli/nav-uninstall.d.ts.map +1 -1
- package/dist/cli/nav-uninstall.js +4 -2
- package/dist/cli/nav-uninstall.js.map +1 -1
- package/dist/cli/nav-update.d.ts +2 -1
- package/dist/cli/nav-update.d.ts.map +1 -1
- package/dist/cli/nav-update.js +11 -6
- package/dist/cli/nav-update.js.map +1 -1
- package/dist/conversation/App.d.ts +9 -2
- package/dist/conversation/App.d.ts.map +1 -1
- package/dist/conversation/App.js +304 -111
- package/dist/conversation/App.js.map +1 -1
- package/dist/conversation/index.d.ts +5 -0
- package/dist/conversation/index.d.ts.map +1 -1
- package/dist/conversation/index.js +17 -2
- package/dist/conversation/index.js.map +1 -1
- package/dist/harness/chibi-harness.d.ts +36 -0
- package/dist/harness/chibi-harness.d.ts.map +1 -0
- package/dist/harness/chibi-harness.js +383 -0
- package/dist/harness/chibi-harness.js.map +1 -0
- package/dist/harness/chibi-plugins/get_plugin_config +64 -0
- package/dist/harness/chibi-plugins/query_navigator +114 -0
- package/dist/harness/chibi-plugins/submit_answer +38 -0
- package/dist/harness/chibi-plugins/update_plugin_config +91 -0
- package/dist/harness/claude-code-harness.d.ts +24 -0
- package/dist/harness/claude-code-harness.d.ts.map +1 -0
- package/dist/harness/claude-code-harness.js +242 -0
- package/dist/harness/claude-code-harness.js.map +1 -0
- package/dist/harness/ephemeral-home.d.ts +34 -0
- package/dist/harness/ephemeral-home.d.ts.map +1 -0
- package/dist/harness/ephemeral-home.js +56 -0
- package/dist/harness/ephemeral-home.js.map +1 -0
- package/dist/harness/factory.d.ts +47 -0
- package/dist/harness/factory.d.ts.map +1 -0
- package/dist/harness/factory.js +84 -0
- package/dist/harness/factory.js.map +1 -0
- package/dist/harness/helpers.d.ts +58 -0
- package/dist/harness/helpers.d.ts.map +1 -0
- package/dist/harness/helpers.js +78 -0
- package/dist/harness/helpers.js.map +1 -0
- package/dist/harness/index.d.ts +14 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +13 -0
- package/dist/harness/index.js.map +1 -0
- package/dist/harness/opencode-harness.d.ts +79 -0
- package/dist/harness/opencode-harness.d.ts.map +1 -0
- package/dist/harness/opencode-harness.js +537 -0
- package/dist/harness/opencode-harness.js.map +1 -0
- package/dist/harness/opencode-tools/get_plugin_config.ts +72 -0
- package/dist/harness/opencode-tools/query_navigator.ts +126 -0
- package/dist/harness/opencode-tools/submit_answer.ts +40 -0
- package/dist/harness/opencode-tools/update_plugin_config.ts +105 -0
- package/dist/harness/sandbox.d.ts +59 -0
- package/dist/harness/sandbox.d.ts.map +1 -0
- package/dist/harness/sandbox.js +152 -0
- package/dist/harness/sandbox.js.map +1 -0
- package/dist/harness/tool-server.d.ts +50 -0
- package/dist/harness/tool-server.d.ts.map +1 -0
- package/dist/harness/tool-server.js +27 -0
- package/dist/harness/tool-server.js.map +1 -0
- package/dist/harness/types.d.ts +168 -0
- package/dist/harness/types.d.ts.map +1 -0
- package/dist/harness/types.js +12 -0
- package/dist/harness/types.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/interview/App.d.ts +4 -2
- package/dist/interview/App.d.ts.map +1 -1
- package/dist/interview/App.js +36 -56
- package/dist/interview/App.js.map +1 -1
- package/dist/interview/index.d.ts +3 -0
- package/dist/interview/index.d.ts.map +1 -1
- package/dist/interview/index.js +1 -0
- package/dist/interview/index.js.map +1 -1
- package/dist/interview/prompts.d.ts +3 -1
- package/dist/interview/prompts.d.ts.map +1 -1
- package/dist/interview/prompts.js +5 -1
- package/dist/interview/prompts.js.map +1 -1
- package/dist/interview/ui/ChatBanner.d.ts +17 -0
- package/dist/interview/ui/ChatBanner.d.ts.map +1 -0
- package/dist/interview/ui/ChatBanner.js +30 -0
- package/dist/interview/ui/ChatBanner.js.map +1 -0
- package/dist/interview/ui/ChatInput.d.ts +36 -0
- package/dist/interview/ui/ChatInput.d.ts.map +1 -0
- package/dist/interview/ui/ChatInput.js +304 -0
- package/dist/interview/ui/ChatInput.js.map +1 -0
- package/dist/interview/ui/MarkdownText.d.ts +13 -0
- package/dist/interview/ui/MarkdownText.d.ts.map +1 -0
- package/dist/interview/ui/MarkdownText.js +107 -0
- package/dist/interview/ui/MarkdownText.js.map +1 -0
- package/dist/interview/ui/index.d.ts +3 -0
- package/dist/interview/ui/index.d.ts.map +1 -1
- package/dist/interview/ui/index.js +3 -0
- package/dist/interview/ui/index.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/implementer-agent.d.ts +31 -0
- package/dist/memento/implementer-agent.d.ts.map +1 -0
- package/dist/memento/implementer-agent.js +95 -0
- package/dist/memento/implementer-agent.js.map +1 -0
- package/dist/memento/index.d.ts +32 -0
- package/dist/memento/index.d.ts.map +1 -0
- package/dist/memento/index.js +40 -0
- package/dist/memento/index.js.map +1 -0
- package/dist/memento/loop.d.ts +34 -0
- package/dist/memento/loop.d.ts.map +1 -0
- package/dist/memento/loop.js +1227 -0
- package/dist/memento/loop.js.map +1 -0
- package/dist/memento/matrix-animation.d.ts +103 -0
- package/dist/memento/matrix-animation.d.ts.map +1 -0
- package/dist/memento/matrix-animation.js +303 -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 +75 -0
- package/dist/memento/nav-protocol.js.map +1 -0
- package/dist/memento/prompts.d.ts +57 -0
- package/dist/memento/prompts.d.ts.map +1 -0
- package/dist/memento/prompts.js +208 -0
- package/dist/memento/prompts.js.map +1 -0
- package/dist/memento/rate-limit.d.ts +85 -0
- package/dist/memento/rate-limit.d.ts.map +1 -0
- package/dist/memento/rate-limit.js +221 -0
- package/dist/memento/rate-limit.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 +33 -0
- package/dist/memento/worker-agent.d.ts.map +1 -0
- package/dist/memento/worker-agent.js +93 -0
- package/dist/memento/worker-agent.js.map +1 -0
- package/dist/registry.d.ts +35 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +87 -0
- package/dist/registry.js.map +1 -0
- package/dist/repo-analyzer/index.d.ts +2 -1
- package/dist/repo-analyzer/index.d.ts.map +1 -1
- package/dist/repo-analyzer/index.js +6 -17
- package/dist/repo-analyzer/index.js.map +1 -1
- package/dist/standup/config.d.ts +19 -0
- package/dist/standup/config.d.ts.map +1 -0
- package/dist/standup/config.js +42 -0
- package/dist/standup/config.js.map +1 -0
- package/dist/standup/index.d.ts +24 -0
- package/dist/standup/index.d.ts.map +1 -0
- package/dist/standup/index.js +29 -0
- package/dist/standup/index.js.map +1 -0
- package/dist/standup/loop.d.ts +36 -0
- package/dist/standup/loop.d.ts.map +1 -0
- package/dist/standup/loop.js +508 -0
- package/dist/standup/loop.js.map +1 -0
- package/dist/standup/prompts.d.ts +62 -0
- package/dist/standup/prompts.d.ts.map +1 -0
- package/dist/standup/prompts.js +211 -0
- package/dist/standup/prompts.js.map +1 -0
- package/dist/standup/standup-protocol.d.ts +33 -0
- package/dist/standup/standup-protocol.d.ts.map +1 -0
- package/dist/standup/standup-protocol.js +189 -0
- package/dist/standup/standup-protocol.js.map +1 -0
- package/dist/standup/types.d.ts +185 -0
- package/dist/standup/types.d.ts.map +1 -0
- package/dist/standup/types.js +67 -0
- package/dist/standup/types.js.map +1 -0
- package/dist/tools/cross-nav.d.ts +21 -0
- package/dist/tools/cross-nav.d.ts.map +1 -0
- package/dist/tools/cross-nav.js +93 -0
- package/dist/tools/cross-nav.js.map +1 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/related-navs-config.d.ts +15 -0
- package/dist/tools/related-navs-config.d.ts.map +1 -0
- package/dist/tools/related-navs-config.js +132 -0
- package/dist/tools/related-navs-config.js.map +1 -0
- package/dist/tools/related-navs.d.ts +23 -0
- package/dist/tools/related-navs.d.ts.map +1 -0
- package/dist/tools/related-navs.js +107 -0
- package/dist/tools/related-navs.js.map +1 -0
- package/dist/tools/response.d.ts +3 -2
- package/dist/tools/response.d.ts.map +1 -1
- package/dist/tools/response.js +7 -11
- package/dist/tools/response.js.map +1 -1
- package/dist/tools/self-config.d.ts +2 -1
- package/dist/tools/self-config.d.ts.map +1 -1
- package/dist/tools/self-config.js +5 -9
- package/dist/tools/self-config.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Operations for Memento Loop
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for git operations: branches, commits, logs, PRs.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Options for git operations
|
|
8
|
+
*/
|
|
9
|
+
interface GitOptions {
|
|
10
|
+
cwd: string;
|
|
11
|
+
verbose?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Check if directory is a git repository
|
|
15
|
+
*/
|
|
16
|
+
export declare function isGitRepo(cwd: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Initialize a git repository if not already initialized
|
|
19
|
+
*/
|
|
20
|
+
export declare function ensureGitRepo(options: GitOptions): void;
|
|
21
|
+
/**
|
|
22
|
+
* Get current branch name
|
|
23
|
+
*/
|
|
24
|
+
export declare function getCurrentBranch(options: GitOptions): string;
|
|
25
|
+
/**
|
|
26
|
+
* Create and checkout a new branch
|
|
27
|
+
*/
|
|
28
|
+
export declare function createBranch(name: string, options: GitOptions): void;
|
|
29
|
+
/**
|
|
30
|
+
* Get recent git log entries
|
|
31
|
+
*/
|
|
32
|
+
export declare function getRecentGitLog(options: GitOptions & {
|
|
33
|
+
count?: number;
|
|
34
|
+
}): string;
|
|
35
|
+
/**
|
|
36
|
+
* Get diff of recent changes (staged + unstaged)
|
|
37
|
+
*/
|
|
38
|
+
export declare function getRecentDiff(options: GitOptions): string;
|
|
39
|
+
/**
|
|
40
|
+
* Diff statistics
|
|
41
|
+
*/
|
|
42
|
+
export interface DiffStats {
|
|
43
|
+
filesChanged: number;
|
|
44
|
+
linesAdded: number;
|
|
45
|
+
linesRemoved: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get diff stats (lines added/removed) for uncommitted changes
|
|
49
|
+
*/
|
|
50
|
+
export declare function getDiffStats(options: GitOptions): DiffStats;
|
|
51
|
+
/**
|
|
52
|
+
* Get diff stats between HEAD and HEAD~1 (last commit)
|
|
53
|
+
*/
|
|
54
|
+
export declare function getLastCommitDiffStats(options: GitOptions): DiffStats;
|
|
55
|
+
/**
|
|
56
|
+
* Check if there are uncommitted changes
|
|
57
|
+
*/
|
|
58
|
+
export declare function hasUncommittedChanges(options: GitOptions): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Stage all changes
|
|
61
|
+
*/
|
|
62
|
+
export declare function stageAllChanges(options: GitOptions): void;
|
|
63
|
+
/**
|
|
64
|
+
* Commit staged changes
|
|
65
|
+
*
|
|
66
|
+
* Returns the commit hash, or null if nothing to commit
|
|
67
|
+
*/
|
|
68
|
+
export declare function commitChanges(message: string, options: GitOptions): string | null;
|
|
69
|
+
/**
|
|
70
|
+
* Push branch to remote
|
|
71
|
+
*/
|
|
72
|
+
export declare function pushBranch(branch: string, options: GitOptions & {
|
|
73
|
+
setUpstream?: boolean;
|
|
74
|
+
}): void;
|
|
75
|
+
/**
|
|
76
|
+
* Create a pull request using GitHub CLI
|
|
77
|
+
*
|
|
78
|
+
* Requires `gh` CLI to be installed and authenticated
|
|
79
|
+
*/
|
|
80
|
+
export declare function createPullRequest(options: GitOptions & {
|
|
81
|
+
title: string;
|
|
82
|
+
body: string;
|
|
83
|
+
base?: string;
|
|
84
|
+
draft?: boolean;
|
|
85
|
+
}): string;
|
|
86
|
+
/**
|
|
87
|
+
* Check if gh CLI is available and authenticated
|
|
88
|
+
*/
|
|
89
|
+
export declare function isGhAvailable(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Get the remote origin URL
|
|
92
|
+
*/
|
|
93
|
+
export declare function getRemoteUrl(options: GitOptions): string | null;
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=git-operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-operations.d.ts","sourceRoot":"","sources":["../../src/memento/git-operations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,UAAU,UAAU;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAuBD;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAW9C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAOvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAM5D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,IAAI,CAgBpE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,UAAU,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACvC,MAAM,CAeR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAQzD;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAqB3D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAoBrE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAOlE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,UAAU,GAClB,MAAM,GAAG,IAAI,CAuBf;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,UAAU,GAAG;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9C,IAAI,CAON;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,UAAU,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACA,MAAM,CAsBR;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAUvC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAM/D"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Operations for Memento Loop
|
|
3
|
+
*
|
|
4
|
+
* Helper functions for git operations: branches, commits, logs, PRs.
|
|
5
|
+
*/
|
|
6
|
+
import { execSync } from "node:child_process";
|
|
7
|
+
/**
|
|
8
|
+
* Execute a git command and return output
|
|
9
|
+
*/
|
|
10
|
+
function execGit(command, options) {
|
|
11
|
+
const execOptions = {
|
|
12
|
+
cwd: options.cwd,
|
|
13
|
+
encoding: "utf-8",
|
|
14
|
+
stdio: options.verbose ? "inherit" : "pipe",
|
|
15
|
+
};
|
|
16
|
+
try {
|
|
17
|
+
const result = execSync(command, execOptions);
|
|
18
|
+
return typeof result === "string" ? result.trim() : "";
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error instanceof Error && "stderr" in error) {
|
|
22
|
+
throw new Error(`Git command failed: ${command}\n${error.stderr}`);
|
|
23
|
+
}
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Check if directory is a git repository
|
|
29
|
+
*/
|
|
30
|
+
export function isGitRepo(cwd) {
|
|
31
|
+
try {
|
|
32
|
+
execSync("git rev-parse --is-inside-work-tree", {
|
|
33
|
+
cwd,
|
|
34
|
+
encoding: "utf-8",
|
|
35
|
+
stdio: "pipe",
|
|
36
|
+
});
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Initialize a git repository if not already initialized
|
|
45
|
+
*/
|
|
46
|
+
export function ensureGitRepo(options) {
|
|
47
|
+
if (!isGitRepo(options.cwd)) {
|
|
48
|
+
execGit("git init", options);
|
|
49
|
+
if (options.verbose) {
|
|
50
|
+
console.log(`Initialized git repository in ${options.cwd}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get current branch name
|
|
56
|
+
*/
|
|
57
|
+
export function getCurrentBranch(options) {
|
|
58
|
+
try {
|
|
59
|
+
return execGit("git branch --show-current", { ...options, verbose: false });
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return "HEAD"; // Detached HEAD state
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create and checkout a new branch
|
|
67
|
+
*/
|
|
68
|
+
export function createBranch(name, options) {
|
|
69
|
+
// Check if branch already exists
|
|
70
|
+
try {
|
|
71
|
+
execGit(`git rev-parse --verify ${name}`, { ...options, verbose: false });
|
|
72
|
+
// Branch exists, just checkout
|
|
73
|
+
execGit(`git checkout ${name}`, options);
|
|
74
|
+
if (options.verbose) {
|
|
75
|
+
console.log(`Switched to existing branch: ${name}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Branch doesn't exist, create it
|
|
80
|
+
execGit(`git checkout -b ${name}`, options);
|
|
81
|
+
if (options.verbose) {
|
|
82
|
+
console.log(`Created and switched to branch: ${name}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get recent git log entries
|
|
88
|
+
*/
|
|
89
|
+
export function getRecentGitLog(options) {
|
|
90
|
+
const count = options.count ?? 10;
|
|
91
|
+
try {
|
|
92
|
+
// Check if there are any commits
|
|
93
|
+
execGit("git rev-parse HEAD", { ...options, verbose: false });
|
|
94
|
+
return execGit(`git log --oneline --no-decorate -n ${count}`, { ...options, verbose: false });
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// No commits yet
|
|
98
|
+
return "";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get diff of recent changes (staged + unstaged)
|
|
103
|
+
*/
|
|
104
|
+
export function getRecentDiff(options) {
|
|
105
|
+
try {
|
|
106
|
+
const staged = execGit("git diff --cached", { ...options, verbose: false });
|
|
107
|
+
const unstaged = execGit("git diff", { ...options, verbose: false });
|
|
108
|
+
return `${staged}\n${unstaged}`.trim();
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get diff stats (lines added/removed) for uncommitted changes
|
|
116
|
+
*/
|
|
117
|
+
export function getDiffStats(options) {
|
|
118
|
+
try {
|
|
119
|
+
// git diff --shortstat outputs: " 3 files changed, 10 insertions(+), 5 deletions(-)"
|
|
120
|
+
const output = execGit("git diff --shortstat", { ...options, verbose: false });
|
|
121
|
+
if (!output) {
|
|
122
|
+
return { filesChanged: 0, linesAdded: 0, linesRemoved: 0 };
|
|
123
|
+
}
|
|
124
|
+
const filesMatch = output.match(/(\d+) files? changed/);
|
|
125
|
+
const insertionsMatch = output.match(/(\d+) insertions?\(\+\)/);
|
|
126
|
+
const deletionsMatch = output.match(/(\d+) deletions?\(-\)/);
|
|
127
|
+
return {
|
|
128
|
+
filesChanged: filesMatch ? parseInt(filesMatch[1], 10) : 0,
|
|
129
|
+
linesAdded: insertionsMatch ? parseInt(insertionsMatch[1], 10) : 0,
|
|
130
|
+
linesRemoved: deletionsMatch ? parseInt(deletionsMatch[1], 10) : 0,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return { filesChanged: 0, linesAdded: 0, linesRemoved: 0 };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get diff stats between HEAD and HEAD~1 (last commit)
|
|
139
|
+
*/
|
|
140
|
+
export function getLastCommitDiffStats(options) {
|
|
141
|
+
try {
|
|
142
|
+
const output = execGit("git diff --shortstat HEAD~1 HEAD", { ...options, verbose: false });
|
|
143
|
+
if (!output) {
|
|
144
|
+
return { filesChanged: 0, linesAdded: 0, linesRemoved: 0 };
|
|
145
|
+
}
|
|
146
|
+
const filesMatch = output.match(/(\d+) files? changed/);
|
|
147
|
+
const insertionsMatch = output.match(/(\d+) insertions?\(\+\)/);
|
|
148
|
+
const deletionsMatch = output.match(/(\d+) deletions?\(-\)/);
|
|
149
|
+
return {
|
|
150
|
+
filesChanged: filesMatch ? parseInt(filesMatch[1], 10) : 0,
|
|
151
|
+
linesAdded: insertionsMatch ? parseInt(insertionsMatch[1], 10) : 0,
|
|
152
|
+
linesRemoved: deletionsMatch ? parseInt(deletionsMatch[1], 10) : 0,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return { filesChanged: 0, linesAdded: 0, linesRemoved: 0 };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Check if there are uncommitted changes
|
|
161
|
+
*/
|
|
162
|
+
export function hasUncommittedChanges(options) {
|
|
163
|
+
try {
|
|
164
|
+
const status = execGit("git status --porcelain", { ...options, verbose: false });
|
|
165
|
+
return status.length > 0;
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Stage all changes
|
|
173
|
+
*/
|
|
174
|
+
export function stageAllChanges(options) {
|
|
175
|
+
execGit("git add -A", options);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Commit staged changes
|
|
179
|
+
*
|
|
180
|
+
* Returns the commit hash, or null if nothing to commit
|
|
181
|
+
*/
|
|
182
|
+
export function commitChanges(message, options) {
|
|
183
|
+
// Check if there's anything to commit
|
|
184
|
+
if (!hasUncommittedChanges(options)) {
|
|
185
|
+
if (options.verbose) {
|
|
186
|
+
console.log("No changes to commit");
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
// Stage all changes
|
|
191
|
+
stageAllChanges(options);
|
|
192
|
+
// Commit
|
|
193
|
+
execGit(`git commit -m "${message.replace(/"/g, '\\"')}"`, options);
|
|
194
|
+
// Get the commit hash
|
|
195
|
+
const hash = execGit("git rev-parse --short HEAD", { ...options, verbose: false });
|
|
196
|
+
if (options.verbose) {
|
|
197
|
+
console.log(`Committed: ${hash} - ${message}`);
|
|
198
|
+
}
|
|
199
|
+
return hash;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Push branch to remote
|
|
203
|
+
*/
|
|
204
|
+
export function pushBranch(branch, options) {
|
|
205
|
+
const upstream = options.setUpstream ? "-u origin" : "";
|
|
206
|
+
execGit(`git push ${upstream} ${branch}`.trim(), options);
|
|
207
|
+
if (options.verbose) {
|
|
208
|
+
console.log(`Pushed branch: ${branch}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Create a pull request using GitHub CLI
|
|
213
|
+
*
|
|
214
|
+
* Requires `gh` CLI to be installed and authenticated
|
|
215
|
+
*/
|
|
216
|
+
export function createPullRequest(options) {
|
|
217
|
+
const { title, body, base = "main", draft = false } = options;
|
|
218
|
+
// Escape for shell
|
|
219
|
+
const escapedTitle = title.replace(/"/g, '\\"');
|
|
220
|
+
const escapedBody = body.replace(/"/g, '\\"');
|
|
221
|
+
const draftFlag = draft ? "--draft" : "";
|
|
222
|
+
const output = execGit(`gh pr create --title "${escapedTitle}" --body "${escapedBody}" --base ${base} ${draftFlag}`.trim(), options);
|
|
223
|
+
// gh pr create outputs the PR URL
|
|
224
|
+
const prUrl = output.split("\n").pop() || output;
|
|
225
|
+
if (options.verbose) {
|
|
226
|
+
console.log(`Created PR: ${prUrl}`);
|
|
227
|
+
}
|
|
228
|
+
return prUrl;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Check if gh CLI is available and authenticated
|
|
232
|
+
*/
|
|
233
|
+
export function isGhAvailable() {
|
|
234
|
+
try {
|
|
235
|
+
execSync("gh auth status", {
|
|
236
|
+
encoding: "utf-8",
|
|
237
|
+
stdio: "pipe",
|
|
238
|
+
});
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Get the remote origin URL
|
|
247
|
+
*/
|
|
248
|
+
export function getRemoteUrl(options) {
|
|
249
|
+
try {
|
|
250
|
+
return execGit("git remote get-url origin", { ...options, verbose: false });
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=git-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-operations.js","sourceRoot":"","sources":["../../src/memento/git-operations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAwB,MAAM,oBAAoB,CAAC;AAUpE;;GAEG;AACH,SAAS,OAAO,CAAC,OAAe,EAAE,OAAmB;IACnD,MAAM,WAAW,GAAoB;QACnC,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;KAC5C,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC9C,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,uBAAuB,OAAO,KAAM,KAAoC,CAAC,MAAM,EAAE,CAAC,CAAC;QACrG,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,IAAI,CAAC;QACH,QAAQ,CAAC,qCAAqC,EAAE;YAC9C,GAAG;YACH,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC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AC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAEzC,MAAM,MAAM,GAAG,OAAO,CACpB,yBAAyB,YAAY,aAAa,WAAW,YAAY,IAAI,IAAI,SAAS,EAAE,CAAC,IAAI,EAAE,EACnG,OAAO,CACR,CAAC;IAEF,kCAAkC;IAClC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,MAAM,CAAC;IAEjD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,IAAI,CAAC;QACH,QAAQ,CAAC,gBAAgB,EAAE;YACzB,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,OAAmB;IAC9C,IAAI,CAAC;QACH,OAAO,OAAO,CAAC,2BAA2B,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementer Agent for Memento Loop
|
|
3
|
+
*
|
|
4
|
+
* Executes implementation plans using the harness interface.
|
|
5
|
+
*/
|
|
6
|
+
import type { Harness } from "../harness/index.js";
|
|
7
|
+
import type { ImplementationPlan, ImplementerResult } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Minimal context for implementer (no persisted state)
|
|
10
|
+
*/
|
|
11
|
+
interface ImplementerContext {
|
|
12
|
+
codeDirectory: string;
|
|
13
|
+
task: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Options for implementer agent execution
|
|
17
|
+
*/
|
|
18
|
+
export interface ImplementerAgentOptions {
|
|
19
|
+
/** Show detailed logging */
|
|
20
|
+
verbose?: boolean;
|
|
21
|
+
/** Model to use (defaults to claude-sonnet-4-5) */
|
|
22
|
+
model?: string;
|
|
23
|
+
/** Maximum turns for implementer agent */
|
|
24
|
+
maxTurns?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Run the implementer agent to implement a plan
|
|
28
|
+
*/
|
|
29
|
+
export declare function runImplementerAgent(context: ImplementerContext, plan: ImplementationPlan, harness: Harness, options?: ImplementerAgentOptions): Promise<ImplementerResult>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=implementer-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implementer-agent.d.ts","sourceRoot":"","sources":["../../src/memento/implementer-agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGxE;;GAEG;AACH,UAAU,kBAAkB;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,4BAA4B;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,iBAAiB,CAAC,CAsG5B"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implementer Agent for Memento Loop
|
|
3
|
+
*
|
|
4
|
+
* Executes implementation plans using the harness interface.
|
|
5
|
+
*/
|
|
6
|
+
import { buildImplementerPrompt, buildImplementerSystemPrompt } from "./prompts.js";
|
|
7
|
+
/**
|
|
8
|
+
* Run the implementer agent to implement a plan
|
|
9
|
+
*/
|
|
10
|
+
export async function runImplementerAgent(context, plan, harness, options = {}) {
|
|
11
|
+
const startTime = Date.now();
|
|
12
|
+
const { verbose = false, model = "claude-sonnet-4-5", maxTurns = 50, } = options;
|
|
13
|
+
const prompt = buildImplementerPrompt(context.codeDirectory, plan);
|
|
14
|
+
const systemPrompt = buildImplementerSystemPrompt(context.codeDirectory);
|
|
15
|
+
if (verbose) {
|
|
16
|
+
console.log("\n[Implementer] Starting implementation...");
|
|
17
|
+
console.log(`[Implementer] Plan: ${plan.summary}`);
|
|
18
|
+
console.log(`[Implementer] Steps: ${plan.steps.length}`);
|
|
19
|
+
}
|
|
20
|
+
const filesModified = [];
|
|
21
|
+
let lastAssistantText = "";
|
|
22
|
+
let resultEvent;
|
|
23
|
+
try {
|
|
24
|
+
const session = harness.run({
|
|
25
|
+
model,
|
|
26
|
+
maxTurns,
|
|
27
|
+
systemPrompt,
|
|
28
|
+
cwd: context.codeDirectory,
|
|
29
|
+
permissionMode: "bypassPermissions",
|
|
30
|
+
}, prompt);
|
|
31
|
+
for await (const event of session) {
|
|
32
|
+
if (event.type === "tool_use") {
|
|
33
|
+
if (verbose) {
|
|
34
|
+
console.log(`[Implementer] Tool: ${event.name}`);
|
|
35
|
+
}
|
|
36
|
+
// Extract file paths from common tools
|
|
37
|
+
if (event.name === "Write" ||
|
|
38
|
+
event.name === "Edit" ||
|
|
39
|
+
event.name === "str_replace_based_edit_tool") {
|
|
40
|
+
const filePath = event.input.file_path || event.input.path;
|
|
41
|
+
if (typeof filePath === "string" && !filesModified.includes(filePath)) {
|
|
42
|
+
filesModified.push(filePath);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (event.type === "text") {
|
|
47
|
+
lastAssistantText = event.text;
|
|
48
|
+
}
|
|
49
|
+
else if (event.type === "result") {
|
|
50
|
+
resultEvent = event;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const durationMs = Date.now() - startTime;
|
|
54
|
+
if (!resultEvent) {
|
|
55
|
+
return {
|
|
56
|
+
success: false,
|
|
57
|
+
summary: "No result message received from implementer agent",
|
|
58
|
+
filesModified,
|
|
59
|
+
errors: ["No result message received"],
|
|
60
|
+
durationMs,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (!resultEvent.success) {
|
|
64
|
+
return {
|
|
65
|
+
success: false,
|
|
66
|
+
summary: `Implementer failed`,
|
|
67
|
+
filesModified,
|
|
68
|
+
errors: [resultEvent.text || "Unknown error"],
|
|
69
|
+
durationMs,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (verbose) {
|
|
73
|
+
console.log(`[Implementer] Completed in ${durationMs}ms`);
|
|
74
|
+
console.log(`[Implementer] Files modified: ${filesModified.length}`);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
success: true,
|
|
78
|
+
summary: resultEvent.text || lastAssistantText || "Implementation completed",
|
|
79
|
+
filesModified,
|
|
80
|
+
durationMs,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
const durationMs = Date.now() - startTime;
|
|
85
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
86
|
+
return {
|
|
87
|
+
success: false,
|
|
88
|
+
summary: `Implementer error: ${errorMessage}`,
|
|
89
|
+
filesModified,
|
|
90
|
+
errors: [errorMessage],
|
|
91
|
+
durationMs,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=implementer-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implementer-agent.js","sourceRoot":"","sources":["../../src/memento/implementer-agent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAwBpF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAA2B,EAC3B,IAAwB,EACxB,OAAgB,EAChB,UAAmC,EAAE;IAErC,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,sBAAsB,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACnE,MAAM,YAAY,GAAG,4BAA4B,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAEzE,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;QAC1D,OAAO,CAAC,GAAG,CAAC,uBAAuB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,IAAI,iBAAiB,GAAG,EAAE,CAAC;IAC3B,IAAI,WAA0D,CAAC;IAE/D,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CACzB;YACE,KAAK;YACL,QAAQ;YACR,YAAY;YACZ,GAAG,EAAE,OAAO,CAAC,aAAa;YAC1B,cAAc,EAAE,mBAAmB;SACpC,EACD,MAAM,CACP,CAAC;QAEF,IAAI,KAAK,EAAE,MAAM,KAAK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aAAa;gBACb,MAAM,EAAE,CAAC,WAAW,CAAC,IAAI,IAAI,eAAe,CAAC;gBAC7C,UAAU;aACX,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,8BAA8B,UAAU,IAAI,CAAC,CAAC;YAC1D,OAAO,CAAC,GAAG,CAAC,iCAAiC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC;QACvE,CAAC;QAED,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,WAAW,CAAC,IAAI,IAAI,iBAAiB,IAAI,0BAA0B;YAC5E,aAAa;YACb,UAAU;SACX,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;QAC1C,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAE5E,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,sBAAsB,YAAY,EAAE;YAC7C,aAAa;YACb,MAAM,EAAE,CAAC,YAAY,CAAC;YACtB,UAAU;SACX,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memento Loop Module
|
|
3
|
+
*
|
|
4
|
+
* Context-clearing iterative development loop that coordinates
|
|
5
|
+
* navigator (planning) and implementer (implementation) agents.
|
|
6
|
+
*
|
|
7
|
+
* Design principle: Git is the only persistent memory. All other
|
|
8
|
+
* state lives in-memory during loop execution.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { runMementoLoop } from './memento';
|
|
13
|
+
*
|
|
14
|
+
* const result = await runMementoLoop(
|
|
15
|
+
* './my-code',
|
|
16
|
+
* './my-navigator',
|
|
17
|
+
* 'Add user authentication',
|
|
18
|
+
* { maxIterations: 10, branch: 'feature/auth', verbose: true }
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* console.log(`Completed in ${result.iterations} iterations`);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export { type ImplementationStep, type ImplementationPlan, type ImplementerResult, type MementoOptions, type MementoResult, ImplementationStepSchema, ImplementationPlanSchema, } from "./types.js";
|
|
25
|
+
export { isGitRepo, ensureGitRepo, getCurrentBranch, createBranch, getRecentGitLog, getRecentDiff, getDiffStats, getLastCommitDiffStats, hasUncommittedChanges, stageAllChanges, commitChanges, pushBranch, createPullRequest, isGhAvailable, getRemoteUrl, type DiffStats, } from "./git-operations.js";
|
|
26
|
+
export { createNavProtocolTools, SUBMIT_PLAN_TOOL, type PlanSubmissionResult, } from "./nav-protocol.js";
|
|
27
|
+
export { buildNavPlanPrompt, buildNavSystemPrompt, buildImplementerPrompt, buildImplementerSystemPrompt, type NavigatorIdentity, } from "./prompts.js";
|
|
28
|
+
export { runImplementerAgent, type ImplementerAgentOptions, } from "./implementer-agent.js";
|
|
29
|
+
export { runMementoLoop, type MementoLoopOptions, } from "./loop.js";
|
|
30
|
+
export { parseRateLimitError, isTransientConnectionError, formatDuration, getBackoffDelay, getConnectionRetryDelay, waitWithCountdown, type RateLimitInfo, type RateLimitRetryConfig, } from "./rate-limit.js";
|
|
31
|
+
export { MatrixAnimation, withMatrixAnimation, type AnimationStats, } from "./matrix-animation.js";
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memento/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,KAAK,SAAS,GACf,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,4BAA4B,EAC5B,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,mBAAmB,EACnB,KAAK,uBAAuB,GAC7B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,cAAc,EACd,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,iBAAiB,EACjB,KAAK,aAAa,EAClB,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,KAAK,cAAc,GACpB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memento Loop Module
|
|
3
|
+
*
|
|
4
|
+
* Context-clearing iterative development loop that coordinates
|
|
5
|
+
* navigator (planning) and implementer (implementation) agents.
|
|
6
|
+
*
|
|
7
|
+
* Design principle: Git is the only persistent memory. All other
|
|
8
|
+
* state lives in-memory during loop execution.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { runMementoLoop } from './memento';
|
|
13
|
+
*
|
|
14
|
+
* const result = await runMementoLoop(
|
|
15
|
+
* './my-code',
|
|
16
|
+
* './my-navigator',
|
|
17
|
+
* 'Add user authentication',
|
|
18
|
+
* { maxIterations: 10, branch: 'feature/auth', verbose: true }
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* console.log(`Completed in ${result.iterations} iterations`);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
// Types
|
|
25
|
+
export { ImplementationStepSchema, ImplementationPlanSchema, } from "./types.js";
|
|
26
|
+
// Git operations
|
|
27
|
+
export { isGitRepo, ensureGitRepo, getCurrentBranch, createBranch, getRecentGitLog, getRecentDiff, getDiffStats, getLastCommitDiffStats, hasUncommittedChanges, stageAllChanges, commitChanges, pushBranch, createPullRequest, isGhAvailable, getRemoteUrl, } from "./git-operations.js";
|
|
28
|
+
// Nav protocol
|
|
29
|
+
export { createNavProtocolTools, SUBMIT_PLAN_TOOL, } from "./nav-protocol.js";
|
|
30
|
+
// Prompts
|
|
31
|
+
export { buildNavPlanPrompt, buildNavSystemPrompt, buildImplementerPrompt, buildImplementerSystemPrompt, } from "./prompts.js";
|
|
32
|
+
// Implementer agent
|
|
33
|
+
export { runImplementerAgent, } from "./implementer-agent.js";
|
|
34
|
+
// Main loop
|
|
35
|
+
export { runMementoLoop, } from "./loop.js";
|
|
36
|
+
// Rate limit handling
|
|
37
|
+
export { parseRateLimitError, isTransientConnectionError, formatDuration, getBackoffDelay, getConnectionRetryDelay, waitWithCountdown, } from "./rate-limit.js";
|
|
38
|
+
// Animation
|
|
39
|
+
export { MatrixAnimation, withMatrixAnimation, } from "./matrix-animation.js";
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/memento/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,QAAQ;AACR,OAAO,EAML,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AAEpB,iBAAiB;AACjB,OAAO,EACL,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,YAAY,GAEb,MAAM,qBAAqB,CAAC;AAE7B,eAAe;AACf,OAAO,EACL,sBAAsB,EACtB,gBAAgB,GAEjB,MAAM,mBAAmB,CAAC;AAE3B,UAAU;AACV,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,4BAA4B,GAE7B,MAAM,cAAc,CAAC;AAEtB,oBAAoB;AACpB,OAAO,EACL,mBAAmB,GAEpB,MAAM,wBAAwB,CAAC;AAEhC,YAAY;AACZ,OAAO,EACL,cAAc,GAEf,MAAM,WAAW,CAAC;AAEnB,sBAAsB;AACtB,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,iBAAiB,GAGlB,MAAM,iBAAiB,CAAC;AAEzB,YAAY;AACZ,OAAO,EACL,eAAe,EACf,mBAAmB,GAEpB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memento Loop Core Logic
|
|
3
|
+
*
|
|
4
|
+
* The main loop that coordinates navigator planning and implementer implementation
|
|
5
|
+
* in a context-clearing iterative development pattern.
|
|
6
|
+
*
|
|
7
|
+
* Design principle: The IMPLEMENTER forgets between iterations (memento pattern).
|
|
8
|
+
* The NAVIGATOR maintains its own memory and knowledge base. We provide git
|
|
9
|
+
* history as context about what the implementer has accomplished so far.
|
|
10
|
+
*/
|
|
11
|
+
import type { MementoOptions, MementoResult } from "./types.js";
|
|
12
|
+
import type { Harness } from "../harness/index.js";
|
|
13
|
+
/**
|
|
14
|
+
* Options for the memento loop
|
|
15
|
+
*/
|
|
16
|
+
export interface MementoLoopOptions extends MementoOptions {
|
|
17
|
+
/** Model to use for implementer agent (default: claude-haiku-4-5) */
|
|
18
|
+
model?: string;
|
|
19
|
+
/** Model to use for navigator agent (default: claude-opus-4-5) */
|
|
20
|
+
navModel?: string;
|
|
21
|
+
/** Maximum turns per agent call */
|
|
22
|
+
maxTurns?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Run the memento loop
|
|
26
|
+
*
|
|
27
|
+
* Coordinates navigator planning and worker implementation in iterations
|
|
28
|
+
* until the task is complete or max iterations reached.
|
|
29
|
+
*
|
|
30
|
+
* All state is in-memory. Git history is the only persistent context
|
|
31
|
+
* visible to the agents.
|
|
32
|
+
*/
|
|
33
|
+
export declare function runMementoLoop(codeDirectory: string, navDirectory: string, task: string, options: MementoLoopOptions, harness: Harness): Promise<MementoResult>;
|
|
34
|
+
//# sourceMappingURL=loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/memento/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAsB,MAAM,YAAY,CAAC;AACpF,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAsT/D;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAEnB;AA08BD;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAClC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,aAAa,CAAC,CAsTxB"}
|