Include all credentials and runtime config
Remove secret exclusions from .gitignore (local-only repo). Add openclaw runtime state: credentials, identity, devices, hooks, telegram, secrets, agent configs. Exclude noisy/binary data: sessions, sqlite, media, temp files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
53
openclaw/hooks/bootstrap-extra-files/HOOK.md
Executable file
53
openclaw/hooks/bootstrap-extra-files/HOOK.md
Executable file
@@ -0,0 +1,53 @@
|
||||
---
|
||||
name: bootstrap-extra-files
|
||||
description: "Inject additional workspace bootstrap files via glob/path patterns"
|
||||
homepage: https://docs.openclaw.ai/automation/hooks#bootstrap-extra-files
|
||||
metadata:
|
||||
{
|
||||
"openclaw":
|
||||
{
|
||||
"emoji": "📎",
|
||||
"events": ["agent:bootstrap"],
|
||||
"requires": { "config": ["workspace.dir"] },
|
||||
"install": [{ "id": "bundled", "kind": "bundled", "label": "Bundled with OpenClaw" }],
|
||||
},
|
||||
}
|
||||
---
|
||||
|
||||
# Bootstrap Extra Files Hook
|
||||
|
||||
Loads additional bootstrap files into `Project Context` during `agent:bootstrap`.
|
||||
|
||||
## Why
|
||||
|
||||
Use this when your workspace has multiple context roots (for example monorepos) and
|
||||
you want to include extra `AGENTS.md`/`TOOLS.md`-class files without changing the
|
||||
workspace root.
|
||||
|
||||
## Configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"hooks": {
|
||||
"internal": {
|
||||
"enabled": true,
|
||||
"entries": {
|
||||
"bootstrap-extra-files": {
|
||||
"enabled": true,
|
||||
"paths": ["packages/*/AGENTS.md", "packages/*/TOOLS.md"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
- `paths` (string[]): preferred list of glob/path patterns.
|
||||
- `patterns` (string[]): alias of `paths`.
|
||||
- `files` (string[]): alias of `paths`.
|
||||
|
||||
All paths are resolved from the workspace and must stay inside it (including realpath checks).
|
||||
Only recognized bootstrap basenames are loaded (`AGENTS.md`, `SOUL.md`, `TOOLS.md`,
|
||||
`IDENTITY.md`, `USER.md`, `HEARTBEAT.md`, `BOOTSTRAP.md`, `MEMORY.md`, `memory.md`).
|
||||
45
openclaw/hooks/bootstrap-extra-files/handler.js
Normal file
45
openclaw/hooks/bootstrap-extra-files/handler.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import "../../paths-hfkBoC7i.js";
|
||||
import { t as createSubsystemLogger } from "../../subsystem-C-Cf_MFK.js";
|
||||
import { d as loadExtraBootstrapFilesWithDiagnostics, u as filterBootstrapFilesForSession } from "../../workspace-CaW79EXh.js";
|
||||
import "../../logger-BW8uLq6f.js";
|
||||
import { i as isAgentBootstrapEvent } from "../../legacy-names-BAf61_0I.js";
|
||||
import "../../frontmatter-CZF6xkL3.js";
|
||||
import { t as resolveHookConfig } from "../../config-Bs6iYHRw.js";
|
||||
//#region src/hooks/bundled/bootstrap-extra-files/handler.ts
|
||||
const HOOK_KEY = "bootstrap-extra-files";
|
||||
const log = createSubsystemLogger("bootstrap-extra-files");
|
||||
function normalizeStringArray(value) {
|
||||
if (!Array.isArray(value)) return [];
|
||||
return value.map((v) => typeof v === "string" ? v.trim() : "").filter(Boolean);
|
||||
}
|
||||
function resolveExtraBootstrapPatterns(hookConfig) {
|
||||
const fromPaths = normalizeStringArray(hookConfig.paths);
|
||||
if (fromPaths.length > 0) return fromPaths;
|
||||
const fromPatterns = normalizeStringArray(hookConfig.patterns);
|
||||
if (fromPatterns.length > 0) return fromPatterns;
|
||||
return normalizeStringArray(hookConfig.files);
|
||||
}
|
||||
const bootstrapExtraFilesHook = async (event) => {
|
||||
if (!isAgentBootstrapEvent(event)) return;
|
||||
const context = event.context;
|
||||
const hookConfig = resolveHookConfig(context.cfg, HOOK_KEY);
|
||||
if (!hookConfig || hookConfig.enabled === false) return;
|
||||
const patterns = resolveExtraBootstrapPatterns(hookConfig);
|
||||
if (patterns.length === 0) return;
|
||||
try {
|
||||
const { files: extras, diagnostics } = await loadExtraBootstrapFilesWithDiagnostics(context.workspaceDir, patterns);
|
||||
if (diagnostics.length > 0) log.debug("skipped extra bootstrap candidates", {
|
||||
skipped: diagnostics.length,
|
||||
reasons: diagnostics.reduce((counts, item) => {
|
||||
counts[item.reason] = (counts[item.reason] ?? 0) + 1;
|
||||
return counts;
|
||||
}, {})
|
||||
});
|
||||
if (extras.length === 0) return;
|
||||
context.bootstrapFiles = filterBootstrapFilesForSession([...context.bootstrapFiles, ...extras], context.sessionKey);
|
||||
} catch (err) {
|
||||
log.warn(`failed: ${String(err)}`);
|
||||
}
|
||||
};
|
||||
//#endregion
|
||||
export { bootstrapExtraFilesHook as default };
|
||||
Reference in New Issue
Block a user