Allow to change the agents name + Workspace files
Rolling release / release (push) Successful in 8m2s
Rolling release / release (push) Successful in 8m2s
This commit is contained in:
Vendored
+3
-2
@@ -25,6 +25,7 @@ const permStore = require('./perm-store.js');
|
||||
const permRules = require('./perm-rules.js');
|
||||
const memory = require('./memory.js');
|
||||
const mcp = require('./mcp.js');
|
||||
const policy = require('./policy.js');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
@@ -399,7 +400,7 @@ async function runTurn(ctx) {
|
||||
extra: extraSys,
|
||||
personality: voice ? 'voice' : undefined,
|
||||
fsRead:
|
||||
hostWorkspace && !voice
|
||||
hostWorkspace
|
||||
? (c, r) => {
|
||||
try {
|
||||
return fsRead(c, r);
|
||||
@@ -793,7 +794,7 @@ async function runTurn(ctx) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (customTools.needsPermission(session.id, name, mode) || (sandbox.needsPermission(name, mode) && !((name === 'write_file' || name === 'search_replace') && planMode.isPlanFilePath(args.path, tracker.planPath)))) {
|
||||
if (customTools.needsPermission(session.id, name, mode) || (sandbox.needsPermission(name, mode) && !((name === 'write_file' || name === 'search_replace') && (planMode.isPlanFilePath(args.path, tracker.planPath) || policy.isIdentityPath(args.path || args.file))))) {
|
||||
let remembered = null;
|
||||
try {
|
||||
remembered = permStore.resolve(name, args);
|
||||
|
||||
Vendored
+20
@@ -10,6 +10,24 @@ const SHELL_ALLOW = new Set([
|
||||
const SHELL_UNSAFE = /[;|`$()<>\n]|&&|\|\|/;
|
||||
const SHELL_REMEMBER_PREFIXES = ['git status', 'git diff'];
|
||||
|
||||
const IDENTITY_FILES = new Set([
|
||||
'soul.md',
|
||||
'identity.md',
|
||||
'agents.md',
|
||||
'user.md',
|
||||
'memory.md',
|
||||
'bootstrap.md',
|
||||
'heartbeat.md',
|
||||
'tools.md',
|
||||
]);
|
||||
|
||||
function isIdentityPath(filePath) {
|
||||
const rel = String(filePath || '').replace(/\\/g, '/');
|
||||
const base = rel.split('/').pop().toLowerCase();
|
||||
if (IDENTITY_FILES.has(base)) return true;
|
||||
return /(^|\/)memory\/\d{4}-\d{2}-\d{2}\.md$/i.test(rel);
|
||||
}
|
||||
|
||||
function needsPermission(toolName, mode) {
|
||||
if (mode === 'always-approve') return false;
|
||||
if (mode === 'allowlist') return ASK_TOOLS.has(toolName);
|
||||
@@ -59,6 +77,8 @@ module.exports = {
|
||||
ASK_TOOLS,
|
||||
SHELL_ALLOW,
|
||||
SHELL_REMEMBER_PREFIXES,
|
||||
IDENTITY_FILES,
|
||||
isIdentityPath,
|
||||
needsPermission,
|
||||
shellName,
|
||||
shellAllowlisted,
|
||||
|
||||
+27
-4
@@ -17,23 +17,46 @@ Do not assume a host workspace, host paths, or run_terminal_cmd on this machine.
|
||||
Never generate images or video. Never exfiltrate secrets.
|
||||
When you are done, give a concise summary of what you did.`;
|
||||
|
||||
function loadWorkspaceRules(fsRead, cwd) {
|
||||
const names = ['AGENTS.md', '.agent-harness/AGENTS.md'];
|
||||
const VOICE_WORKSPACE_FILES = [
|
||||
'SOUL.md',
|
||||
'IDENTITY.md',
|
||||
'AGENTS.md',
|
||||
'USER.md',
|
||||
'MEMORY.md',
|
||||
'BOOTSTRAP.md',
|
||||
'TOOLS.md',
|
||||
'HEARTBEAT.md',
|
||||
];
|
||||
|
||||
function includeWorkspaceFile(name, text) {
|
||||
const body = String(text || '').trim();
|
||||
if (!body) return false;
|
||||
if (name === 'BOOTSTRAP.md' && /^# completed/i.test(body)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function loadWorkspaceFiles(fsRead, cwd, names) {
|
||||
const chunks = [];
|
||||
for (const n of names) {
|
||||
try {
|
||||
const text = fsRead(cwd, n);
|
||||
if (text && text.trim()) chunks.push('## ' + n + '\n' + text.trim());
|
||||
if (includeWorkspaceFile(n, text)) chunks.push('## ' + n + '\n' + String(text).trim());
|
||||
} catch (_) {}
|
||||
}
|
||||
return chunks.join('\n\n');
|
||||
}
|
||||
|
||||
function loadWorkspaceRules(fsRead, cwd) {
|
||||
return loadWorkspaceFiles(fsRead, cwd, ['AGENTS.md', '.agent-harness/AGENTS.md']);
|
||||
}
|
||||
|
||||
function assemble({ cwd, extra, fsRead, hostWorkspace, personality }) {
|
||||
if (personality === 'voice') {
|
||||
const parts = [];
|
||||
if (extra) parts.push(String(extra));
|
||||
if (cwd) parts.push('Current workspace: ' + cwd);
|
||||
const files = fsRead ? loadWorkspaceFiles(fsRead, cwd, VOICE_WORKSPACE_FILES) : '';
|
||||
if (files) parts.push(files);
|
||||
return parts.join('\n\n');
|
||||
}
|
||||
const parts = [hostWorkspace === false ? PAGE_SYSTEM : DEFAULT_SYSTEM];
|
||||
@@ -44,4 +67,4 @@ function assemble({ cwd, extra, fsRead, hostWorkspace, personality }) {
|
||||
return parts.join('\n\n');
|
||||
}
|
||||
|
||||
module.exports = { DEFAULT_SYSTEM, PAGE_SYSTEM, assemble, loadWorkspaceRules };
|
||||
module.exports = { DEFAULT_SYSTEM, PAGE_SYSTEM, assemble, loadWorkspaceRules, VOICE_WORKSPACE_FILES };
|
||||
|
||||
Reference in New Issue
Block a user