MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / bashIntent

Function bashIntent

scripts/agent-eval/parse-run.mjs:773–789  ·  view source on GitHub ↗

What a Bash command is really doing, as far as retrieval is concerned.

(cmd)

Source from the content-addressed store, hash-verified

771
772/** What a Bash command is really doing, as far as retrieval is concerned. */
773function bashIntent(cmd) {
774 const c = String(cmd || '');
775 // A heredoc or a redirect is WRITING a file — `cat <<EOF > x` must not read
776 // as a Read.
777 if (!/<</.test(c) && !/>\s*\S/.test(c)) {
778 const m = BASH_READ_RE.exec(c);
779 if (m) {
780 // Drop flags and numeric arguments (`sed -n '100,200p' lib/x.js`), then
781 // take the last path-shaped token.
782 const args = m[1].split(/\s+/).filter((a) => a && !a.startsWith('-') && !/^['"]?\d/.test(a));
783 const path = args.reverse().find((a) => /[/.]/.test(a));
784 if (path) return { kind: 'read', path: path.replace(/^['"]|['"]$/g, '') };
785 }
786 }
787 if (BASH_SEARCH_RE.test(c)) return { kind: 'search' };
788 return null;
789}
790
791const normPath = (p) => String(p ?? '').replace(/\\/g, '/').replace(/^\.\//, '');
792/** Same file, with either side repo-relative and the other absolute. */

Callers 2

reactionOfFunction · 0.85
isFileAccessFunction · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected