@ouro.bot/cli 0.1.0-alpha.1111 → 0.1.0-alpha.1113
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/changelog.json +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/daemon/portable-git.js +37 -2
- package/dist/senses/app-sessions/issue-drain-state.js +3 -1
- package/dist/senses/app-sessions/issue-drains.js +43 -13
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/changelog.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
|
|
3
3
|
"versions": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.1.0-alpha.1113",
|
|
6
|
+
"changes": [
|
|
7
|
+
"Issue drains are woken only by changes someone other than the drain made: the drain's own status comment (by marker and revision) and its own `drain:` label changes no longer count as activity, so a drain stops waking on issues that did not change. A new comment, a body or title edit, a reopen or another label still wakes it once; a closed issue the drain handled never wakes it, and its waiting event is dropped."
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"version": "0.1.0-alpha.1112",
|
|
12
|
+
"changes": [
|
|
13
|
+
"Bundle sync can fetch and push again on a Mac whose git (the Copilot app's bundled git) cannot find its https helper: the daemon points git at the helper beside it instead of failing every sync with \"'remote-https' is not a git command\"."
|
|
14
|
+
]
|
|
15
|
+
},
|
|
4
16
|
{
|
|
5
17
|
"version": "0.1.0-alpha.1111",
|
|
6
18
|
"changes": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0"?>
|
|
2
2
|
<Container version="2">
|
|
3
3
|
<Name>ouro-butler</Name>
|
|
4
|
-
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.
|
|
4
|
+
<Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1113</Repository>
|
|
5
5
|
<Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
|
|
6
6
|
<Network>host</Network>
|
|
7
7
|
<Shell>sh</Shell>
|
|
@@ -41,10 +41,12 @@ exports.portableGitRoot = portableGitRoot;
|
|
|
41
41
|
exports.portableGitBinary = portableGitBinary;
|
|
42
42
|
exports.findGitOnPath = findGitOnPath;
|
|
43
43
|
exports.portableGitEnv = portableGitEnv;
|
|
44
|
+
exports.pinGitHelperPath = pinGitHelperPath;
|
|
44
45
|
exports.activatePortableGit = activatePortableGit;
|
|
45
46
|
const fs = __importStar(require("fs"));
|
|
46
47
|
const os = __importStar(require("os"));
|
|
47
48
|
const path = __importStar(require("path"));
|
|
49
|
+
const child_process_1 = require("child_process");
|
|
48
50
|
const runtime_1 = require("../../nerves/runtime");
|
|
49
51
|
/**
|
|
50
52
|
* A portable git for hosts that have none (a BusyBox appliance has no package
|
|
@@ -111,6 +113,33 @@ function portableGitEnv(root, exists = fs.existsSync) {
|
|
|
111
113
|
env.GIT_SSL_CAINFO = caBundle;
|
|
112
114
|
return env;
|
|
113
115
|
}
|
|
116
|
+
const HTTPS_HELPER = "git-remote-https";
|
|
117
|
+
function defaultGitExecPath(gitBinary, env) {
|
|
118
|
+
const childEnv = { ...env };
|
|
119
|
+
delete childEnv.GIT_EXEC_PATH;
|
|
120
|
+
const run = (0, child_process_1.spawnSync)(gitBinary, ["--exec-path"], { env: childEnv, encoding: "utf8" });
|
|
121
|
+
return run.status === 0 ? run.stdout.trim() : null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Point GIT_EXEC_PATH at the libexec beside `gitBinary` when git cannot find
|
|
125
|
+
* its https helper where it looks. The Copilot app's bundled git on a Mac is
|
|
126
|
+
* relocated: its own exec path is `//libexec/git-core`, so a process started
|
|
127
|
+
* without the app's GIT_EXEC_PATH (the Ouro daemon) fails every fetch and push
|
|
128
|
+
* with "'remote-https' is not a git command". Returns true when it set the path.
|
|
129
|
+
*/
|
|
130
|
+
function pinGitHelperPath(gitBinary, env, deps = {}) {
|
|
131
|
+
if (env.GIT_EXEC_PATH !== undefined)
|
|
132
|
+
return false;
|
|
133
|
+
const exists = deps.exists ?? fs.existsSync;
|
|
134
|
+
const libexec = path.join(path.dirname(path.dirname(gitBinary)), "libexec", "git-core");
|
|
135
|
+
if (!exists(path.join(libexec, HTTPS_HELPER)))
|
|
136
|
+
return false;
|
|
137
|
+
const ownExecPath = (deps.execPath ?? defaultGitExecPath)(gitBinary, env);
|
|
138
|
+
if (ownExecPath && exists(path.join(ownExecPath, HTTPS_HELPER)))
|
|
139
|
+
return false;
|
|
140
|
+
env.GIT_EXEC_PATH = libexec;
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
114
143
|
/**
|
|
115
144
|
* Put the portable git's bin directory first on PATH when it is installed and
|
|
116
145
|
* the host has no git, so every `git` this process or its children run (bundle
|
|
@@ -121,14 +150,20 @@ function activatePortableGit(options = {}) {
|
|
|
121
150
|
const env = options.env ?? process.env;
|
|
122
151
|
const isExecutable = options.isExecutable ?? isExecutableFile;
|
|
123
152
|
const binary = portableGitBinary(options.homeDir);
|
|
124
|
-
if (!isExecutable(binary))
|
|
153
|
+
if (!isExecutable(binary)) {
|
|
154
|
+
const hostGit = findGitOnPath(env.PATH, isExecutable);
|
|
155
|
+
if (hostGit)
|
|
156
|
+
pinGitHelperPath(hostGit, env);
|
|
125
157
|
return { status: "absent" };
|
|
158
|
+
}
|
|
126
159
|
const binDir = path.dirname(binary);
|
|
127
160
|
const systemGit = findGitOnPath(env.PATH, isExecutable);
|
|
128
161
|
if (systemGit === binary)
|
|
129
162
|
return { status: "activated", binDir };
|
|
130
|
-
if (systemGit)
|
|
163
|
+
if (systemGit) {
|
|
164
|
+
pinGitHelperPath(systemGit, env);
|
|
131
165
|
return { status: "system", git: systemGit };
|
|
166
|
+
}
|
|
132
167
|
env.PATH = env.PATH ? `${binDir}${path.delimiter}${env.PATH}` : binDir;
|
|
133
168
|
for (const [key, value] of Object.entries(portableGitEnv(path.dirname(binDir)))) {
|
|
134
169
|
if (env[key] === undefined)
|
|
@@ -33,11 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.drainStateFile = void 0;
|
|
36
|
+
exports.drainStateFile = exports.seenIssue = void 0;
|
|
37
37
|
exports.readDrainStates = readDrainStates;
|
|
38
38
|
exports.drainStatusLines = drainStatusLines;
|
|
39
39
|
const path = __importStar(require("node:path"));
|
|
40
40
|
const store_1 = require("./store");
|
|
41
|
+
const seenIssue = (entry) => typeof entry === "string" ? { updatedAt: entry } : entry;
|
|
42
|
+
exports.seenIssue = seenIssue;
|
|
41
43
|
const drainStateFile = (agentRoot) => path.join((0, store_1.appSessionsStateDir)(agentRoot), "issue-drains.json");
|
|
42
44
|
exports.drainStateFile = drainStateFile;
|
|
43
45
|
function readDrainStates(agentRoot) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendWake = exports.connectGithub = exports.DRAIN_STATUS_MARKER = exports.ISSUE_POLL_MS = void 0;
|
|
3
|
+
exports.sendWake = exports.connectGithub = exports.DRAIN_LABEL_PREFIX = exports.DRAIN_STATUS_MARKER = exports.ISSUE_POLL_MS = void 0;
|
|
4
4
|
exports.wakeMessage = wakeMessage;
|
|
5
5
|
exports.pollDrain = pollDrain;
|
|
6
6
|
exports.pollIssueDrains = pollIssueDrains;
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
8
|
const node_child_process_1 = require("node:child_process");
|
|
8
9
|
const account_pool_1 = require("../../heart/providers/account-pool");
|
|
9
10
|
const runtime_1 = require("../../nerves/runtime");
|
|
@@ -15,10 +16,17 @@ const store_1 = require("./store");
|
|
|
15
16
|
* lists each repository's open issues and messages the drain's session when one is new or changed since the last
|
|
16
17
|
* poll. Events are written to disk before anyone is woken, so a crash or a refused message loses nothing; an
|
|
17
18
|
* authentication or network failure is recorded for `ouro status` and leaves every marker where it was.
|
|
19
|
+
*
|
|
20
|
+
* `updated_at` alone is not a revision: the drain's own label edits and status comment move it too. An issue wakes the
|
|
21
|
+
* drain only when something other than the drain changed it since the revision last recorded for that issue.
|
|
18
22
|
*/
|
|
19
23
|
exports.ISSUE_POLL_MS = 5 * 60_000;
|
|
20
24
|
/** A drain's own status comment carries this marker, so its creation and edits do not wake the drain again. */
|
|
21
25
|
exports.DRAIN_STATUS_MARKER = "<!-- ouro-drain-status -->";
|
|
26
|
+
/** The drain moves an issue through labels in this namespace (`drain: triaged`, `drain: in progress`); changing them is not news. */
|
|
27
|
+
exports.DRAIN_LABEL_PREFIX = "drain:";
|
|
28
|
+
/** A closed issue's record is kept this long, so one that comes back unchanged is not mistaken for a new issue. */
|
|
29
|
+
const GONE_MS = 30 * 24 * 3_600_000;
|
|
22
30
|
const MAX_TITLES = 20;
|
|
23
31
|
const PAGE = 100;
|
|
24
32
|
const blank = () => ({ seeded: false, seen: {}, pending: [] });
|
|
@@ -31,10 +39,23 @@ function wakeMessage(repo, events) {
|
|
|
31
39
|
const more = events.length > MAX_TITLES ? `, and ${events.length - MAX_TITLES} more` : "";
|
|
32
40
|
return `New or changed issues in ${repo}: ${shown.join(", ")}${more}. Drain them.`;
|
|
33
41
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
const digestOf = (issue) => (0, node_crypto_1.createHash)("sha1").update(`${issue.title}\n${issue.body ?? ""}`).digest("hex").slice(0, 16);
|
|
43
|
+
/** The drain's own status comment: the marker, written by the polling account. Its creation and every edit are skipped. */
|
|
44
|
+
const ownStatus = (comment, login) => comment.user?.login?.toLowerCase() === login.toLowerCase() && !!comment.body?.includes(exports.DRAIN_STATUS_MARKER);
|
|
45
|
+
/** A reopen, or a label change outside the drain's own namespace. Closes, assignments, mentions and the drain's labels are not news. */
|
|
46
|
+
const newsEvent = (event) => event.event === "reopened" || ((event.event === "labeled" || event.event === "unlabeled") && !event.label?.name?.startsWith(exports.DRAIN_LABEL_PREFIX));
|
|
47
|
+
/** Whether anyone but the drain changed the issue since `before`: a new issue, an edit, another comment, a reopen or a label outside the drain's own. */
|
|
48
|
+
async function changedByOthers(api, repo, issue, before, digest) {
|
|
49
|
+
if (!before)
|
|
50
|
+
return true;
|
|
51
|
+
if (before.digest && before.digest !== digest)
|
|
52
|
+
return true;
|
|
53
|
+
const since = before.updatedAt;
|
|
54
|
+
const comments = (await api.comments(repo, issue.number, since)).filter(comment => comment.updated_at > since);
|
|
55
|
+
if (comments.some(comment => !ownStatus(comment, api.login)))
|
|
56
|
+
return true;
|
|
57
|
+
const events = (await api.issueEvents(repo, issue.number)).filter(event => event.created_at > since);
|
|
58
|
+
return events.some(newsEvent);
|
|
38
59
|
}
|
|
39
60
|
/** Poll one drain's repository, record what changed, then wake its session once with the whole batch. */
|
|
40
61
|
async function pollDrain(drain, states, save, deps) {
|
|
@@ -47,16 +68,23 @@ async function pollDrain(drain, states, save, deps) {
|
|
|
47
68
|
const recorded = [];
|
|
48
69
|
for (const issue of issues) {
|
|
49
70
|
const key = String(issue.number);
|
|
50
|
-
const before = state.seen[key];
|
|
51
|
-
|
|
52
|
-
|
|
71
|
+
const before = (0, issue_drain_state_1.seenIssue)(state.seen[key]);
|
|
72
|
+
const digest = digestOf(issue);
|
|
73
|
+
seen[key] = { updatedAt: issue.updated_at, digest };
|
|
74
|
+
if (!state.seeded || before?.updatedAt === issue.updated_at)
|
|
53
75
|
continue;
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
76
|
+
if (await changedByOthers(api, drain.repo, issue, before, digest))
|
|
77
|
+
recorded.push({ number: issue.number, title: issue.title, updatedAt: issue.updated_at });
|
|
78
|
+
}
|
|
79
|
+
for (const [key, entry] of Object.entries(state.seen)) {
|
|
80
|
+
const gone = (0, issue_drain_state_1.seenIssue)(entry);
|
|
81
|
+
const goneAt = gone.goneAt ?? deps.now;
|
|
82
|
+
if (!(key in seen) && deps.now - goneAt < GONE_MS)
|
|
83
|
+
seen[key] = { ...gone, goneAt };
|
|
57
84
|
}
|
|
85
|
+
const open = new Set(issues.map(issue => issue.number));
|
|
58
86
|
const numbers = new Set(recorded.map(event => event.number));
|
|
59
|
-
state.pending = [...state.pending.filter(event => !numbers.has(event.number)), ...recorded];
|
|
87
|
+
state.pending = [...state.pending.filter(event => open.has(event.number) && !numbers.has(event.number)), ...recorded];
|
|
60
88
|
state.seen = seen;
|
|
61
89
|
state.seeded = true;
|
|
62
90
|
state.openCount = issues.length;
|
|
@@ -112,8 +140,9 @@ const connectGithub = async (account) => {
|
|
|
112
140
|
};
|
|
113
141
|
const all = async (route) => {
|
|
114
142
|
const items = [];
|
|
143
|
+
const join = route.includes("?") ? "&" : "?";
|
|
115
144
|
for (let page = 1;; page++) {
|
|
116
|
-
const { body, next } = await get(`${route}
|
|
145
|
+
const { body, next } = await get(`${route}${join}per_page=${PAGE}&page=${page}`);
|
|
117
146
|
items.push(...body);
|
|
118
147
|
if (!next)
|
|
119
148
|
return items;
|
|
@@ -124,6 +153,7 @@ const connectGithub = async (account) => {
|
|
|
124
153
|
login,
|
|
125
154
|
openIssues: async (repo) => (await all(`/repos/${repo}/issues?state=open&sort=updated&direction=desc`)).filter(issue => !issue.pull_request),
|
|
126
155
|
comments: (repo, issue, since) => all(`/repos/${repo}/issues/${issue}/comments?since=${encodeURIComponent(since)}`),
|
|
156
|
+
issueEvents: (repo, issue) => all(`/repos/${repo}/issues/${issue}/events`),
|
|
127
157
|
};
|
|
128
158
|
};
|
|
129
159
|
exports.connectGithub = connectGithub;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ouro.bot/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1113",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@ouro.bot/cli",
|
|
9
|
-
"version": "0.1.0-alpha.
|
|
9
|
+
"version": "0.1.0-alpha.1113",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.78.0",
|
|
12
12
|
"@ouro.bot/friends": "0.1.0-alpha.18",
|