picocode-core 0.9.119
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 +15 -0
- package/package.json +33 -0
- package/src/agent-transcript.js +80 -0
- package/src/agent.js +170 -0
- package/src/agents.js +213 -0
- package/src/attachments.js +141 -0
- package/src/boot.js +28 -0
- package/src/catalog-snapshot.json +1 -0
- package/src/catalog.js +86 -0
- package/src/codex-models.js +56 -0
- package/src/commands.js +61 -0
- package/src/compaction.js +82 -0
- package/src/completion.js +21 -0
- package/src/config.js +32 -0
- package/src/context.js +82 -0
- package/src/controller.js +1263 -0
- package/src/conversation-search.js +101 -0
- package/src/deliberation-history.js +65 -0
- package/src/deliberation.js +61 -0
- package/src/derive.js +307 -0
- package/src/events.js +54 -0
- package/src/export.js +16 -0
- package/src/files.js +39 -0
- package/src/format.js +6 -0
- package/src/fuzzy.js +41 -0
- package/src/git.js +156 -0
- package/src/history.js +51 -0
- package/src/init.js +25 -0
- package/src/keys.js +26 -0
- package/src/mcp.js +280 -0
- package/src/memory.js +120 -0
- package/src/models.js +14 -0
- package/src/openai-auth.js +204 -0
- package/src/paths.js +67 -0
- package/src/reversible-edit.js +79 -0
- package/src/rewind.js +84 -0
- package/src/session-index.js +264 -0
- package/src/session-lock.js +27 -0
- package/src/session.js +160 -0
- package/src/shells.js +166 -0
- package/src/skills.js +164 -0
- package/src/steer.js +129 -0
- package/src/system-prompt.js +49 -0
- package/src/terminal-theme.js +49 -0
- package/src/tools/bash.js +184 -0
- package/src/tools/diff.js +18 -0
- package/src/tools/edit.js +95 -0
- package/src/tools/glob.js +43 -0
- package/src/tools/grep.js +59 -0
- package/src/tools/index.js +296 -0
- package/src/tools/read.js +49 -0
- package/src/tools/recorder.js +74 -0
- package/src/tools/web.js +84 -0
- package/src/tools/write.js +48 -0
- package/src/update.js +82 -0
- package/src/user-tools.js +59 -0
- package/src/wakeups.js +40 -0
package/src/context.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
+
import { homedir } from 'node:os'
|
|
3
|
+
import { dirname, join, resolve } from 'node:path'
|
|
4
|
+
import { globalAgentsFile } from './paths.js'
|
|
5
|
+
|
|
6
|
+
function readIfExists(path) {
|
|
7
|
+
try {
|
|
8
|
+
return existsSync(path) ? readFileSync(path, 'utf-8') : null
|
|
9
|
+
} catch {
|
|
10
|
+
return null
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function contextStopDir(cwd) {
|
|
15
|
+
let dir = resolve(cwd)
|
|
16
|
+
const home = homedir()
|
|
17
|
+
while (true) {
|
|
18
|
+
if (existsSync(join(dir, '.git')) || dir === home) return dir
|
|
19
|
+
const parent = dirname(dir)
|
|
20
|
+
if (parent === dir) return resolve(cwd)
|
|
21
|
+
dir = parent
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function ancestorDirs(cwd, stopDir) {
|
|
26
|
+
const dirs = []
|
|
27
|
+
let dir = resolve(cwd)
|
|
28
|
+
while (true) {
|
|
29
|
+
dirs.unshift(dir)
|
|
30
|
+
if (dir === stopDir) break
|
|
31
|
+
const parent = dirname(dir)
|
|
32
|
+
if (parent === dir) break
|
|
33
|
+
dir = parent
|
|
34
|
+
}
|
|
35
|
+
return dirs
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// AGENTS.md is canonical; CLAUDE.md is honored per directory only when no
|
|
39
|
+
// AGENTS.md exists there, so repos documented for other agents still work.
|
|
40
|
+
// the fallback never applies to the global file: that is ~/.pico/AGENTS.md
|
|
41
|
+
// alone, and personal files like ~/.claude/CLAUDE.md are another tool's
|
|
42
|
+
function readDirContext(dir) {
|
|
43
|
+
const agents = join(dir, 'AGENTS.md')
|
|
44
|
+
const agentsContent = readIfExists(agents)
|
|
45
|
+
if (agentsContent) return { path: agents, content: agentsContent }
|
|
46
|
+
const claude = join(dir, 'CLAUDE.md')
|
|
47
|
+
const claudeContent = readIfExists(claude)
|
|
48
|
+
if (claudeContent) return { path: claude, content: claudeContent }
|
|
49
|
+
return null
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function loadStartupContext(cwd) {
|
|
53
|
+
const stopDir = contextStopDir(cwd)
|
|
54
|
+
const files = []
|
|
55
|
+
const globalContent = readIfExists(globalAgentsFile())
|
|
56
|
+
if (globalContent) files.push({ path: globalAgentsFile(), content: globalContent })
|
|
57
|
+
for (const dir of ancestorDirs(cwd, stopDir)) {
|
|
58
|
+
const entry = readDirContext(dir)
|
|
59
|
+
if (entry) files.push(entry)
|
|
60
|
+
}
|
|
61
|
+
return { files, stopDir }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function createContextTracker({ stopDir, loaded }) {
|
|
65
|
+
return {
|
|
66
|
+
loaded,
|
|
67
|
+
check(filePath) {
|
|
68
|
+
const target = dirname(resolve(filePath))
|
|
69
|
+
if (!target.startsWith(stopDir)) return []
|
|
70
|
+
const fresh = []
|
|
71
|
+
for (const dir of ancestorDirs(target, stopDir)) {
|
|
72
|
+
if (loaded.has(join(dir, 'AGENTS.md')) || loaded.has(join(dir, 'CLAUDE.md'))) continue
|
|
73
|
+
const entry = readDirContext(dir)
|
|
74
|
+
if (entry) {
|
|
75
|
+
loaded.add(entry.path)
|
|
76
|
+
fresh.push(entry)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return fresh
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
}
|