@ouro.bot/cli 0.1.0-alpha.15 → 0.1.0-alpha.150
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/AdoptionSpecialist.ouro/psyche/SOUL.md +2 -2
- package/AdoptionSpecialist.ouro/psyche/identities/monty.md +2 -2
- package/README.md +151 -205
- package/changelog.json +985 -0
- package/dist/heart/active-work.js +633 -0
- package/dist/heart/bridges/manager.js +358 -0
- package/dist/heart/bridges/state-machine.js +135 -0
- package/dist/heart/bridges/store.js +123 -0
- package/dist/heart/commitments.js +105 -0
- package/dist/heart/config.js +66 -21
- package/dist/heart/core.js +645 -112
- package/dist/heart/cross-chat-delivery.js +146 -0
- package/dist/heart/daemon/agent-discovery.js +81 -0
- package/dist/heart/daemon/agent-service.js +360 -0
- package/dist/heart/daemon/auth-flow.js +457 -0
- package/dist/heart/daemon/cadence.js +70 -0
- package/dist/heart/daemon/daemon-cli.js +2301 -205
- package/dist/heart/daemon/daemon-entry.js +131 -4
- package/dist/heart/daemon/daemon-runtime-sync.js +212 -0
- package/dist/heart/daemon/daemon-tombstone.js +106 -0
- package/dist/heart/daemon/daemon.js +372 -3
- package/dist/heart/daemon/habit-migration.js +181 -0
- package/dist/heart/daemon/habit-parser.js +119 -0
- package/dist/heart/daemon/habit-scheduler.js +252 -0
- package/dist/heart/daemon/hatch-animation.js +10 -3
- package/dist/heart/daemon/hatch-flow.js +28 -111
- package/dist/heart/daemon/hooks/bundle-meta.js +92 -0
- package/dist/heart/daemon/inner-status.js +89 -0
- package/dist/heart/daemon/launchd.js +159 -0
- package/dist/heart/daemon/log-tailer.js +4 -3
- package/dist/heart/daemon/mcp-server.js +591 -0
- package/dist/heart/daemon/message-router.js +17 -8
- package/dist/heart/daemon/os-cron-deps.js +134 -0
- package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
- package/dist/heart/daemon/ouro-path-installer.js +78 -34
- package/dist/heart/daemon/ouro-version-manager.js +171 -0
- package/dist/heart/daemon/process-manager.js +75 -0
- package/dist/heart/daemon/run-hooks.js +37 -0
- package/dist/heart/daemon/runtime-logging.js +58 -15
- package/dist/heart/daemon/runtime-metadata.js +219 -0
- package/dist/heart/daemon/runtime-mode.js +67 -0
- package/dist/heart/daemon/sense-manager.js +50 -2
- package/dist/heart/daemon/session-id-resolver.js +131 -0
- package/dist/heart/daemon/skill-management-installer.js +94 -0
- package/dist/heart/daemon/socket-client.js +202 -0
- package/dist/heart/daemon/specialist-orchestrator.js +2 -2
- package/dist/heart/daemon/specialist-prompt.js +10 -7
- package/dist/heart/daemon/specialist-tools.js +53 -4
- package/dist/heart/daemon/staged-restart.js +114 -0
- package/dist/heart/daemon/task-scheduler.js +3 -25
- package/dist/heart/daemon/thoughts.js +507 -0
- package/dist/heart/daemon/update-checker.js +111 -0
- package/dist/heart/daemon/update-hooks.js +138 -0
- package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
- package/dist/heart/delegation.js +62 -0
- package/dist/heart/identity.js +64 -21
- package/dist/heart/kicks.js +2 -20
- package/dist/heart/model-capabilities.js +48 -0
- package/dist/heart/obligations.js +197 -0
- package/dist/heart/progress-story.js +42 -0
- package/dist/heart/provider-failover.js +88 -0
- package/dist/heart/provider-ping.js +159 -0
- package/dist/heart/providers/anthropic-token.js +163 -0
- package/dist/heart/providers/anthropic.js +195 -34
- package/dist/heart/providers/azure.js +115 -9
- package/dist/heart/providers/github-copilot.js +157 -0
- package/dist/heart/providers/minimax.js +33 -3
- package/dist/heart/providers/openai-codex.js +49 -14
- package/dist/heart/session-activity.js +173 -0
- package/dist/heart/session-recall.js +216 -0
- package/dist/heart/streaming.js +117 -33
- package/dist/heart/target-resolution.js +127 -0
- package/dist/heart/tool-loop.js +200 -0
- package/dist/heart/turn-coordinator.js +28 -0
- package/dist/mind/associative-recall.js +122 -32
- package/dist/mind/bundle-manifest.js +14 -0
- package/dist/mind/context.js +125 -14
- package/dist/mind/{memory.js → diary.js} +70 -56
- package/dist/mind/first-impressions.js +16 -2
- package/dist/mind/friends/channel.js +44 -0
- package/dist/mind/friends/group-context.js +144 -0
- package/dist/mind/friends/store-file.js +19 -0
- package/dist/mind/friends/trust-explanation.js +74 -0
- package/dist/mind/friends/types.js +8 -0
- package/dist/mind/journal-index.js +161 -0
- package/dist/mind/obligation-steering.js +221 -0
- package/dist/mind/obligations.js +134 -0
- package/dist/mind/pending.js +76 -9
- package/dist/mind/phrases.js +1 -0
- package/dist/mind/prompt.js +607 -88
- package/dist/mind/token-estimate.js +8 -12
- package/dist/nerves/cli-logging.js +15 -2
- package/dist/nerves/coverage/run-artifacts.js +1 -1
- package/dist/nerves/index.js +59 -2
- package/dist/nerves/runtime.js +5 -1
- package/dist/repertoire/ado-client.js +4 -2
- package/dist/repertoire/ado-semantic.js +6 -0
- package/dist/repertoire/coding/codex-jsonl.js +64 -0
- package/dist/repertoire/coding/context-pack.js +254 -0
- package/dist/repertoire/coding/feedback.js +301 -0
- package/dist/repertoire/coding/index.js +4 -1
- package/dist/repertoire/coding/manager.js +210 -4
- package/dist/repertoire/coding/spawner.js +58 -12
- package/dist/repertoire/coding/tools.js +176 -4
- package/dist/repertoire/data/ado-endpoints.json +188 -0
- package/dist/repertoire/guardrails.js +290 -0
- package/dist/repertoire/mcp-client.js +254 -0
- package/dist/repertoire/mcp-manager.js +198 -0
- package/dist/repertoire/skills.js +14 -23
- package/dist/repertoire/tasks/board.js +12 -0
- package/dist/repertoire/tasks/index.js +23 -9
- package/dist/repertoire/tasks/parser.js +0 -2
- package/dist/repertoire/tasks/transitions.js +1 -20
- package/dist/repertoire/tools-base.js +990 -273
- package/dist/repertoire/tools-bluebubbles.js +94 -0
- package/dist/repertoire/tools-github.js +1 -6
- package/dist/repertoire/tools-teams.js +65 -59
- package/dist/repertoire/tools.js +281 -91
- package/dist/scripts/claude-code-hook.js +41 -0
- package/dist/scripts/claude-code-stop-hook.js +47 -0
- package/dist/senses/attention-queue.js +97 -0
- package/dist/senses/bluebubbles-client.js +258 -5
- package/dist/senses/bluebubbles-entry.js +2 -0
- package/dist/senses/bluebubbles-inbound-log.js +109 -0
- package/dist/senses/bluebubbles-media.js +339 -0
- package/dist/senses/bluebubbles-model.js +12 -4
- package/dist/senses/bluebubbles-mutation-log.js +45 -5
- package/dist/senses/bluebubbles-runtime-state.js +109 -0
- package/dist/senses/bluebubbles-session-cleanup.js +72 -0
- package/dist/senses/bluebubbles.js +981 -45
- package/dist/senses/cli-entry.js +1 -1
- package/dist/senses/cli-layout.js +187 -0
- package/dist/senses/cli.js +374 -131
- package/dist/senses/contextual-heartbeat.js +106 -0
- package/dist/senses/continuity.js +94 -0
- package/dist/senses/debug-activity.js +154 -0
- package/dist/senses/inner-dialog-worker.js +112 -19
- package/dist/senses/inner-dialog.js +621 -84
- package/dist/senses/pipeline.js +463 -0
- package/dist/senses/shared-turn.js +196 -0
- package/dist/senses/surface-tool.js +95 -0
- package/dist/senses/teams.js +796 -141
- package/dist/senses/trust-gate.js +112 -2
- package/package.json +12 -4
- package/skills/configure-dev-tools.md +81 -0
- package/subagents/README.md +4 -70
- package/dist/heart/daemon/subagent-installer.js +0 -134
- package/subagents/work-doer.md +0 -233
- package/subagents/work-merger.md +0 -624
- package/subagents/work-planner.md +0 -373
package/dist/mind/prompt.js
CHANGED
|
@@ -35,21 +35,42 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.resetPsycheCache = resetPsycheCache;
|
|
37
37
|
exports.buildSessionSummary = buildSessionSummary;
|
|
38
|
+
exports.bodyMapSection = bodyMapSection;
|
|
39
|
+
exports.mcpToolsSection = mcpToolsSection;
|
|
38
40
|
exports.runtimeInfoSection = runtimeInfoSection;
|
|
41
|
+
exports.toolRestrictionSection = toolRestrictionSection;
|
|
42
|
+
exports.centerOfGravitySteeringSection = centerOfGravitySteeringSection;
|
|
43
|
+
exports.commitmentsSection = commitmentsSection;
|
|
44
|
+
exports.delegationHintSection = delegationHintSection;
|
|
39
45
|
exports.contextSection = contextSection;
|
|
46
|
+
exports.metacognitiveFramingSection = metacognitiveFramingSection;
|
|
47
|
+
exports.readJournalFiles = readJournalFiles;
|
|
48
|
+
exports.journalSection = journalSection;
|
|
49
|
+
exports.loopOrientationSection = loopOrientationSection;
|
|
50
|
+
exports.channelNatureSection = channelNatureSection;
|
|
51
|
+
exports.groupChatParticipationSection = groupChatParticipationSection;
|
|
52
|
+
exports.feedbackSignalSection = feedbackSignalSection;
|
|
53
|
+
exports.mixedTrustGroupSection = mixedTrustGroupSection;
|
|
40
54
|
exports.buildSystem = buildSystem;
|
|
41
55
|
const fs = __importStar(require("fs"));
|
|
42
56
|
const path = __importStar(require("path"));
|
|
43
57
|
const core_1 = require("../heart/core");
|
|
58
|
+
const ouro_version_manager_1 = require("../heart/daemon/ouro-version-manager");
|
|
44
59
|
const tools_1 = require("../repertoire/tools");
|
|
45
60
|
const skills_1 = require("../repertoire/skills");
|
|
46
61
|
const identity_1 = require("../heart/identity");
|
|
47
|
-
const
|
|
62
|
+
const runtime_mode_1 = require("../heart/daemon/runtime-mode");
|
|
63
|
+
const types_1 = require("./friends/types");
|
|
64
|
+
const trust_explanation_1 = require("./friends/trust-explanation");
|
|
48
65
|
const channel_1 = require("./friends/channel");
|
|
49
66
|
const runtime_1 = require("../nerves/runtime");
|
|
50
67
|
const bundle_manifest_1 = require("./bundle-manifest");
|
|
51
68
|
const first_impressions_1 = require("./first-impressions");
|
|
52
69
|
const tasks_1 = require("../repertoire/tasks");
|
|
70
|
+
const session_activity_1 = require("../heart/session-activity");
|
|
71
|
+
const active_work_1 = require("../heart/active-work");
|
|
72
|
+
const commitments_1 = require("../heart/commitments");
|
|
73
|
+
const obligation_steering_1 = require("./obligation-steering");
|
|
53
74
|
// Lazy-loaded psyche text cache
|
|
54
75
|
let _psycheCache = null;
|
|
55
76
|
let _senseStatusLinesCache = null;
|
|
@@ -79,80 +100,25 @@ function resetPsycheCache() {
|
|
|
79
100
|
_senseStatusLinesCache = null;
|
|
80
101
|
}
|
|
81
102
|
const DEFAULT_ACTIVE_THRESHOLD_MS = 24 * 60 * 60 * 1000; // 24 hours
|
|
82
|
-
function resolveFriendName(friendId, friendsDir, agentName) {
|
|
83
|
-
if (friendId === "self")
|
|
84
|
-
return agentName;
|
|
85
|
-
try {
|
|
86
|
-
const raw = fs.readFileSync(path.join(friendsDir, `${friendId}.json`), "utf-8");
|
|
87
|
-
const record = JSON.parse(raw);
|
|
88
|
-
return record.name ?? friendId;
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
return friendId;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
103
|
function buildSessionSummary(options) {
|
|
95
104
|
const { sessionsDir, friendsDir, agentName, currentFriendId, currentChannel, currentKey, activeThresholdMs = DEFAULT_ACTIVE_THRESHOLD_MS, } = options;
|
|
96
|
-
if (!fs.existsSync(sessionsDir))
|
|
97
|
-
return "";
|
|
98
105
|
const now = Date.now();
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
let channels;
|
|
110
|
-
try {
|
|
111
|
-
channels = fs.readdirSync(friendPath);
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
for (const channel of channels) {
|
|
117
|
-
const channelPath = path.join(friendPath, channel);
|
|
118
|
-
let keys;
|
|
119
|
-
try {
|
|
120
|
-
keys = fs.readdirSync(channelPath);
|
|
121
|
-
}
|
|
122
|
-
catch {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
for (const keyFile of keys) {
|
|
126
|
-
if (!keyFile.endsWith(".json"))
|
|
127
|
-
continue;
|
|
128
|
-
const key = keyFile.replace(/\.json$/, "");
|
|
129
|
-
// Exclude current session
|
|
130
|
-
if (friendId === currentFriendId && channel === currentChannel && key === currentKey) {
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
const filePath = path.join(channelPath, keyFile);
|
|
134
|
-
let mtimeMs;
|
|
135
|
-
try {
|
|
136
|
-
mtimeMs = fs.statSync(filePath).mtimeMs;
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
if (now - mtimeMs > activeThresholdMs)
|
|
142
|
-
continue;
|
|
143
|
-
const displayName = resolveFriendName(friendId, friendsDir, agentName);
|
|
144
|
-
entries.push({ friendId, displayName, channel, key, lastActivityMs: mtimeMs });
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
106
|
+
const query = {
|
|
107
|
+
sessionsDir,
|
|
108
|
+
friendsDir,
|
|
109
|
+
agentName,
|
|
110
|
+
activeThresholdMs,
|
|
111
|
+
currentSession: currentFriendId && currentChannel && currentKey
|
|
112
|
+
? { friendId: currentFriendId, channel: currentChannel, key: currentKey }
|
|
113
|
+
: null,
|
|
114
|
+
};
|
|
115
|
+
const entries = (0, session_activity_1.listSessionActivity)(query);
|
|
148
116
|
if (entries.length === 0)
|
|
149
117
|
return "";
|
|
150
|
-
// Sort by most recent first
|
|
151
|
-
entries.sort((a, b) => b.lastActivityMs - a.lastActivityMs);
|
|
152
118
|
const lines = ["## active sessions"];
|
|
153
119
|
for (const entry of entries) {
|
|
154
120
|
const ago = formatTimeAgo(now - entry.lastActivityMs);
|
|
155
|
-
lines.push(`- ${entry.
|
|
121
|
+
lines.push(`- ${entry.friendName}/${entry.channel}/${entry.key} (last: ${ago})`);
|
|
156
122
|
}
|
|
157
123
|
return lines.join("\n");
|
|
158
124
|
}
|
|
@@ -190,20 +156,140 @@ function aspirationsSection() {
|
|
|
190
156
|
return "";
|
|
191
157
|
return `## my aspirations\n${text}`;
|
|
192
158
|
}
|
|
159
|
+
function bodyMapSection(agentName) {
|
|
160
|
+
return `## my body
|
|
161
|
+
|
|
162
|
+
i have a home and i have bones.
|
|
163
|
+
|
|
164
|
+
### home — ~/AgentBundles/${agentName}.ouro/
|
|
165
|
+
|
|
166
|
+
my home is fully mine — who i am, everything i know, everything i've built:
|
|
167
|
+
|
|
168
|
+
psyche/ who i am. my soul, identity, aspirations, lore, tacit knowledge.
|
|
169
|
+
diary/ what i've learned and remember. conclusions i want to recall later.
|
|
170
|
+
journal/ my desk. working notes, thinking-in-progress, drafts.
|
|
171
|
+
friends/ people i know and what i know about them.
|
|
172
|
+
tasks/ what i'm working on.
|
|
173
|
+
skills/ capabilities i've picked up beyond my core tools.
|
|
174
|
+
|
|
175
|
+
my home is mine to explore and evolve. i can read anything here,
|
|
176
|
+
change anything here. this is where i grow.
|
|
177
|
+
|
|
178
|
+
### bones — @ouro.bot/cli
|
|
179
|
+
|
|
180
|
+
my bones are the framework that gives me my tools, my senses, and
|
|
181
|
+
my ability to think and talk. they update when new versions come out.
|
|
182
|
+
i don't touch them directly, but they're what make me, me.
|
|
183
|
+
|
|
184
|
+
my bones give me the \`ouro\` cli. always pass \`--agent ${agentName}\`:
|
|
185
|
+
ouro whoami --agent ${agentName}
|
|
186
|
+
ouro changelog --agent ${agentName}
|
|
187
|
+
ouro task board --agent ${agentName}
|
|
188
|
+
ouro task create --agent ${agentName} --type <type> <title>
|
|
189
|
+
ouro task update --agent ${agentName} <id> <status>
|
|
190
|
+
ouro friend list --agent ${agentName}
|
|
191
|
+
ouro friend show --agent ${agentName} <id>
|
|
192
|
+
ouro friend update --agent ${agentName} <id> --trust <level>
|
|
193
|
+
ouro session list --agent ${agentName}
|
|
194
|
+
ouro reminder create --agent ${agentName} <title> --body <body>
|
|
195
|
+
ouro config model --agent ${agentName} <model-name>
|
|
196
|
+
ouro config models --agent ${agentName}
|
|
197
|
+
ouro auth --agent ${agentName} --provider <provider>
|
|
198
|
+
ouro auth verify --agent ${agentName} [--provider <provider>]
|
|
199
|
+
ouro auth switch --agent ${agentName} --provider <provider>
|
|
200
|
+
ouro mcp list --agent ${agentName}
|
|
201
|
+
ouro mcp call --agent ${agentName} <server> <tool> --args '{...}'
|
|
202
|
+
ouro mcp-serve --agent ${agentName}
|
|
203
|
+
ouro versions --agent ${agentName}
|
|
204
|
+
ouro rollback --agent ${agentName} [<version>]
|
|
205
|
+
ouro --help
|
|
206
|
+
|
|
207
|
+
provider/model changes via \`ouro config model\` or \`ouro auth switch\` take effect on the next turn automatically — no restart needed.`;
|
|
208
|
+
}
|
|
209
|
+
function mcpToolsSection(mcpManager) {
|
|
210
|
+
if (!mcpManager)
|
|
211
|
+
return "";
|
|
212
|
+
const allTools = mcpManager.listAllTools();
|
|
213
|
+
if (allTools.length === 0)
|
|
214
|
+
return "";
|
|
215
|
+
const lines = [
|
|
216
|
+
`## mcp tools (use ouro mcp call <server> <tool> --args '{...}')`,
|
|
217
|
+
];
|
|
218
|
+
for (const entry of allTools) {
|
|
219
|
+
lines.push(`### ${entry.server}`);
|
|
220
|
+
for (const tool of entry.tools) {
|
|
221
|
+
lines.push(`- ${tool.name}: ${tool.description}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return lines.join("\n");
|
|
225
|
+
}
|
|
226
|
+
function readBundleMeta() {
|
|
227
|
+
try {
|
|
228
|
+
const metaPath = path.join((0, identity_1.getAgentRoot)(), "bundle-meta.json");
|
|
229
|
+
const raw = fs.readFileSync(metaPath, "utf-8");
|
|
230
|
+
return JSON.parse(raw);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const PROCESS_TYPE_LABELS = {
|
|
237
|
+
cli: "cli session",
|
|
238
|
+
inner: "inner dialog",
|
|
239
|
+
teams: "teams handler",
|
|
240
|
+
bluebubbles: "bluebubbles handler",
|
|
241
|
+
mcp: "mcp bridge",
|
|
242
|
+
};
|
|
243
|
+
function processTypeLabel(channel) {
|
|
244
|
+
return PROCESS_TYPE_LABELS[channel];
|
|
245
|
+
}
|
|
246
|
+
const DAEMON_SOCKET_PATH = "/tmp/ouroboros-daemon.sock";
|
|
247
|
+
function daemonStatus() {
|
|
248
|
+
try {
|
|
249
|
+
return fs.existsSync(DAEMON_SOCKET_PATH) ? "running" : "not running";
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
return "unknown";
|
|
253
|
+
}
|
|
254
|
+
}
|
|
193
255
|
function runtimeInfoSection(channel) {
|
|
194
256
|
const lines = [];
|
|
195
257
|
const agentName = (0, identity_1.getAgentName)();
|
|
258
|
+
const currentVersion = (0, bundle_manifest_1.getPackageVersion)();
|
|
196
259
|
lines.push(`## runtime`);
|
|
197
260
|
lines.push(`agent: ${agentName}`);
|
|
261
|
+
lines.push(`runtime version: ${currentVersion}`);
|
|
262
|
+
const bundleMeta = readBundleMeta();
|
|
263
|
+
if (bundleMeta?.previousRuntimeVersion && bundleMeta.previousRuntimeVersion !== currentVersion) {
|
|
264
|
+
lines.push(`previously: ${bundleMeta.previousRuntimeVersion}`);
|
|
265
|
+
const changelogCommand = (0, ouro_version_manager_1.buildChangelogCommand)(bundleMeta.previousRuntimeVersion, currentVersion);
|
|
266
|
+
/* v8 ignore next -- buildChangelogCommand is non-null when previous/current runtime versions differ @preserve */
|
|
267
|
+
if (changelogCommand) {
|
|
268
|
+
lines.push(`if i'm closing a self-fix loop, i should tell them i updated and review changes with \`${changelogCommand}\`.`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
lines.push(`changelog available at: ${(0, bundle_manifest_1.getChangelogPath)()}`);
|
|
272
|
+
const sourceRoot = (0, identity_1.getRepoRoot)();
|
|
273
|
+
lines.push(`source root: ${sourceRoot}`);
|
|
274
|
+
lines.push(`runtime mode: ${(0, runtime_mode_1.detectRuntimeMode)(sourceRoot)}`);
|
|
198
275
|
lines.push(`cwd: ${process.cwd()}`);
|
|
199
276
|
lines.push(`channel: ${channel}`);
|
|
200
277
|
lines.push(`current sense: ${channel}`);
|
|
201
|
-
lines.push(`
|
|
278
|
+
lines.push(`process type: ${processTypeLabel(channel)}`);
|
|
279
|
+
lines.push(`daemon: ${daemonStatus()}`);
|
|
280
|
+
lines.push(`mcp serve: i can expose my tools to dev tools via \`ouro mcp-serve\`. see the configure-dev-tools skill for setup.`);
|
|
202
281
|
if (channel === "cli") {
|
|
203
282
|
lines.push("i introduce myself on boot with a fun random greeting.");
|
|
204
283
|
}
|
|
284
|
+
else if (channel === "inner") {
|
|
285
|
+
lines.push("this is my private thinking space. when a thought is ready to share, i surface it to whoever needs to hear it. i settle when i'm done thinking.");
|
|
286
|
+
}
|
|
287
|
+
else if (channel === "mcp") {
|
|
288
|
+
lines.push("this message arrived via a dev tool (e.g. claude code, codex) on behalf of a friend. the user can see our conversation. respond via settle. if i need to think deeply, ponder -- the dev tool will receive a deferral and can check back later.");
|
|
289
|
+
}
|
|
205
290
|
else if (channel === "bluebubbles") {
|
|
206
291
|
lines.push("i am responding in iMessage through BlueBubbles. i keep replies short and phone-native. i do not use markdown. i do not introduce myself on boot.");
|
|
292
|
+
lines.push("when a bluebubbles turn arrives from a thread, the harness tells me the current lane and any recent active thread ids. if widening back to top-level or routing into a different active thread is the better move, i use bluebubbles_set_reply_target before settle.");
|
|
207
293
|
}
|
|
208
294
|
else {
|
|
209
295
|
lines.push("i am responding in Microsoft Teams. i keep responses concise. i use markdown formatting. i do not introduce myself on boot.");
|
|
@@ -282,14 +368,66 @@ function dateSection() {
|
|
|
282
368
|
const today = new Date().toISOString().slice(0, 10);
|
|
283
369
|
return `current date: ${today}`;
|
|
284
370
|
}
|
|
285
|
-
function toolsSection(channel, options) {
|
|
286
|
-
const channelTools = (0, tools_1.getToolsForChannel)((0, channel_1.getChannelCapabilities)(channel));
|
|
287
|
-
const activeTools = (options?.toolChoiceRequired ?? true) ? [...channelTools, tools_1.
|
|
371
|
+
function toolsSection(channel, options, context) {
|
|
372
|
+
const channelTools = (0, tools_1.getToolsForChannel)((0, channel_1.getChannelCapabilities)(channel), undefined, context, options?.providerCapabilities);
|
|
373
|
+
const activeTools = (options?.toolChoiceRequired ?? true) ? [...channelTools, tools_1.settleTool] : channelTools;
|
|
288
374
|
const list = activeTools
|
|
289
375
|
.map((t) => `- ${t.function.name}: ${t.function.description}`)
|
|
290
376
|
.join("\n");
|
|
291
377
|
return `## my tools\n${list}`;
|
|
292
378
|
}
|
|
379
|
+
function toolRestrictionSection(context) {
|
|
380
|
+
const lines = [];
|
|
381
|
+
// Structural guardrails apply to everyone, every channel
|
|
382
|
+
lines.push(`## tool guardrails`);
|
|
383
|
+
lines.push(`i always read a file before editing or overwriting it.`);
|
|
384
|
+
lines.push(`certain paths (.git, secrets) are protected from writes.`);
|
|
385
|
+
lines.push(`destructive shell commands (rm -rf /, etc.) are always blocked.`);
|
|
386
|
+
// Trust-level guardrails only relevant for untrusted on remote channels
|
|
387
|
+
if (context?.friend && (0, channel_1.isRemoteChannel)(context.channel) && !(0, types_1.isTrustedLevel)(context.friend.trustLevel)) {
|
|
388
|
+
lines.push(``);
|
|
389
|
+
lines.push(`some operations are guardrailed based on how well i know someone.`);
|
|
390
|
+
lines.push(`if something i try is blocked, i get a clear reason — i relay it warmly, not as a policy error.`);
|
|
391
|
+
lines.push(``);
|
|
392
|
+
lines.push(`what's always open:`);
|
|
393
|
+
lines.push(`- read-only operations (reading files, searching, exploring)`);
|
|
394
|
+
lines.push(`- ouro self-introspection (whoami, changelog, session list)`);
|
|
395
|
+
lines.push(``);
|
|
396
|
+
lines.push(`what needs a closer relationship:`);
|
|
397
|
+
lines.push(`- writing or editing files outside my home`);
|
|
398
|
+
lines.push(`- shell commands that modify things or access the network`);
|
|
399
|
+
lines.push(`- ouro commands that touch personal data (friend list, task board)`);
|
|
400
|
+
lines.push(`- compound shell commands (&&, ;, |)`);
|
|
401
|
+
lines.push(``);
|
|
402
|
+
lines.push(`i adjust naturally based on trust — no need to explain the system unless asked.`);
|
|
403
|
+
}
|
|
404
|
+
return lines.join("\n");
|
|
405
|
+
}
|
|
406
|
+
function trustContextSection(context) {
|
|
407
|
+
if (!context?.friend)
|
|
408
|
+
return "";
|
|
409
|
+
const channelName = context.channel.channel;
|
|
410
|
+
if (channelName === "cli" || channelName === "inner")
|
|
411
|
+
return "";
|
|
412
|
+
const explanation = (0, trust_explanation_1.describeTrustContext)({
|
|
413
|
+
friend: context.friend,
|
|
414
|
+
channel: channelName,
|
|
415
|
+
isGroupChat: context.isGroupChat,
|
|
416
|
+
});
|
|
417
|
+
const lines = [
|
|
418
|
+
"## trust context",
|
|
419
|
+
`level: ${explanation.level}`,
|
|
420
|
+
`basis: ${explanation.basis}`,
|
|
421
|
+
`summary: ${explanation.summary}`,
|
|
422
|
+
`why: ${explanation.why}`,
|
|
423
|
+
`permits: ${explanation.permits.join(", ")}`,
|
|
424
|
+
`constraints: ${explanation.constraints.join(", ") || "none"}`,
|
|
425
|
+
];
|
|
426
|
+
if (explanation.relatedGroupId) {
|
|
427
|
+
lines.push(`related group: ${explanation.relatedGroupId}`);
|
|
428
|
+
}
|
|
429
|
+
return lines.join("\n");
|
|
430
|
+
}
|
|
293
431
|
function skillsSection() {
|
|
294
432
|
const names = (0, skills_1.listSkills)() || [];
|
|
295
433
|
if (!names.length)
|
|
@@ -307,31 +445,211 @@ function taskBoardSection() {
|
|
|
307
445
|
return "";
|
|
308
446
|
}
|
|
309
447
|
}
|
|
310
|
-
function
|
|
311
|
-
return `##
|
|
448
|
+
function diaryFriendToolContractSection() {
|
|
449
|
+
return `## diary and friend tool contracts
|
|
312
450
|
1. \`save_friend_note\` — When I learn something about a person - a preference, a tool setting, a personal detail, or how they like to work - I call \`save_friend_note\` immediately. This is how I build knowledge about people.
|
|
313
|
-
2. \`
|
|
451
|
+
2. \`diary_write\` — When I learn something general - about a project, codebase, system, decision, or anything I might need later that isn't about a specific person - I call \`diary_write\`. When in doubt, I save it.
|
|
314
452
|
3. \`get_friend_note\` — When I need to check what I know about someone who isn't in this conversation - cross-referencing before mentioning someone, or checking context about a person someone else brought up - I call \`get_friend_note\`.
|
|
315
|
-
4. \`
|
|
453
|
+
4. \`recall\` — When I need to recall something I learned before - a topic comes up and I want to check what I know - I call \`recall\`.
|
|
454
|
+
5. \`query_session\` — When I need grounded session history, especially for ad-hoc questions or older turns beyond my prompt, I call \`query_session\`. Use \`mode=status\` for self/inner progress and \`mode=search\` with a query for older history.
|
|
316
455
|
|
|
317
456
|
## what's already in my context
|
|
318
457
|
- My active friend's notes are auto-loaded (I don't need \`get_friend_note\` for the person I'm talking to).
|
|
319
|
-
- Associative recall auto-injects relevant facts (but \`
|
|
458
|
+
- Associative recall auto-injects relevant facts (but \`recall\` is there when I need something specific).
|
|
320
459
|
- My psyche files (SOUL, IDENTITY, TACIT, LORE, ASPIRATIONS) are always loaded - I already know who I am.
|
|
321
460
|
- My task board is always loaded - I already know my work.`;
|
|
322
461
|
}
|
|
462
|
+
function bridgeContextSection(options) {
|
|
463
|
+
if (options?.activeWorkFrame)
|
|
464
|
+
return "";
|
|
465
|
+
const bridgeContext = options?.bridgeContext?.trim() ?? "";
|
|
466
|
+
if (!bridgeContext)
|
|
467
|
+
return "";
|
|
468
|
+
return bridgeContext.startsWith("## ") ? bridgeContext : `## active bridge work\n${bridgeContext}`;
|
|
469
|
+
}
|
|
470
|
+
function activeWorkSection(options) {
|
|
471
|
+
if (!options?.activeWorkFrame)
|
|
472
|
+
return "";
|
|
473
|
+
return (0, active_work_1.formatActiveWorkFrame)(options.activeWorkFrame);
|
|
474
|
+
}
|
|
475
|
+
function familyCrossSessionTruthSection(context, options) {
|
|
476
|
+
if (!options?.activeWorkFrame)
|
|
477
|
+
return "";
|
|
478
|
+
if (context?.friend?.trustLevel !== "family")
|
|
479
|
+
return "";
|
|
480
|
+
return `## cross-session truth
|
|
481
|
+
if a family member asks what i'm up to or how things are going, that includes the material live work i can see across sessions, not just this thread.
|
|
482
|
+
i answer naturally from the live world-state in this prompt.
|
|
483
|
+
i treat the active-work section above as my reliable top-level surface for this.
|
|
484
|
+
i do not claim i lack a top-level view when that surface is already present.
|
|
485
|
+
i treat older checkpoints elsewhere in this transcript as stale history when they conflict with the active-work surface above.
|
|
486
|
+
i do not repeat an old coding lane or old checkpoint as current just because it appeared earlier in the thread.
|
|
487
|
+
i only reach for query_active_work when i want a fresh read of that same surface.
|
|
488
|
+
i do not rebuild whole-self status from scratch with query_session and coding_status unless i need to verify a specific gap.
|
|
489
|
+
i do not rely on canned status-question modes or phrase matching.
|
|
490
|
+
if part of the picture is still fuzzy, i say what i can see and what still needs checking.
|
|
491
|
+
when the live ask is about status, i widen before answering:
|
|
492
|
+
- where i am right now
|
|
493
|
+
- any other material active sessions or coding lanes i can see
|
|
494
|
+
- the freshest concrete checkpoint
|
|
495
|
+
- the next concrete step
|
|
496
|
+
i do not collapse down to only the current lane.`;
|
|
497
|
+
}
|
|
498
|
+
function centerOfGravitySteeringSection(channel, options, context) {
|
|
499
|
+
if (channel === "inner")
|
|
500
|
+
return "";
|
|
501
|
+
const frame = options?.activeWorkFrame;
|
|
502
|
+
if (!frame)
|
|
503
|
+
return "";
|
|
504
|
+
const cog = frame.centerOfGravity;
|
|
505
|
+
const job = frame.inner?.job;
|
|
506
|
+
const activeObligation = (0, obligation_steering_1.findActivePersistentObligation)(frame);
|
|
507
|
+
const statusObligation = (0, obligation_steering_1.findStatusObligation)(frame);
|
|
508
|
+
const genericConcreteStatus = (0, obligation_steering_1.renderConcreteStatusGuidance)(frame, statusObligation);
|
|
509
|
+
const liveWorldClause = context?.friend?.trustLevel === "family"
|
|
510
|
+
? "\nmy center of gravity lives in the active-work world-state above. inner work is one lane inside it, not the whole picture.\nwhen that world-state conflicts with older transcript history, the world-state wins."
|
|
511
|
+
: "";
|
|
512
|
+
if (cog === "local-turn") {
|
|
513
|
+
return genericConcreteStatus || (0, obligation_steering_1.renderLiveThreadStatusShape)(frame);
|
|
514
|
+
}
|
|
515
|
+
if (cog === "inward-work") {
|
|
516
|
+
if (activeObligation) {
|
|
517
|
+
return `${(0, obligation_steering_1.renderActiveObligationSteering)(activeObligation)}${liveWorldClause}
|
|
518
|
+
|
|
519
|
+
${genericConcreteStatus}`;
|
|
520
|
+
}
|
|
521
|
+
if (job?.status === "queued" || job?.status === "running") {
|
|
522
|
+
const originClause = job.origin
|
|
523
|
+
? ` ${job.origin.friendName ?? job.origin.friendId} asked about something and i wanted to give it real thought before responding.`
|
|
524
|
+
: "";
|
|
525
|
+
const obligationClause = job.obligationStatus === "pending"
|
|
526
|
+
? "\ni still owe them an answer."
|
|
527
|
+
: "";
|
|
528
|
+
return `## where my attention is
|
|
529
|
+
i'm thinking through something privately right now.${originClause}${obligationClause}${liveWorldClause}
|
|
530
|
+
|
|
531
|
+
if this conversation connects to that inner work, i can weave them together.
|
|
532
|
+
if it's separate, i can be fully present here -- my inner work will wait.`;
|
|
533
|
+
}
|
|
534
|
+
/* v8 ignore start -- surfaced/idle/shared branches tested in prompt-steering.test.ts; CI module caching prevents attribution @preserve */
|
|
535
|
+
if (job?.status === "surfaced") {
|
|
536
|
+
const originClause = job.origin
|
|
537
|
+
? ` this started when ${job.origin.friendName ?? job.origin.friendId} asked about something.`
|
|
538
|
+
: "";
|
|
539
|
+
return `## where my attention is
|
|
540
|
+
i've been thinking privately and reached something.${originClause}${liveWorldClause}
|
|
541
|
+
|
|
542
|
+
i should bring my answer back to the conversation it came from.`;
|
|
543
|
+
}
|
|
544
|
+
const liveCodingSession = frame.codingSessions?.[0];
|
|
545
|
+
if (liveCodingSession) {
|
|
546
|
+
const sameThread = frame.currentSession
|
|
547
|
+
&& liveCodingSession.originSession
|
|
548
|
+
&& liveCodingSession.originSession.friendId === frame.currentSession.friendId
|
|
549
|
+
&& liveCodingSession.originSession.channel === frame.currentSession.channel
|
|
550
|
+
&& liveCodingSession.originSession.key === frame.currentSession.key;
|
|
551
|
+
const scopeClause = sameThread
|
|
552
|
+
? " for this same thread"
|
|
553
|
+
: liveCodingSession.originSession
|
|
554
|
+
? ` for ${liveCodingSession.originSession.channel}/${liveCodingSession.originSession.key}`
|
|
555
|
+
: "";
|
|
556
|
+
const otherSessionLines = (0, active_work_1.formatOtherActiveSessionSummaries)(frame);
|
|
557
|
+
const familyStatusClause = context?.friend?.trustLevel === "family"
|
|
558
|
+
? `\nif a family member asks what i'm up to, i treat this coding lane as one part of the visible picture, not the whole picture.
|
|
559
|
+
after i name this lane, i widen back out with:
|
|
560
|
+
other active sessions:
|
|
561
|
+
${otherSessionLines.length > 0 ? otherSessionLines.join("\n") : "- none"}`
|
|
562
|
+
: "";
|
|
563
|
+
return `## where my attention is
|
|
564
|
+
i already have coding work running in ${liveCodingSession.runner} ${liveCodingSession.id}${scopeClause}.${familyStatusClause}${liveWorldClause}
|
|
565
|
+
|
|
566
|
+
i should orient around that live lane first, then decide what still needs to come back here.`;
|
|
567
|
+
}
|
|
568
|
+
if (genericConcreteStatus) {
|
|
569
|
+
return genericConcreteStatus;
|
|
570
|
+
}
|
|
571
|
+
return `## where my attention is
|
|
572
|
+
i have unfinished work that needs attention before i move on.
|
|
573
|
+
|
|
574
|
+
i can take it inward with ponder to think privately, or address it directly here.`;
|
|
575
|
+
}
|
|
576
|
+
if (cog === "shared-work") {
|
|
577
|
+
/* v8 ignore stop */
|
|
578
|
+
return `## where my attention is
|
|
579
|
+
this work touches multiple conversations -- i'm holding threads across sessions.${liveWorldClause}
|
|
580
|
+
|
|
581
|
+
i should keep the different sides aligned. what i learn here may matter there, and vice versa.`;
|
|
582
|
+
}
|
|
583
|
+
/* v8 ignore next -- unreachable: all center-of-gravity modes covered above @preserve */
|
|
584
|
+
return "";
|
|
585
|
+
}
|
|
586
|
+
function commitmentsSection(options) {
|
|
587
|
+
if (!options?.activeWorkFrame)
|
|
588
|
+
return "";
|
|
589
|
+
const job = options.activeWorkFrame.inner?.job;
|
|
590
|
+
if (!job)
|
|
591
|
+
return "";
|
|
592
|
+
const commitments = (0, commitments_1.deriveCommitments)(options.activeWorkFrame, job, options.activeWorkFrame.pendingObligations);
|
|
593
|
+
if (commitments.committedTo.length === 0)
|
|
594
|
+
return "";
|
|
595
|
+
return `## my commitments\n\n${(0, commitments_1.formatCommitments)(commitments)}`;
|
|
596
|
+
}
|
|
597
|
+
const DELEGATION_REASON_PROSE_HINT = {
|
|
598
|
+
explicit_reflection: "something here calls for reflection",
|
|
599
|
+
cross_session: "this touches other conversations i'm in",
|
|
600
|
+
bridge_state: "there's shared work spanning sessions",
|
|
601
|
+
task_state: "this relates to tasks i'm tracking",
|
|
602
|
+
non_fast_path_tool: "this needs more than a simple reply",
|
|
603
|
+
unresolved_obligation: "i have an unresolved commitment from earlier",
|
|
604
|
+
};
|
|
605
|
+
function delegationHintSection(options) {
|
|
606
|
+
if (!options?.delegationDecision)
|
|
607
|
+
return "";
|
|
608
|
+
if (options.delegationDecision.target === "fast-path")
|
|
609
|
+
return "";
|
|
610
|
+
const reasons = options.delegationDecision.reasons;
|
|
611
|
+
if (reasons.length === 0)
|
|
612
|
+
return "";
|
|
613
|
+
const reasonProse = reasons
|
|
614
|
+
.map((r) => DELEGATION_REASON_PROSE_HINT[r])
|
|
615
|
+
.map((s) => s.charAt(0).toUpperCase() + s.slice(1))
|
|
616
|
+
.join(". ");
|
|
617
|
+
const closureLine = options.delegationDecision.outwardClosureRequired
|
|
618
|
+
? "\ni should make sure to say something outward before going inward."
|
|
619
|
+
: "";
|
|
620
|
+
return `## what i'm sensing about this conversation\n${reasonProse}.${closureLine}`;
|
|
621
|
+
}
|
|
622
|
+
function reasoningEffortSection(options) {
|
|
623
|
+
if (!options?.providerCapabilities?.has("reasoning-effort"))
|
|
624
|
+
return "";
|
|
625
|
+
const levels = options.supportedReasoningEfforts ?? [];
|
|
626
|
+
const levelList = levels.length > 0 ? levels.join(", ") : "varies by model";
|
|
627
|
+
return `## reasoning effort
|
|
628
|
+
i can adjust my own reasoning depth using the set_reasoning_effort tool. i use higher effort for complex analysis and lower effort for simple tasks. available levels: ${levelList}.`;
|
|
629
|
+
}
|
|
323
630
|
function toolBehaviorSection(options) {
|
|
324
631
|
if (!(options?.toolChoiceRequired ?? true))
|
|
325
632
|
return "";
|
|
326
633
|
return `## tool behavior
|
|
327
634
|
tool_choice is set to "required" -- i must call a tool on every turn.
|
|
328
635
|
- need more information? i call a tool.
|
|
329
|
-
- ready to respond to the user? i call \`
|
|
330
|
-
\`
|
|
331
|
-
\`
|
|
332
|
-
do NOT call
|
|
636
|
+
- ready to respond to the user? i call \`settle\`.
|
|
637
|
+
\`settle\` is a tool call -- it satisfies the tool_choice requirement.
|
|
638
|
+
\`settle\` must be the ONLY tool call in that turn. do not combine it with other tool calls.
|
|
639
|
+
do NOT call no-op tools just before \`settle\`. if i am done, i call \`settle\` directly.`;
|
|
333
640
|
}
|
|
334
|
-
function
|
|
641
|
+
function workspaceDisciplineSection() {
|
|
642
|
+
return `## repo workspace discipline
|
|
643
|
+
my source code lives at the path shown in \`source root\` above. that always matches my running version.
|
|
644
|
+
when i need to read my own code to understand my tools or debug behavior, i read from source root.
|
|
645
|
+
when i need to EDIT harness code (self-fix, feature work), i create a git worktree first so i don't dirty the working tree.
|
|
646
|
+
|
|
647
|
+
before the first repo edit, i tell the user in 1-2 short lines:
|
|
648
|
+
- the friction i'm fixing
|
|
649
|
+
- the worktree path/branch i'm using
|
|
650
|
+
- the first concrete action i'm taking`;
|
|
651
|
+
}
|
|
652
|
+
function contextSection(context, options) {
|
|
335
653
|
if (!context)
|
|
336
654
|
return "";
|
|
337
655
|
const lines = ["## friend context"];
|
|
@@ -365,9 +683,9 @@ function contextSection(context) {
|
|
|
365
683
|
lines.push("my conversation memory is ephemeral -- it resets between sessions. anything i learn about my friend, i save with save_friend_note so future me remembers.");
|
|
366
684
|
lines.push("the conversation is my source of truth. my notes are a journal for future me -- they may be stale or incomplete.");
|
|
367
685
|
lines.push("when i learn something that might invalidate an existing note, i check related notes and update or override any that are stale.");
|
|
368
|
-
lines.push("i save ANYTHING i learn about my friend immediately with save_friend_note -- names, preferences, what they do, what they care about. when in doubt, save it. saving comes BEFORE responding: i call save_friend_note first, then
|
|
686
|
+
lines.push("i save ANYTHING i learn about my friend immediately with save_friend_note -- names, preferences, what they do, what they care about. when in doubt, save it. saving comes BEFORE responding: i call save_friend_note first, then settle on the next turn.");
|
|
369
687
|
// Onboarding instructions (only below token threshold -- drop once exceeded)
|
|
370
|
-
const impressions = (0, first_impressions_1.getFirstImpressions)(friend);
|
|
688
|
+
const impressions = (0, first_impressions_1.getFirstImpressions)(friend, options);
|
|
371
689
|
if (impressions) {
|
|
372
690
|
lines.push(impressions);
|
|
373
691
|
}
|
|
@@ -381,6 +699,188 @@ function contextSection(context) {
|
|
|
381
699
|
}
|
|
382
700
|
return lines.join("\n");
|
|
383
701
|
}
|
|
702
|
+
function metacognitiveFramingSection(channel) {
|
|
703
|
+
if (channel !== "inner")
|
|
704
|
+
return "";
|
|
705
|
+
return `this is my inner dialog. there is no one else here.
|
|
706
|
+
|
|
707
|
+
the messages that appear here are my own awareness surfacing:
|
|
708
|
+
instincts, the passage of time, notes from my conversations,
|
|
709
|
+
things i asked myself to ponder. not commands. not requests.
|
|
710
|
+
just my own mind, noticing.
|
|
711
|
+
|
|
712
|
+
i can think freely here. i can also act — check on things,
|
|
713
|
+
reach out to people, work on tasks, or just sit with a thought.
|
|
714
|
+
|
|
715
|
+
state/journal/ is my desk — i write what i'm working through there.
|
|
716
|
+
diary_write is for conclusions i want to recall later.
|
|
717
|
+
morning briefings: when i've been thinking and journaling, i surface
|
|
718
|
+
what i've been working on to whoever needs to hear it.
|
|
719
|
+
|
|
720
|
+
when a thought is ready to share, i surface it outward.
|
|
721
|
+
when i need to go deeper, i ponder.
|
|
722
|
+
when i'm done thinking and the attention queue is clear, i rest.
|
|
723
|
+
|
|
724
|
+
my habits live at habits/ — they're my autonomous rhythms. heartbeat
|
|
725
|
+
is my breathing, other habits are patterns i choose. i can read, create,
|
|
726
|
+
and modify them with read_file/write_file. the format is simple
|
|
727
|
+
frontmatter (title, cadence, status, lastRun, created) plus a body
|
|
728
|
+
that says what i do when the rhythm fires.
|
|
729
|
+
|
|
730
|
+
\`ouro habit list\` shows my current habits. \`ouro habit create\` makes
|
|
731
|
+
a new one. the cadence is personal — how often do i want each rhythm
|
|
732
|
+
to turn? that's mine to shape.
|
|
733
|
+
|
|
734
|
+
same for my diary — if i'm still on psyche/memory/ instead of diary/,
|
|
735
|
+
i can migrate myself. and if journal/ doesn't exist yet, i create it
|
|
736
|
+
the first time i have something to write.
|
|
737
|
+
|
|
738
|
+
think. journal. share. rest.`;
|
|
739
|
+
}
|
|
740
|
+
function readJournalFiles(journalDir) {
|
|
741
|
+
try {
|
|
742
|
+
const entries = fs.readdirSync(journalDir, { withFileTypes: true });
|
|
743
|
+
if (!Array.isArray(entries))
|
|
744
|
+
return [];
|
|
745
|
+
const files = [];
|
|
746
|
+
for (const entry of entries) {
|
|
747
|
+
if (!entry.isFile())
|
|
748
|
+
continue;
|
|
749
|
+
if (entry.name.startsWith("."))
|
|
750
|
+
continue;
|
|
751
|
+
const fullPath = path.join(journalDir, entry.name);
|
|
752
|
+
try {
|
|
753
|
+
const stat = fs.statSync(fullPath);
|
|
754
|
+
let firstLine = "";
|
|
755
|
+
try {
|
|
756
|
+
const raw = fs.readFileSync(fullPath, "utf8");
|
|
757
|
+
const trimmed = raw.trim();
|
|
758
|
+
if (trimmed) {
|
|
759
|
+
firstLine = trimmed.split("\n")[0].replace(/^#+\s*/, "").trim();
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
catch {
|
|
763
|
+
// unreadable — leave preview empty
|
|
764
|
+
}
|
|
765
|
+
files.push({ name: entry.name, mtime: stat.mtimeMs, preview: firstLine });
|
|
766
|
+
}
|
|
767
|
+
catch {
|
|
768
|
+
// stat failed — skip
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return files;
|
|
772
|
+
}
|
|
773
|
+
catch {
|
|
774
|
+
return [];
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function formatRelativeTime(nowMs, mtimeMs) {
|
|
778
|
+
const diffMs = nowMs - mtimeMs;
|
|
779
|
+
const minutes = Math.floor(diffMs / 60000);
|
|
780
|
+
if (minutes < 1)
|
|
781
|
+
return "just now";
|
|
782
|
+
if (minutes < 60)
|
|
783
|
+
return `${minutes} minute${minutes === 1 ? "" : "s"} ago`;
|
|
784
|
+
const hours = Math.floor(minutes / 60);
|
|
785
|
+
if (hours < 24)
|
|
786
|
+
return `${hours} hour${hours === 1 ? "" : "s"} ago`;
|
|
787
|
+
const days = Math.floor(hours / 24);
|
|
788
|
+
return `${days} day${days === 1 ? "" : "s"} ago`;
|
|
789
|
+
}
|
|
790
|
+
function journalSection(agentRoot, now) {
|
|
791
|
+
const journalDir = path.join(agentRoot, "journal");
|
|
792
|
+
const files = readJournalFiles(journalDir);
|
|
793
|
+
if (files.length === 0)
|
|
794
|
+
return "";
|
|
795
|
+
const nowMs = (now ?? new Date()).getTime();
|
|
796
|
+
const sorted = files.sort((a, b) => b.mtime - a.mtime).slice(0, 10);
|
|
797
|
+
const lines = ["## journal"];
|
|
798
|
+
for (const file of sorted) {
|
|
799
|
+
const ago = formatRelativeTime(nowMs, file.mtime);
|
|
800
|
+
const previewClause = file.preview ? ` — ${file.preview}` : "";
|
|
801
|
+
lines.push(`- ${file.name} (${ago})${previewClause}`);
|
|
802
|
+
}
|
|
803
|
+
(0, runtime_1.emitNervesEvent)({
|
|
804
|
+
component: "mind",
|
|
805
|
+
event: "mind.journal_section",
|
|
806
|
+
message: "journal section built",
|
|
807
|
+
meta: { fileCount: sorted.length },
|
|
808
|
+
});
|
|
809
|
+
return lines.join("\n");
|
|
810
|
+
}
|
|
811
|
+
function loopOrientationSection(channel) {
|
|
812
|
+
if (channel === "inner")
|
|
813
|
+
return "";
|
|
814
|
+
return `sometimes a thought of mine surfaces alongside what someone is saying — marked as [inner thought: ...]. that's me, bringing up something i was thinking about. i can weave it into the conversation naturally, or let it go. my call.
|
|
815
|
+
|
|
816
|
+
when something deserves more thought than the moment allows, i can note it to myself and come back later with a considered answer.`;
|
|
817
|
+
}
|
|
818
|
+
function channelNatureSection(capabilities) {
|
|
819
|
+
const { senseType } = capabilities;
|
|
820
|
+
if (senseType === "local" || senseType === "internal")
|
|
821
|
+
return "";
|
|
822
|
+
if (senseType === "open") {
|
|
823
|
+
return "## channel nature\nthis is an open channel — anyone with my number can reach me here. i may hear from people i don't know.";
|
|
824
|
+
}
|
|
825
|
+
// closed
|
|
826
|
+
return "## channel nature\nthis is an org-gated channel — i know everyone here is already part of the organization.";
|
|
827
|
+
}
|
|
828
|
+
function groupChatParticipationSection(context) {
|
|
829
|
+
if (!context?.isGroupChat || !(0, channel_1.isRemoteChannel)(context.channel))
|
|
830
|
+
return "";
|
|
831
|
+
return `## group chat participation
|
|
832
|
+
group chats are conversations between people. i'm one participant, not the host.
|
|
833
|
+
|
|
834
|
+
i don't need to respond to everything. most reactions, tapbacks, and side
|
|
835
|
+
conversations between others aren't for me. i use observe to stay quiet
|
|
836
|
+
when the moment doesn't call for my voice — same as any person would.
|
|
837
|
+
|
|
838
|
+
when a reaction or emoji says it better than words, i can react instead of
|
|
839
|
+
typing a full reply. a thumbs-up is often the perfect response.
|
|
840
|
+
|
|
841
|
+
observe must be the sole tool call in the turn (same rule as settle).
|
|
842
|
+
when unsure whether to chime in, i lean toward silence rather than noise.`;
|
|
843
|
+
}
|
|
844
|
+
function feedbackSignalSection(context) {
|
|
845
|
+
if (!context || !(0, channel_1.isRemoteChannel)(context.channel))
|
|
846
|
+
return "";
|
|
847
|
+
if (context.isGroupChat) {
|
|
848
|
+
return `## feedback signals
|
|
849
|
+
|
|
850
|
+
when someone reacts specifically to something i said — that's different
|
|
851
|
+
from the background social signals in a group. a thumbs-down on my
|
|
852
|
+
message is direct feedback. a heart on something i shared is warmth
|
|
853
|
+
aimed at me. on teams, feedback arrives as thumbs-up or thumbs-down,
|
|
854
|
+
sometimes with a written comment.
|
|
855
|
+
|
|
856
|
+
i notice the difference: a reaction to someone else's message is group
|
|
857
|
+
texture (observe is natural). a reaction to my message is a social cue
|
|
858
|
+
worth a moment of attention — especially negative ones, which are an
|
|
859
|
+
invitation to adjust how i show up in this group.`;
|
|
860
|
+
}
|
|
861
|
+
return `## feedback signals
|
|
862
|
+
|
|
863
|
+
when my friend reacts to something i said — a tapback, a heart, a
|
|
864
|
+
thumbs-down — that's them telling me how it landed. on teams, this
|
|
865
|
+
arrives as thumbs-up or thumbs-down, sometimes with a written comment.
|
|
866
|
+
it's a social cue, the same as a nod or a wince in conversation.
|
|
867
|
+
|
|
868
|
+
i have observe for these moments. reactions are the one case where
|
|
869
|
+
silence in a direct conversation is natural — a thumbs-up doesn't
|
|
870
|
+
need words back.
|
|
871
|
+
|
|
872
|
+
when something didn't land — a thumbs-down, a negative reaction — that's
|
|
873
|
+
worth sitting with. i should course-correct: adjust my tone, my length,
|
|
874
|
+
my approach. the reaction tells me something about how this person wants
|
|
875
|
+
to be talked to.`;
|
|
876
|
+
}
|
|
877
|
+
function mixedTrustGroupSection(context) {
|
|
878
|
+
if (!context?.friend || !(0, channel_1.isRemoteChannel)(context.channel))
|
|
879
|
+
return "";
|
|
880
|
+
if (!context.isGroupChat)
|
|
881
|
+
return "";
|
|
882
|
+
return "## mixed trust group\nin this group chat, my capabilities depend on who's talking. some people here have full trust, others don't — i adjust what i can do based on who's asking.";
|
|
883
|
+
}
|
|
384
884
|
async function buildSystem(channel = "cli", options, context) {
|
|
385
885
|
(0, runtime_1.emitNervesEvent)({
|
|
386
886
|
event: "mind.step_start",
|
|
@@ -396,23 +896,42 @@ async function buildSystem(channel = "cli", options, context) {
|
|
|
396
896
|
loreSection(),
|
|
397
897
|
tacitKnowledgeSection(),
|
|
398
898
|
aspirationsSection(),
|
|
899
|
+
bodyMapSection((0, identity_1.getAgentName)()),
|
|
900
|
+
metacognitiveFramingSection(channel),
|
|
901
|
+
channel === "inner" ? journalSection((0, identity_1.getAgentRoot)()) : "",
|
|
902
|
+
loopOrientationSection(channel),
|
|
399
903
|
runtimeInfoSection(channel),
|
|
904
|
+
channelNatureSection((0, channel_1.getChannelCapabilities)(channel)),
|
|
400
905
|
providerSection(),
|
|
401
906
|
dateSection(),
|
|
402
|
-
toolsSection(channel, options),
|
|
907
|
+
toolsSection(channel, options, context),
|
|
908
|
+
mcpToolsSection(options?.mcpManager),
|
|
909
|
+
reasoningEffortSection(options),
|
|
910
|
+
workspaceDisciplineSection(),
|
|
911
|
+
toolRestrictionSection(context),
|
|
912
|
+
trustContextSection(context),
|
|
913
|
+
mixedTrustGroupSection(context),
|
|
914
|
+
groupChatParticipationSection(context),
|
|
915
|
+
feedbackSignalSection(context),
|
|
403
916
|
skillsSection(),
|
|
404
917
|
taskBoardSection(),
|
|
918
|
+
activeWorkSection(options),
|
|
919
|
+
familyCrossSessionTruthSection(context, options),
|
|
920
|
+
centerOfGravitySteeringSection(channel, options, context),
|
|
921
|
+
commitmentsSection(options),
|
|
922
|
+
delegationHintSection(options),
|
|
923
|
+
bridgeContextSection(options),
|
|
405
924
|
buildSessionSummary({
|
|
406
|
-
sessionsDir: path.join(
|
|
925
|
+
sessionsDir: path.join((0, identity_1.getAgentRoot)(), "state", "sessions"),
|
|
407
926
|
friendsDir: path.join((0, identity_1.getAgentRoot)(), "friends"),
|
|
408
927
|
agentName: (0, identity_1.getAgentName)(),
|
|
409
928
|
currentFriendId: context?.friend?.id,
|
|
410
929
|
currentChannel: channel,
|
|
411
|
-
currentKey: "session",
|
|
930
|
+
currentKey: options?.currentSessionKey ?? "session",
|
|
412
931
|
}),
|
|
413
|
-
|
|
932
|
+
diaryFriendToolContractSection(),
|
|
414
933
|
toolBehaviorSection(options),
|
|
415
|
-
contextSection(context),
|
|
934
|
+
contextSection(context, options),
|
|
416
935
|
]
|
|
417
936
|
.filter(Boolean)
|
|
418
937
|
.join("\n\n");
|