-
Notifications
You must be signed in to change notification settings - Fork 7
Add artifact exclusion and goal mode orchestration logic #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mashan555
wants to merge
6
commits into
main
Choose a base branch
from
fadeeva/goal-in-action
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4b118c3
Add agent artifact exclusion logic and goal mode orchestration suppor…
mashan555 6106b39
Added PR title prefix logic with validation, constants, and comprehen…
mashan555 ecb313a
Added dynamic branch policy note generation
mashan555 b3cba92
Fixed title keywords
mashan555 48261ea
Added handling for external tracker titles (Jira, YouTrack) to resolv…
mashan555 fc1d3c7
Simplified comments and documentation across utility functions; refin…
mashan555 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import {execSync} from "child_process"; | ||
| import * as fs from "node:fs"; | ||
| import * as path from "node:path"; | ||
|
|
||
| // Agent scratch files written into the checkout; must never be committed. | ||
| export const AGENT_ARTIFACT_PATTERNS = [ | ||
| ".junie/plans/", | ||
| ".junie/memory/", | ||
| ]; | ||
|
|
||
| const EXCLUDE_HEADER = "# junie-github-action: agent artifacts, not part of the task result"; | ||
|
|
||
| // Uses --git-common-dir so linked worktrees resolve to the shared info/exclude. | ||
| function resolveGitCommonDir(cwd?: string): string | undefined { | ||
| try { | ||
| const gitDir = execSync("git rev-parse --git-common-dir", { | ||
| encoding: "utf-8", | ||
| cwd, | ||
| stdio: ["ignore", "pipe", "pipe"], | ||
| }).trim(); | ||
|
|
||
| if (!gitDir) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return path.isAbsolute(gitDir) ? gitDir : path.resolve(cwd ?? process.cwd(), gitDir); | ||
| } catch (error) { | ||
| console.warn(`Could not locate the git directory: ${error instanceof Error ? error.message : String(error)}`); | ||
| return undefined; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Appends `patterns` to `.git/info/exclude` (best-effort) so the commit step's | ||
| * `git add .` skips untracked agent artifacts. Returns the newly added patterns. | ||
| */ | ||
| export function addGitExcludePatterns(patterns: string[], cwd?: string): string[] { | ||
| if (patterns.length === 0) { | ||
| return []; | ||
| } | ||
|
|
||
| const gitDir = resolveGitCommonDir(cwd); | ||
| if (!gitDir) { | ||
| console.warn("Skipping agent artifact excludes: not inside a git repository"); | ||
| return []; | ||
| } | ||
|
|
||
| const excludePath = path.join(gitDir, "info", "exclude"); | ||
|
|
||
| try { | ||
| const existing = fs.existsSync(excludePath) ? fs.readFileSync(excludePath, "utf-8") : ""; | ||
| const existingPatterns = new Set( | ||
| existing.split("\n").map(line => line.trim()).filter(line => line && !line.startsWith("#")) | ||
| ); | ||
|
|
||
| const missing = patterns.filter(pattern => !existingPatterns.has(pattern)); | ||
| if (missing.length === 0) { | ||
| console.log("Agent artifact excludes are already present"); | ||
| return []; | ||
| } | ||
|
|
||
| fs.mkdirSync(path.dirname(excludePath), {recursive: true}); | ||
|
|
||
| // Keep whatever the checkout already excluded and append below it. | ||
| const prefix = existing === "" || existing.endsWith("\n") ? existing : `${existing}\n`; | ||
| fs.writeFileSync(excludePath, `${prefix}${EXCLUDE_HEADER}\n${missing.join("\n")}\n`); | ||
|
|
||
| console.log(`Excluded agent artifacts from commits: ${missing.join(", ")}`); | ||
| return missing; | ||
| } catch (error) { | ||
| console.warn( | ||
| `Could not write ${excludePath}, agent artifacts may be committed: ` + | ||
| `${error instanceof Error ? error.message : String(error)}` | ||
| ); | ||
| return []; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if the header already exists before appending it to avoid duplication when patterns are added incrementally.