chore: generate
This commit is contained in:
parent
40d5ea1cf1
commit
dc7d665e94
4 changed files with 114 additions and 24 deletions
|
|
@ -17,7 +17,7 @@ export const Parameters = Schema.Struct({
|
||||||
}),
|
}),
|
||||||
depth: Schema.optional(Schema.Number).annotate({
|
depth: Schema.optional(Schema.Number).annotate({
|
||||||
description: "Maximum structure depth to include. Defaults to 3.",
|
description: "Maximum structure depth to include. Defaults to 3.",
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
type Metadata = {
|
type Metadata = {
|
||||||
|
|
@ -33,7 +33,17 @@ type Metadata = {
|
||||||
truncated: boolean
|
truncated: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const IGNORED_DIRS = new Set([".git", "node_modules", "__pycache__", ".venv", "dist", "build", ".next", "target", "vendor"])
|
const IGNORED_DIRS = new Set([
|
||||||
|
".git",
|
||||||
|
"node_modules",
|
||||||
|
"__pycache__",
|
||||||
|
".venv",
|
||||||
|
"dist",
|
||||||
|
"build",
|
||||||
|
".next",
|
||||||
|
"target",
|
||||||
|
"vendor",
|
||||||
|
])
|
||||||
const STRUCTURE_LIMIT = 200
|
const STRUCTURE_LIMIT = 200
|
||||||
const DEPENDENCY_FILES = [
|
const DEPENDENCY_FILES = [
|
||||||
"package.json",
|
"package.json",
|
||||||
|
|
@ -73,7 +83,19 @@ function ecosystems(files: Set<string>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function commonEntrypoints(files: Set<string>) {
|
function commonEntrypoints(files: Set<string>) {
|
||||||
return ["index.ts", "index.tsx", "index.js", "index.mjs", "main.ts", "main.js", "src/index.ts", "src/index.tsx", "src/index.js", "src/main.ts", "src/main.js"].filter((file) => files.has(file))
|
return [
|
||||||
|
"index.ts",
|
||||||
|
"index.tsx",
|
||||||
|
"index.js",
|
||||||
|
"index.mjs",
|
||||||
|
"main.ts",
|
||||||
|
"main.js",
|
||||||
|
"src/index.ts",
|
||||||
|
"src/index.tsx",
|
||||||
|
"src/index.js",
|
||||||
|
"src/main.ts",
|
||||||
|
"src/main.js",
|
||||||
|
].filter((file) => files.has(file))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RepoOverviewTool = Tool.define<typeof Parameters, Metadata, AppFileSystem.Service | Git.Service>(
|
export const RepoOverviewTool = Tool.define<typeof Parameters, Metadata, AppFileSystem.Service | Git.Service>(
|
||||||
|
|
@ -82,7 +104,9 @@ export const RepoOverviewTool = Tool.define<typeof Parameters, Metadata, AppFile
|
||||||
const fs = yield* AppFileSystem.Service
|
const fs = yield* AppFileSystem.Service
|
||||||
const git = yield* Git.Service
|
const git = yield* Git.Service
|
||||||
|
|
||||||
const resolveTarget = Effect.fn("RepoOverviewTool.resolveTarget")(function* (params: Schema.Schema.Type<typeof Parameters>) {
|
const resolveTarget = Effect.fn("RepoOverviewTool.resolveTarget")(function* (
|
||||||
|
params: Schema.Schema.Type<typeof Parameters>,
|
||||||
|
) {
|
||||||
if (params.path) {
|
if (params.path) {
|
||||||
const full = path.isAbsolute(params.path) ? params.path : path.resolve(Instance.directory, params.path)
|
const full = path.isAbsolute(params.path) ? params.path : path.resolve(Instance.directory, params.path)
|
||||||
return { path: full, repository: params.repository }
|
return { path: full, repository: params.repository }
|
||||||
|
|
@ -104,7 +128,10 @@ export const RepoOverviewTool = Tool.define<typeof Parameters, Metadata, AppFile
|
||||||
let truncated = false
|
let truncated = false
|
||||||
const lines: string[] = []
|
const lines: string[] = []
|
||||||
|
|
||||||
const visit: (dir: string, level: number) => Effect.Effect<void> = Effect.fnUntraced(function* (dir: string, level: number) {
|
const visit: (dir: string, level: number) => Effect.Effect<void> = Effect.fnUntraced(function* (
|
||||||
|
dir: string,
|
||||||
|
level: number,
|
||||||
|
) {
|
||||||
if (level >= depth || lines.length >= STRUCTURE_LIMIT) {
|
if (level >= depth || lines.length >= STRUCTURE_LIMIT) {
|
||||||
truncated = truncated || lines.length >= STRUCTURE_LIMIT
|
truncated = truncated || lines.length >= STRUCTURE_LIMIT
|
||||||
return
|
return
|
||||||
|
|
@ -150,7 +177,8 @@ export const RepoOverviewTool = Tool.define<typeof Parameters, Metadata, AppFile
|
||||||
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context<Metadata>) =>
|
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context<Metadata>) =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const target = yield* resolveTarget(params)
|
const target = yield* resolveTarget(params)
|
||||||
const depth = !params.depth || !Number.isInteger(params.depth) || params.depth < 1 || params.depth > 6 ? 3 : params.depth
|
const depth =
|
||||||
|
!params.depth || !Number.isInteger(params.depth) || params.depth < 1 || params.depth > 6 ? 3 : params.depth
|
||||||
|
|
||||||
yield* assertExternalDirectoryEffect(ctx, target.path, { kind: "directory" })
|
yield* assertExternalDirectoryEffect(ctx, target.path, { kind: "directory" })
|
||||||
yield* ctx.ask({
|
yield* ctx.ask({
|
||||||
|
|
@ -166,7 +194,8 @@ export const RepoOverviewTool = Tool.define<typeof Parameters, Metadata, AppFile
|
||||||
|
|
||||||
const info = yield* fs.stat(target.path).pipe(Effect.catch(() => Effect.succeed(undefined)))
|
const info = yield* fs.stat(target.path).pipe(Effect.catch(() => Effect.succeed(undefined)))
|
||||||
if (!info) {
|
if (!info) {
|
||||||
if (target.repository) throw new Error(`Repository is not cloned: ${target.repository}. Use repo_clone first.`)
|
if (target.repository)
|
||||||
|
throw new Error(`Repository is not cloned: ${target.repository}. Use repo_clone first.`)
|
||||||
throw new Error(`Directory not found: ${target.path}`)
|
throw new Error(`Directory not found: ${target.path}`)
|
||||||
}
|
}
|
||||||
if (info.type !== "Directory") throw new Error(`Path is not a directory: ${target.path}`)
|
if (info.type !== "Directory") throw new Error(`Path is not a directory: ${target.path}`)
|
||||||
|
|
@ -175,7 +204,9 @@ export const RepoOverviewTool = Tool.define<typeof Parameters, Metadata, AppFile
|
||||||
const topLevel = new Set(entries.map((entry) => entry.name))
|
const topLevel = new Set(entries.map((entry) => entry.name))
|
||||||
const dependencyFiles = DEPENDENCY_FILES.filter((file) => topLevel.has(file))
|
const dependencyFiles = DEPENDENCY_FILES.filter((file) => topLevel.has(file))
|
||||||
const packageJson = topLevel.has("package.json")
|
const packageJson = topLevel.has("package.json")
|
||||||
? (yield* fs.readJson(path.join(target.path, "package.json")).pipe(Effect.orElseSucceed(() => ({})))) as Record<string, unknown>
|
? ((yield* fs
|
||||||
|
.readJson(path.join(target.path, "package.json"))
|
||||||
|
.pipe(Effect.orElseSucceed(() => ({})))) as Record<string, unknown>)
|
||||||
: {}
|
: {}
|
||||||
|
|
||||||
const entrypoints = [
|
const entrypoints = [
|
||||||
|
|
@ -187,16 +218,20 @@ export const RepoOverviewTool = Tool.define<typeof Parameters, Metadata, AppFile
|
||||||
? Object.keys(packageJson.bin as Record<string, unknown>).map((name) => `bin: ${name}`)
|
? Object.keys(packageJson.bin as Record<string, unknown>).map((name) => `bin: ${name}`)
|
||||||
: []),
|
: []),
|
||||||
...(packageJson.exports && typeof packageJson.exports === "object" && !Array.isArray(packageJson.exports)
|
...(packageJson.exports && typeof packageJson.exports === "object" && !Array.isArray(packageJson.exports)
|
||||||
? Object.keys(packageJson.exports as Record<string, unknown>).slice(0, 10).map((name) => `exports: ${name}`)
|
? Object.keys(packageJson.exports as Record<string, unknown>)
|
||||||
|
.slice(0, 10)
|
||||||
|
.map((name) => `exports: ${name}`)
|
||||||
: []),
|
: []),
|
||||||
]
|
]
|
||||||
|
|
||||||
const common = commonEntrypoints(new Set([
|
const common = commonEntrypoints(
|
||||||
...topLevel,
|
new Set([
|
||||||
...entries
|
...topLevel,
|
||||||
.filter((entry) => entry.name === "src")
|
...entries
|
||||||
.flatMap(() => ["src/index.ts", "src/index.tsx", "src/index.js", "src/main.ts", "src/main.js"]),
|
.filter((entry) => entry.name === "src")
|
||||||
]))
|
.flatMap(() => ["src/index.ts", "src/index.tsx", "src/index.js", "src/main.ts", "src/main.js"]),
|
||||||
|
]),
|
||||||
|
)
|
||||||
const structureResult = yield* structure(target.path, depth)
|
const structureResult = yield* structure(target.path, depth)
|
||||||
const branch = yield* git.branch(target.path)
|
const branch = yield* git.branch(target.path)
|
||||||
const head = yield* git.run(["rev-parse", "HEAD"], { cwd: target.path })
|
const head = yield* git.run(["rev-parse", "HEAD"], { cwd: target.path })
|
||||||
|
|
@ -225,8 +260,12 @@ export const RepoOverviewTool = Tool.define<typeof Parameters, Metadata, AppFile
|
||||||
...(headText ? [`HEAD: ${headText}`] : []),
|
...(headText ? [`HEAD: ${headText}`] : []),
|
||||||
...(metadata.ecosystems.length ? [`Ecosystems: ${metadata.ecosystems.join(", ")}`] : []),
|
...(metadata.ecosystems.length ? [`Ecosystems: ${metadata.ecosystems.join(", ")}`] : []),
|
||||||
...(metadata.package_manager ? [`Package manager: ${metadata.package_manager}`] : []),
|
...(metadata.package_manager ? [`Package manager: ${metadata.package_manager}`] : []),
|
||||||
...(metadata.dependency_files.length ? [`Dependency files: ${metadata.dependency_files.join(", ")}`] : []),
|
...(metadata.dependency_files.length
|
||||||
...(metadata.entrypoints.length ? ["Likely entrypoints:", ...metadata.entrypoints.map((entry) => `- ${entry}`)] : []),
|
? [`Dependency files: ${metadata.dependency_files.join(", ")}`]
|
||||||
|
: []),
|
||||||
|
...(metadata.entrypoints.length
|
||||||
|
? ["Likely entrypoints:", ...metadata.entrypoints.map((entry) => `- ${entry}`)]
|
||||||
|
: []),
|
||||||
"Top-level structure:",
|
"Top-level structure:",
|
||||||
...structureResult.lines,
|
...structureResult.lines,
|
||||||
...(structureResult.truncated ? ["(Structure truncated)"] : []),
|
...(structureResult.truncated ? ["(Structure truncated)"] : []),
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,11 @@ export type Reference = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalize(input: string) {
|
function normalize(input: string) {
|
||||||
return input.trim().replace(/^git\+/, "").replace(/#.*$/, "").replace(/\/+$/, "")
|
return input
|
||||||
|
.trim()
|
||||||
|
.replace(/^git\+/, "")
|
||||||
|
.replace(/#.*$/, "")
|
||||||
|
.replace(/\/+$/, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
function trimGitSuffix(input: string) {
|
function trimGitSuffix(input: string) {
|
||||||
|
|
|
||||||
|
|
@ -908,9 +908,6 @@ export type ReferenceConfigEntry =
|
||||||
* Git repository URL, host/path reference, or GitHub owner/repo shorthand
|
* Git repository URL, host/path reference, or GitHub owner/repo shorthand
|
||||||
*/
|
*/
|
||||||
repository: string
|
repository: string
|
||||||
/**
|
|
||||||
* Branch or ref Scout should clone and inspect
|
|
||||||
*/
|
|
||||||
branch?: string
|
branch?: string
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
|
|
@ -920,9 +917,6 @@ export type ReferenceConfigEntry =
|
||||||
path: string
|
path: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Named git or local directory references that can be @ mentioned as Scout-backed subagents
|
|
||||||
*/
|
|
||||||
export type ReferenceConfig = {
|
export type ReferenceConfig = {
|
||||||
[key: string]: ReferenceConfigEntry
|
[key: string]: ReferenceConfigEntry
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11311,6 +11311,44 @@
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"description": "Server configuration for opencode serve and web commands"
|
"description": "Server configuration for opencode serve and web commands"
|
||||||
},
|
},
|
||||||
|
"ReferenceConfigEntry": {
|
||||||
|
"anyOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"repository": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Git repository URL, host/path reference, or GitHub owner/repo shorthand"
|
||||||
|
},
|
||||||
|
"branch": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["repository"],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"path": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Absolute path, ~/ path, or workspace-relative path to a local reference directory"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["path"],
|
||||||
|
"additionalProperties": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"ReferenceConfig": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": {
|
||||||
|
"$ref": "#/components/schemas/ReferenceConfigEntry"
|
||||||
|
}
|
||||||
|
},
|
||||||
"PermissionActionConfig": {
|
"PermissionActionConfig": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["ask", "allow", "deny"]
|
"enum": ["ask", "allow", "deny"]
|
||||||
|
|
@ -11375,6 +11413,15 @@
|
||||||
"websearch": {
|
"websearch": {
|
||||||
"$ref": "#/components/schemas/PermissionActionConfig"
|
"$ref": "#/components/schemas/PermissionActionConfig"
|
||||||
},
|
},
|
||||||
|
"codesearch": {
|
||||||
|
"$ref": "#/components/schemas/PermissionActionConfig"
|
||||||
|
},
|
||||||
|
"repo_clone": {
|
||||||
|
"$ref": "#/components/schemas/PermissionRuleConfig"
|
||||||
|
},
|
||||||
|
"repo_overview": {
|
||||||
|
"$ref": "#/components/schemas/PermissionRuleConfig"
|
||||||
|
},
|
||||||
"lsp": {
|
"lsp": {
|
||||||
"$ref": "#/components/schemas/PermissionRuleConfig"
|
"$ref": "#/components/schemas/PermissionRuleConfig"
|
||||||
},
|
},
|
||||||
|
|
@ -11851,6 +11898,9 @@
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
|
"reference": {
|
||||||
|
"$ref": "#/components/schemas/ReferenceConfig"
|
||||||
|
},
|
||||||
"watcher": {
|
"watcher": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -11961,6 +12011,9 @@
|
||||||
"explore": {
|
"explore": {
|
||||||
"$ref": "#/components/schemas/AgentConfig"
|
"$ref": "#/components/schemas/AgentConfig"
|
||||||
},
|
},
|
||||||
|
"scout": {
|
||||||
|
"$ref": "#/components/schemas/AgentConfig"
|
||||||
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"$ref": "#/components/schemas/AgentConfig"
|
"$ref": "#/components/schemas/AgentConfig"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue