FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
opencode/packages/opencode/src/project/instance-context.ts at dev · argszero/opencode · GitHub
argszero
/
opencode
Public
forked from
anomalyco/opencode
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
opencode
/
packages
/
opencode
/
src
/
project
/
instance-context.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (21 loc) · 950 Bytes
Breadcrumbs
opencode
/
packages
/
opencode
/
src
/
project
/
instance-context.ts
Copy path
File metadata and controls
24 lines (21 loc) · 950 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import
{
LocalContext
}
from
"@/util/local-context"
import
{
FSUtil
}
from
"@opencode-ai/core/fs-util"
import
type
*
as
Project
from
"./project"
export
interface
InstanceContext
{
directory
:
string
worktree
:
string
project
:
Project
.
Info
}
export
const
context
=
LocalContext
.
create
<
InstanceContext
>
(
"instance"
)
/**
* Check if a path is within the project boundary.
* Returns true if path is inside ctx.directory OR ctx.worktree.
* Paths within the worktree but outside the working directory should not trigger external_directory permission.
*/
export
function
containsPath
(
filepath
:
string
,
ctx
:
InstanceContext
)
:
boolean
{
if
(
FSUtil
.
contains
(
ctx
.
directory
,
filepath
)
)
return
true
// Non-git projects set worktree to "/" which would match ANY absolute path.
// Skip worktree check in this case to preserve external_directory permissions.
if
(
ctx
.
worktree
===
"/"
)
return
false
return
FSUtil
.
contains
(
ctx
.
worktree
,
filepath
)
}
Back
|
FazBrowse Home
|
New Git URL