even-keel 0.2.1 → 0.2.2
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.md +27 -0
- package/README.md +77 -88
- package/dist/src/account/current.js +4 -4
- package/dist/src/account/model.js +1 -1
- package/dist/src/account/watcher.js +4 -1
- package/dist/src/agent/providers.js +2 -1
- package/dist/src/autostart.js +32 -2
- package/dist/src/chain/dispatcher.js +8 -2
- package/dist/src/chain/launches.js +1 -1
- package/dist/src/chain/log.js +2 -0
- package/dist/src/chain/maincheck.js +19 -0
- package/dist/src/chain/mainci.js +4 -0
- package/dist/src/chain/mainfix.js +30 -0
- package/dist/src/chain/prompts.js +2 -0
- package/dist/src/chain/unchanged.js +47 -19
- package/dist/src/ci/watcher.js +12 -1
- package/dist/src/claude/adapter.js +8 -2
- package/dist/src/claude/cli.js +11 -3
- package/dist/src/claude/sdk/release.js +1 -1
- package/dist/src/claude/trust.js +77 -4
- package/dist/src/codex/adapter.js +2 -2
- package/dist/src/codex/plugins.js +20 -5
- package/dist/src/codex/version.js +1 -1
- package/dist/src/copilot/adapter.js +2 -1
- package/dist/src/copilot/cli.js +10 -5
- package/dist/src/copilot/home.js +19 -5
- package/dist/src/copilot/machine.js +20 -3
- package/dist/src/git/setup.js +2 -2
- package/dist/src/gitlab/adapter.js +1 -0
- package/dist/src/gitlab/source.js +13 -1
- package/dist/src/jira/adapter.js +1 -0
- package/dist/src/jira/api.js +13 -5
- package/dist/src/jira/source.js +20 -2
- package/dist/src/notice/en.js +7 -2
- package/dist/src/opencode/adapter.js +1 -1
- package/dist/src/packages/service.js +2 -0
- package/dist/src/packages/store.js +2 -1
- package/dist/src/paths.js +35 -0
- package/dist/src/projects/check.js +15 -6
- package/dist/src/projects/folder.js +8 -0
- package/dist/src/projects/state.js +1 -0
- package/dist/src/service/accounts.js +19 -4
- package/dist/src/service/chain.js +2 -2
- package/dist/src/service/stats.js +3 -0
- package/dist/src/sessions/protection.js +9 -6
- package/dist/src/stats/tally.js +2 -2
- package/dist/src/storage/atomic.js +19 -3
- package/dist/src/storage/database.js +5 -0
- package/dist/src/storage/migrations.js +17 -1
- package/dist/src/storage/schema.js +1 -1
- package/dist/src/tracker/model.js +4 -0
- package/dist/src/tracker/trackers.js +7 -0
- package/dist/tally/src/collect-worker.js +2 -2
- package/dist/tally/src/collect.js +3 -2
- package/dist/tally/src/db.js +3 -0
- package/dist/tally/src/steps.js +7 -2
- package/dist/tally/src/tracker-times.js +47 -0
- package/dist/web/assets/Loader-CRe-GCoI.js +31 -0
- package/dist/web/assets/{TaskCard-CjyQeVqL.js → TaskCard-C2xeaHWD.js} +2 -2
- package/dist/web/assets/TranscriptWindow-B9zsSmIg.css +1 -0
- package/dist/web/assets/TranscriptWindow-COL_WTrF.js +4 -0
- package/dist/web/assets/{feedLine-CDr3S8u-.js → feedLine-D0lnFyBZ.js} +1 -1
- package/dist/web/assets/index-DQje9Nfo.js +25 -0
- package/dist/web/assets/index-mDBlgk2Y.css +1 -0
- package/dist/web/assets/{media-CZ0HLFuK.js → media-BlW-XXN0.js} +1 -1
- package/dist/web/assets/useModels-DRW63oka.js +15 -0
- package/dist/web/index.html +5 -5
- package/even-keel.config.example.json +1 -1
- package/package.json +3 -2
- package/dist/web/assets/Loader-CG5xzofh.js +0 -31
- package/dist/web/assets/TranscriptWindow-2afYjYo9.css +0 -1
- package/dist/web/assets/TranscriptWindow-z3VnB6bE.js +0 -4
- package/dist/web/assets/index-AeOeU4Dr.js +0 -25
- package/dist/web/assets/index-DMDSaLu7.css +0 -1
- package/dist/web/assets/useModels-DfXVnluv.js +0 -15
package/dist/src/jira/api.js
CHANGED
|
@@ -21,11 +21,14 @@ export function siteUrl(values) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
export const basicAuth = (email, token) => Buffer.from(`${email}:${token}`).toString('base64');
|
|
24
|
+
/** `fields` — the keys of the answer's `errors`: the request's own fields Jira refused, as opposed to `errorMessages`. */
|
|
24
25
|
export class JiraHttpError extends Error {
|
|
25
26
|
status;
|
|
26
|
-
|
|
27
|
+
fields;
|
|
28
|
+
constructor(status, detail, fields = []) {
|
|
27
29
|
super(`jira: HTTP ${status}${detail ? `: ${detail}` : ''}`);
|
|
28
30
|
this.status = status;
|
|
31
|
+
this.fields = fields;
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
export class JiraApi {
|
|
@@ -79,18 +82,23 @@ export class JiraApi {
|
|
|
79
82
|
}, path);
|
|
80
83
|
if (response.ok)
|
|
81
84
|
return response;
|
|
82
|
-
const
|
|
85
|
+
const answer = await response.json().catch(() => ({}));
|
|
86
|
+
const detail = errorText(answer);
|
|
83
87
|
if (response.status === 401)
|
|
84
88
|
throw new CredentialsRefused(`jira: the e-mail and the API token are refused (HTTP 401)${detail ? `: ${detail}` : ''}`);
|
|
85
89
|
if (response.status === 404)
|
|
86
90
|
throw new TrackerNotFound(`jira: not found or the account cannot see it (HTTP 404)${detail ? `: ${detail}` : ''}`);
|
|
87
|
-
throw new JiraHttpError(response.status, detail);
|
|
91
|
+
throw new JiraHttpError(response.status, detail, Object.keys(fieldErrors(answer)));
|
|
88
92
|
}
|
|
89
93
|
}
|
|
94
|
+
const fieldErrors = (body) => {
|
|
95
|
+
const { errors } = (body ?? {});
|
|
96
|
+
return errors !== null && typeof errors === 'object' ? errors : {};
|
|
97
|
+
};
|
|
90
98
|
/** Jira's error answer: `errorMessages` and the `errors` of fields. */
|
|
91
99
|
function errorText(body) {
|
|
92
|
-
const { errorMessages
|
|
100
|
+
const { errorMessages } = (body ?? {});
|
|
93
101
|
const messages = Array.isArray(errorMessages) ? errorMessages.map(String) : [];
|
|
94
|
-
const fields =
|
|
102
|
+
const fields = Object.entries(fieldErrors(body)).map(([field, message]) => `${field}: ${String(message)}`);
|
|
95
103
|
return [...messages, ...fields].join('; ');
|
|
96
104
|
}
|
package/dist/src/jira/source.js
CHANGED
|
@@ -2,10 +2,10 @@ import { sameName } from '../chain/rules.js';
|
|
|
2
2
|
import { changedLabels } from '../tracker/labels.js';
|
|
3
3
|
import { fail } from '../notice/notice.js';
|
|
4
4
|
import { commentsAfterId } from '../tracker/comments.js';
|
|
5
|
-
import { parseTaskId, uniqueStatuses } from '../tracker/model.js';
|
|
5
|
+
import { entryMinutes, parseTaskId, uniqueStatuses } from '../tracker/model.js';
|
|
6
6
|
import { TrackerNotFound } from '../tracker/source.js';
|
|
7
7
|
import { adfToMarkdown, markdownToAdf } from './adf.js';
|
|
8
|
-
import { JiraApi } from './api.js';
|
|
8
|
+
import { JiraApi, JiraHttpError } from './api.js';
|
|
9
9
|
import { BLOCKS, CARD_FIELDS, earliestVersion, hasChildIssues, jiraStatus, priorityFor, TASK_FIELDS, toCard, toTrackerTask, } from './model.js';
|
|
10
10
|
const PAGE = 100;
|
|
11
11
|
/** Keys per `parent in (…)` query: a long JQL is refused. */
|
|
@@ -315,6 +315,24 @@ export async function connectJira(settings, timeoutMs, fetchImpl = fetch, log =
|
|
|
315
315
|
milestones: openVersions(await versionsOf(key)).map((version) => version.name),
|
|
316
316
|
};
|
|
317
317
|
},
|
|
318
|
+
// A refusal of the project — no "Work on issues", tracking off on the site — is a 403, or a 400 naming no field of
|
|
319
|
+
// the request: Jira words it in the account's language (EKR-91), so the text is never matched. A 400 naming a
|
|
320
|
+
// field (`started`, `timeSpentSeconds`) is our own request's fault and throws.
|
|
321
|
+
async logTime(id, entry) {
|
|
322
|
+
const seconds = entryMinutes(entry.hours) * 60;
|
|
323
|
+
const started = jiraTime(Date.parse(entry.at) - seconds * 1000);
|
|
324
|
+
try {
|
|
325
|
+
await api.rest(`${issuePath(id)}/worklog?notifyUsers=false`, 'POST', { timeSpentSeconds: seconds, started, comment: markdownToAdf(entry.summary) });
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
if (error instanceof JiraHttpError && (error.status === 403 || (error.status === 400 && error.fields.length === 0)))
|
|
330
|
+
return false;
|
|
331
|
+
throw error;
|
|
332
|
+
}
|
|
333
|
+
},
|
|
318
334
|
close: async () => { },
|
|
319
335
|
};
|
|
320
336
|
}
|
|
337
|
+
/** A worklog's `started`: Jira takes `2026-11-01T10:13:00.000+0000`, not the `Z` of ISO. */
|
|
338
|
+
const jiraTime = (ms) => new Date(ms).toISOString().replace(/Z$/, '+0000');
|
package/dist/src/notice/en.js
CHANGED
|
@@ -181,8 +181,12 @@ export const en = {
|
|
|
181
181
|
'cliCheck.busy': (p) => `the CLI check is running on the account ${p.account}; try again once it ends`,
|
|
182
182
|
'cliCheck.chainWaits': (p) => `the CLI check is running on the account ${p.account}; ${p.task} starts as soon as it ends`,
|
|
183
183
|
'claude.startFailed': (p) => `claude: could not start ${p.task} in ${p.cwd}`,
|
|
184
|
-
// `service` — Even Keel runs as a system service (BTN-687); a pause written before it has none.
|
|
185
|
-
|
|
184
|
+
// `service` — Even Keel runs as a system service (BTN-687); a pause written before it has none. `script` — the `.ps1` a
|
|
185
|
+
// Windows service's command runs (EKR-87). The command itself is the page's (`web/src/pages/trustRecovery.ts`).
|
|
186
|
+
'claude.untrusted': (p) => `Claude Code does not trust ${p.folder}. Run the command and press Check again and resume`,
|
|
187
|
+
// `file` and `reason` came with EKR-87; a pause written before it has only the folder.
|
|
188
|
+
'claude.trustWriteFailed': (p) => p.file === undefined ? `Could not save Claude Code trust for ${p.folder}. Fix the account's .claude.json and press Check again and resume`
|
|
189
|
+
: `Could not save Claude Code trust: ${p.reason === 'invalid' ? `${p.file} is damaged` : `no access to ${p.file}`}. Fix it and press Check again and resume`,
|
|
186
190
|
'claude.resumeFailed': (p) => `claude: could not resume ${p.task} in ${p.cwd}`,
|
|
187
191
|
'claude.notShown': (p) => `claude: ${p.task} was started but did not show up in claude agents`,
|
|
188
192
|
'claude.resumedNotShown': (p) => `claude: ${p.task} was resumed but did not show up in claude agents`,
|
|
@@ -354,6 +358,7 @@ export const en = {
|
|
|
354
358
|
'huly.clientFailed': () => 'huly: npm could not install the Huly client; Huly projects wait until it is retried',
|
|
355
359
|
'packages.marketplaceUpdate': (p) => `packages: claude plugin marketplace update ${p.marketplace} failed`,
|
|
356
360
|
'packages.marketplaceAdd': (p) => `packages: claude plugin marketplace add could not add ${p.marketplace}`,
|
|
361
|
+
'packages.marketplaceCliMissing': () => 'Even Keel cannot find Claude Code: install it, then add the marketplace again on Accounts',
|
|
357
362
|
'packages.noOwnMarketplace': (p) => `packages: ${p.dir} has no .claude-plugin/marketplace.json`,
|
|
358
363
|
'packages.upToDate': (p) => `packages: ${p.name} is already the latest version`,
|
|
359
364
|
'packages.updated': (p) => `packages: ${p.name} is updated to ${p.version}; running tasks stay on the version they started with`,
|
|
@@ -47,7 +47,7 @@ export const opencode = {
|
|
|
47
47
|
const onMachine = () => findBinary(system(), env());
|
|
48
48
|
const cli = new OpenCodeCli(bin, timeoutMs, envOf, new TurnRegistry(join(workDir, OPENCODE)));
|
|
49
49
|
return {
|
|
50
|
-
cli: cliCopy(copy, { checkedCli }, version, onMachine, () => !!env().EVEN_KEEL_OPENCODE_BIN,
|
|
50
|
+
cli: cliCopy(copy, { checkedCli }, version, onMachine, () => !!env().EVEN_KEEL_OPENCODE_BIN, 80 * 1_000_000),
|
|
51
51
|
mode: SESSION_MODE,
|
|
52
52
|
env: envOf,
|
|
53
53
|
launch: (home, start) => cli.launch(home, start),
|
|
@@ -172,6 +172,8 @@ export class Packages {
|
|
|
172
172
|
await this.deps.addMarketplace(this.deps.ownDir);
|
|
173
173
|
}
|
|
174
174
|
catch (error) {
|
|
175
|
+
if (error.code === 'ENOENT')
|
|
176
|
+
throw fail('packages.marketplaceCliMissing', {}, {}, { cause: error });
|
|
175
177
|
throw fail('packages.marketplaceAdd', { marketplace: name }, { detail: error.message }, { cause: error });
|
|
176
178
|
}
|
|
177
179
|
this.deps.log(`packages: the marketplace ${name} added to Claude Code from ${this.deps.ownDir}`);
|
|
@@ -33,7 +33,8 @@ export function loadPackages(file) {
|
|
|
33
33
|
pins: (isRecord(raw.pins) ? raw.pins : {}),
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
/** Private (600 off Windows): a package's settings may hold a header or a variable with a token. */
|
|
36
37
|
export function savePackages(file, packages) {
|
|
37
38
|
const stored = { version: SCHEMA_VERSION, packages: packages.packages, projects: packages.projects, pins: packages.pins };
|
|
38
|
-
writeAtomic(file, `${JSON.stringify(stored, null, 2)}\n
|
|
39
|
+
writeAtomic(file, `${JSON.stringify(stored, null, 2)}\n`, 0o600);
|
|
39
40
|
}
|
package/dist/src/paths.js
CHANGED
|
@@ -53,6 +53,25 @@ export function spelledUnder(path, folder, platform = process.platform) {
|
|
|
53
53
|
export function samePath(a, b, platform = process.platform) {
|
|
54
54
|
return pathKey(a, platform) === pathKey(b, platform);
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The folder as a CLI started in it sees its working folder: the real path, links resolved — a symlink off Windows
|
|
58
|
+
* (macOS `/tmp` is `/private/tmp`, EKR-94) and a junction on Windows (EKR-96). A folder that cannot be resolved is kept
|
|
59
|
+
* as it is, and so is a Windows one whose real path leaves its drive (a `subst` or mapped drive, a `\\?\` or UNC path):
|
|
60
|
+
* what the CLI reads there is unchecked.
|
|
61
|
+
*/
|
|
62
|
+
export function workingFolder(folder, platform = process.platform, real = realpathSync.native) {
|
|
63
|
+
let resolved;
|
|
64
|
+
try {
|
|
65
|
+
resolved = real(folder);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return folder;
|
|
69
|
+
}
|
|
70
|
+
if (platform !== 'win32')
|
|
71
|
+
return resolved;
|
|
72
|
+
const sameDrive = !resolved.startsWith('\\\\') && win32.parse(resolved).root.toLowerCase() === win32.parse(win32.resolve(folder)).root.toLowerCase();
|
|
73
|
+
return sameDrive ? resolved : folder;
|
|
74
|
+
}
|
|
56
75
|
/** The same path as written, links not followed: where a link points, not where it leads. */
|
|
57
76
|
export function sameSpelling(a, b, platform = process.platform) {
|
|
58
77
|
const paths = pathsOf(platform);
|
|
@@ -75,6 +94,22 @@ export function findBinary(bin, env, platform = process.platform, exists = exist
|
|
|
75
94
|
const extensions = windows ? SPAWN_EXTENSIONS : [''];
|
|
76
95
|
return pathFolders(env, platform).some((folder) => extensions.some((extension) => exists(paths.join(folder, `${bin}${extension}`))));
|
|
77
96
|
}
|
|
97
|
+
/** The executable spawn resolves, made absolute so a recovery terminal need not share the service's PATH. */
|
|
98
|
+
export function binaryPath(bin, env, cwd, platform = process.platform, exists = existsSync) {
|
|
99
|
+
const paths = pathsOf(platform);
|
|
100
|
+
if (bin.includes('/') || (platform === 'win32' && bin.includes('\\')))
|
|
101
|
+
return paths.resolve(cwd, bin);
|
|
102
|
+
const extensions = platform === 'win32' && paths.extname(bin) === '' ? SPAWN_EXTENSIONS : [''];
|
|
103
|
+
const folders = platform === 'win32' ? [cwd, ...pathFolders(env, platform)] : pathFolders(env, platform);
|
|
104
|
+
for (const folder of folders) {
|
|
105
|
+
for (const extension of extensions) {
|
|
106
|
+
const file = paths.resolve(cwd, folder, `${bin}${extension}`);
|
|
107
|
+
if (exists(file))
|
|
108
|
+
return file;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
78
113
|
/** The folders of the PATH, whatever the case of the variable on Windows. */
|
|
79
114
|
export function pathFolders(env, platform = process.platform) {
|
|
80
115
|
const windows = platform === 'win32';
|
|
@@ -4,8 +4,8 @@ import { parseRemote, remotesOf } from '../ci/remote.js';
|
|
|
4
4
|
import { withNewProject, yieldedMilestones } from '../config-form.js';
|
|
5
5
|
import { DEFAULT_BRANCH, isPlainObject, parseConfig, projectLabels, runSettings } from '../config.js';
|
|
6
6
|
import { notice, noticeOf } from '../notice/notice.js';
|
|
7
|
-
import { pathsOf, samePath } from '../paths.js';
|
|
8
|
-
import {
|
|
7
|
+
import { pathsOf, samePath, sameSpelling, workingFolder } from '../paths.js';
|
|
8
|
+
import { expandFolder, isFullPath, REAL_FOLDERS } from './folder.js';
|
|
9
9
|
import { errorText, TrackerLink } from '../tracker/link.js';
|
|
10
10
|
import { isOpen } from '../tracker/model.js';
|
|
11
11
|
import { trackerOf } from '../tracker/source.js';
|
|
@@ -50,10 +50,10 @@ export async function checkRepo(git, draft, raw, platform = process.platform, ad
|
|
|
50
50
|
const typed = draft.repo.trim();
|
|
51
51
|
if (typed === '')
|
|
52
52
|
return { root: null, current: null, suggested: null, notice: null };
|
|
53
|
-
const path =
|
|
53
|
+
const path = expandFolder(typed, folders.home, platform);
|
|
54
54
|
const refuse = (code) => ({ root: null, current: null, suggested: null, notice: notice(code, { path: typed }) });
|
|
55
55
|
if (!isFullPath(path, platform))
|
|
56
|
-
return refuse('wizard.relativePath');
|
|
56
|
+
return refuse(platform === 'win32' && /%[^%]+%/.test(path) ? 'wizard.noFolder' : 'wizard.relativePath');
|
|
57
57
|
if (!folders.isFolder(path))
|
|
58
58
|
return refuse('wizard.noFolder');
|
|
59
59
|
const top = await git(path, ['rev-parse', '--show-toplevel']);
|
|
@@ -167,8 +167,17 @@ async function checkTracker(adapter, deps, key, place, rules) {
|
|
|
167
167
|
await link.close();
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
/** Whether `.claude.json` trusts the folder under
|
|
170
|
+
/** Whether `.claude.json` trusts the folder under a key the CLI reads. */
|
|
171
171
|
export function isTrusted(config, folder, platform = process.platform) {
|
|
172
172
|
const projects = isPlainObject(config) && isPlainObject(config.projects) ? config.projects : {};
|
|
173
|
-
return Object.entries(projects).some(([path, entry]) =>
|
|
173
|
+
return Object.entries(projects).some(([path, entry]) => readsKey(path, folder, platform) && isPlainObject(entry) && entry.hasTrustDialogAccepted === true);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Whether the CLI started in `folder` reads its trust under `key`: the folder's real path (`workingFolder`), a key under
|
|
177
|
+
* a link or junction to it does not count (EKR-94, EKR-96); on Windows in any case, with forward slashes only (EKR-92).
|
|
178
|
+
*/
|
|
179
|
+
export function readsKey(key, folder, platform = process.platform) {
|
|
180
|
+
if (platform === 'win32' && key.includes('\\'))
|
|
181
|
+
return false;
|
|
182
|
+
return sameSpelling(key, workingFolder(folder, platform), platform);
|
|
174
183
|
}
|
|
@@ -24,6 +24,14 @@ export function expandHome(typed, home, platform = process.platform) {
|
|
|
24
24
|
const flavour = platform === 'win32' ? path.win32 : path.posix;
|
|
25
25
|
return rest[1] === undefined || rest[1] === '' ? home : flavour.join(home, rest[1]);
|
|
26
26
|
}
|
|
27
|
+
/** Expand the wizard's home shorthand and, on Windows, service environment variables in one pass. */
|
|
28
|
+
export function expandFolder(typed, home, platform = process.platform, env = process.env) {
|
|
29
|
+
const expanded = expandHome(typed, home, platform);
|
|
30
|
+
if (platform !== 'win32')
|
|
31
|
+
return expanded;
|
|
32
|
+
const values = new Map(Object.entries(env).map(([name, value]) => [name.toUpperCase(), value]));
|
|
33
|
+
return expanded.replace(/%([^%]+)%/g, (token, name) => values.get(name.toUpperCase()) || token);
|
|
34
|
+
}
|
|
27
35
|
/** Whether the path is full for the platform the service runs on. */
|
|
28
36
|
export function isFullPath(folder, platform = process.platform) {
|
|
29
37
|
return (platform === 'win32' ? path.win32 : path.posix).isAbsolute(folder);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -159,13 +159,14 @@ export function wireLaunchIn(ctx) {
|
|
|
159
159
|
await ctx.requireModel(home, start);
|
|
160
160
|
if (home.agent === CLAUDE && start.settings !== undefined)
|
|
161
161
|
ctx.sayBlankedSecrets(home);
|
|
162
|
+
const trusted = withTrust(ctx, start, project);
|
|
162
163
|
try {
|
|
163
|
-
return await ctx.cliLease.session(home, () => ctx.agentOf(home).launch(home,
|
|
164
|
+
return await ctx.cliLease.session(home, () => ctx.agentOf(home).launch(home, trusted));
|
|
164
165
|
}
|
|
165
166
|
catch (error) {
|
|
166
|
-
const folder =
|
|
167
|
+
const folder = trusted.trustedRepo;
|
|
167
168
|
const place = folder === undefined ? null : { task: start.name, folder, platform: process.platform, user: userInfo().username, service: await runsAsService() };
|
|
168
|
-
throw (place === null ? null : untrustedStart(error, place)) ?? error;
|
|
169
|
+
throw (place === null ? null : untrustedStart(error, place, ctx.stateDir)) ?? error;
|
|
169
170
|
}
|
|
170
171
|
};
|
|
171
172
|
}
|
|
@@ -175,9 +176,23 @@ export function wireResumeIn(ctx) {
|
|
|
175
176
|
if (blocked)
|
|
176
177
|
throw new NoticeError(blocked);
|
|
177
178
|
await ctx.requireModel(home, start);
|
|
178
|
-
|
|
179
|
+
const project = ctx.projectOf(start.name);
|
|
180
|
+
const trusted = withTrust(ctx, start, project);
|
|
181
|
+
try {
|
|
182
|
+
return await ctx.cliLease.session(home, () => ctx.agentOf(home).resume(home, session, trusted));
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
const folder = trusted.trustedRepo;
|
|
186
|
+
const place = folder === undefined ? null : { task: start.name, folder, platform: process.platform, user: userInfo().username, service: await runsAsService() };
|
|
187
|
+
throw (place === null ? null : untrustedStart(error, place, ctx.stateDir)) ?? error;
|
|
188
|
+
}
|
|
179
189
|
};
|
|
180
190
|
}
|
|
191
|
+
function withTrust(ctx, start, project) {
|
|
192
|
+
const config = ctx.configStore.current;
|
|
193
|
+
const folder = project === undefined ? undefined : config.projects[project];
|
|
194
|
+
return { ...start, trustedRepo: folder };
|
|
195
|
+
}
|
|
181
196
|
export function wireLimits(ctx) {
|
|
182
197
|
return new LimitsWatcher({
|
|
183
198
|
file: ctx.limitsFile,
|
|
@@ -514,9 +514,9 @@ export function approved(ctx, task, session, prompt) {
|
|
|
514
514
|
return true;
|
|
515
515
|
}
|
|
516
516
|
export function goOnWith(ctx, home, task, session, prompt) {
|
|
517
|
-
const
|
|
517
|
+
const { model } = ctx.planFor(task, prompt);
|
|
518
518
|
const extras = ctx.agentExtras(home, ctx.projectOf(task), task);
|
|
519
|
-
return { name: task, cwd: session.cwd, prompt
|
|
519
|
+
return { name: task, cwd: session.cwd, prompt, model, settings: ctx.settingsFor(task), ...extras };
|
|
520
520
|
}
|
|
521
521
|
export async function steer(ctx, task, session, prompt) {
|
|
522
522
|
const home = ctx.homeOf(session.account);
|
|
@@ -6,6 +6,8 @@ import { defaultProfile, profileFor } from '../profiles/model.js';
|
|
|
6
6
|
import { StatsReader } from '../stats/reader.js';
|
|
7
7
|
import { tallyKey } from '../stats/mode.js';
|
|
8
8
|
import { TallyService } from '../stats/tally.js';
|
|
9
|
+
import { ADAPTERS } from '../tracker/adapters.js';
|
|
10
|
+
import { timeTrackers } from '../tracker/trackers.js';
|
|
9
11
|
export function wireNewTally(ctx) {
|
|
10
12
|
return () => new TallyService({
|
|
11
13
|
mode: ctx.tallyMode(),
|
|
@@ -28,6 +30,7 @@ export function wireNewTally(ctx) {
|
|
|
28
30
|
const byId = Object.fromEntries(set.profiles.filter((profile) => profile.kind === 'huly').map((profile) => [profile.id, profile.values]));
|
|
29
31
|
return { projects: Object.fromEntries(projects), fallback: defaultProfile(set, 'huly')?.values ?? null, elsewhere, byId };
|
|
30
32
|
},
|
|
33
|
+
trackers: () => timeTrackers(ctx.readers(), ctx.profiles.current(), ADAPTERS),
|
|
31
34
|
log: (message) => console.log(message),
|
|
32
35
|
changed: () => ctx.hub.broadcastSoon('state', ctx.getState),
|
|
33
36
|
});
|
|
@@ -40,23 +40,26 @@ const GIT_GLOBALS = [[], ['-C', '.'], ['--no-pager']];
|
|
|
40
40
|
const push = (flags, remotes) => commands(['git', 'git -*'].flatMap(git => flags.flatMap(flag => [`${git} push ${flag}*`, `${git} push * ${flag}*`])), GIT_GLOBALS.flatMap(global => flags.flatMap(flag => [['git', ...global, 'push', flag], ...remotes.map(remote => ['git', ...global, 'push', remote, flag])])));
|
|
41
41
|
const remove = (targets) => commands(['-rf', '-fr'].flatMap(flags => targets.map(target => `rm ${flags} ${target}*`)), ['-rf', '-fr'].flatMap(flags => targets.map(target => ['rm', flags, target])));
|
|
42
42
|
/**
|
|
43
|
-
* Codex compares whole arguments, so `C:\`
|
|
44
|
-
*
|
|
43
|
+
* Codex compares whole arguments, so `C:\` slips past `C:`. These rm spellings stay Codex's: Claude's patterns
|
|
44
|
+
* already cover them, and Copilot's parsing of a `*` inside a prefix was never checked.
|
|
45
45
|
*/
|
|
46
46
|
const codexOnly = (prefixes) => ({ claude: [], codex: prefixes, copilot: [], opencode: { bash: [], tools: [] } });
|
|
47
47
|
const removeSpelled = (targets) => codexOnly(['-rf', '-fr'].flatMap(flags => targets.map(target => ['rm', flags, target])));
|
|
48
|
-
const refspec = (forms, remotes) =>
|
|
48
|
+
const refspec = (forms, remotes, copilot) => {
|
|
49
|
+
const prefixes = remotes.flatMap(remote => forms.map(form => ['git', 'push', remote, form]));
|
|
50
|
+
return { ...codexOnly(prefixes), copilot: copilot ? commands([], prefixes).copilot : [] };
|
|
51
|
+
};
|
|
49
52
|
const merge = (...parts) => ({ claude: parts.flatMap(part => part.claude), codex: parts.flatMap(part => part.codex), copilot: parts.flatMap(part => part.copilot), opencode: { bash: parts.flatMap(part => part.opencode.bash), tools: parts.flatMap(part => part.opencode.tools) } });
|
|
50
53
|
/**
|
|
51
54
|
* Codex and Copilot match literal command prefixes; the remote names cover the usual `git push <remote> <flag>` order too,
|
|
52
|
-
* and with the project's main branch Codex also gets
|
|
55
|
+
* and with the project's main branch both get force-refspecs; Codex also gets deletion refspecs.
|
|
53
56
|
*/
|
|
54
57
|
export function protectionRules(value = DEFAULT_PROTECTION, remotes = [], branch, hulyServers = ['plugin_huly_huly', 'huly']) {
|
|
55
|
-
const refspecs = (forms) => refspec(branch === undefined ? [] : forms(branch), remotes);
|
|
58
|
+
const refspecs = (forms, copilot = false) => refspec(branch === undefined ? [] : forms(branch), remotes, copilot);
|
|
56
59
|
// Only Huly has native rules too; the other trackers' deletes are refused by the gateway alone (native ones: BTN-611).
|
|
57
60
|
const gateway = () => ({ claude: [], codex: [], copilot: [], opencode: { bash: [], tools: [] } });
|
|
58
61
|
const groups = {
|
|
59
|
-
forcePush: merge(push(['--force', '--force-with-lease', '-f'], remotes), refspecs(main => [`+${main}`, `+HEAD:${main}`, `+${main}:${main}`, `+${main}:refs/heads/${main}`, `+HEAD:refs/heads/${main}`])),
|
|
62
|
+
forcePush: merge(push(['--force', '--force-with-lease', '-f'], remotes), refspecs(main => [`+${main}`, `+HEAD:${main}`, `+${main}:${main}`, `+${main}:refs/heads/${main}`, `+HEAD:refs/heads/${main}`], true)),
|
|
60
63
|
mirrorPush: push(['--mirror'], remotes),
|
|
61
64
|
deleteRemote: merge(push(['--delete', '-d'], remotes), refspecs(main => [`:${main}`, `:refs/heads/${main}`])),
|
|
62
65
|
deleteRoot: merge(remove(['/', 'C:', 'D:']), removeSpelled(['C:\\', 'D:\\', 'C:/', 'D:/', '/*'])),
|
package/dist/src/stats/tally.js
CHANGED
|
@@ -116,9 +116,9 @@ export class TallyService {
|
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
const { root, home, env, evenKeelUrl, huly, log } = this.options;
|
|
119
|
+
const { root, home, env, evenKeelUrl, huly, trackers, log } = this.options;
|
|
120
120
|
const run = new Worker(workerFile('collect-worker'), {
|
|
121
|
-
workerData: { root, home, settings, huly: huly() },
|
|
121
|
+
workerData: { root, home, settings, huly: huly(), trackers: trackers() },
|
|
122
122
|
env: { ...process.env, EVEN_KEEL_URL: env.EVEN_KEEL_URL ?? evenKeelUrl() },
|
|
123
123
|
});
|
|
124
124
|
this.running = run;
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { mkdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { chmodSync, mkdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
3
|
const RENAME_RETRY_MS = 3000;
|
|
4
4
|
const waitBuffer = new Int32Array(new SharedArrayBuffer(4));
|
|
5
5
|
/**
|
|
6
6
|
* Writes the file whole or not at all: into a temporary file next to it, then a rename over it.
|
|
7
7
|
* In-process readers must use synchronous fs calls: a pending async close cannot run during rename's retry wait.
|
|
8
|
+
* Off Windows the file keeps the permissions of the one it replaces, so a 600 account file does not turn 644 under the
|
|
9
|
+
* umask (EKR-95); `mode` sets them instead, for a file that must stay private whether it is new or not.
|
|
8
10
|
*/
|
|
9
|
-
export function writeAtomic(file, text) {
|
|
11
|
+
export function writeAtomic(file, text, mode) {
|
|
10
12
|
mkdirSync(dirname(file), { recursive: true });
|
|
11
13
|
const temp = `${file}.${process.pid}.tmp`;
|
|
12
14
|
try {
|
|
13
|
-
|
|
15
|
+
const kept = process.platform === 'win32' ? undefined : mode ?? modeOf(file);
|
|
16
|
+
// Owner-only until the chmod, so a private file's text is never readable by others on the way.
|
|
17
|
+
writeFileSync(temp, text, kept === undefined ? {} : { mode: 0o600 });
|
|
18
|
+
if (kept !== undefined)
|
|
19
|
+
chmodSync(temp, kept);
|
|
14
20
|
renameOver(temp, file);
|
|
15
21
|
}
|
|
16
22
|
catch (error) {
|
|
@@ -18,6 +24,16 @@ export function writeAtomic(file, text) {
|
|
|
18
24
|
throw error;
|
|
19
25
|
}
|
|
20
26
|
}
|
|
27
|
+
function modeOf(file) {
|
|
28
|
+
try {
|
|
29
|
+
return statSync(file).mode & 0o7777;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error.code === 'ENOENT')
|
|
33
|
+
return undefined;
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
21
37
|
/**
|
|
22
38
|
* A rename retried for up to three seconds on Windows: readers there (virus scanners, the indexer) can briefly deny
|
|
23
39
|
* replacing a file they have open or moving a folder just closed (BTN-674).
|
|
@@ -307,6 +307,11 @@ export const STEPS = [
|
|
|
307
307
|
closed_at text not null,
|
|
308
308
|
primary key (project_id, task)
|
|
309
309
|
);
|
|
310
|
+
`,
|
|
311
|
+
// Claude background sessions always trust the checkout; remove legacy project consent and its definition.
|
|
312
|
+
`
|
|
313
|
+
delete from setting_values where key = 'trustClaude';
|
|
314
|
+
delete from setting_definitions where key = 'trustClaude';
|
|
310
315
|
`,
|
|
311
316
|
];
|
|
312
317
|
/** The version this code reads and writes. */
|
|
@@ -136,7 +136,23 @@ export function currentConfig(raw, active = GLOBAL_ACCOUNT) {
|
|
|
136
136
|
const cli = version < 21 ? cliChecked(groups) : groups;
|
|
137
137
|
const sdk = version < 22 ? sdkChecked(cli) : cli;
|
|
138
138
|
// v23 → v24: a project's `statusMoves` and a feed's `moves` (BTN-554) are optional; the restamp above is all it takes.
|
|
139
|
-
|
|
139
|
+
// v24 → v25: optional project consent `trustClaude`; omitted means false, so existing projects keep manual trust.
|
|
140
|
+
const feeds = version < 23 ? feedsRuled(sdk) : sdk;
|
|
141
|
+
return version < 26 ? automaticTrust(feeds) : feeds;
|
|
142
|
+
}
|
|
143
|
+
/** v25 → v26: Claude background launches always trust the checkout; project consent is no longer a setting. */
|
|
144
|
+
export function automaticTrust(raw) {
|
|
145
|
+
if (!isRecord(raw))
|
|
146
|
+
return raw;
|
|
147
|
+
if (!Array.isArray(raw.projects))
|
|
148
|
+
return stamped(raw);
|
|
149
|
+
const projects = raw.projects.map((project) => {
|
|
150
|
+
if (!isRecord(project))
|
|
151
|
+
return project;
|
|
152
|
+
const { trustClaude: _removed, ...rest } = project;
|
|
153
|
+
return rest;
|
|
154
|
+
});
|
|
155
|
+
return stamped({ ...raw, projects });
|
|
140
156
|
}
|
|
141
157
|
/**
|
|
142
158
|
* v22 → v23: a feed keeps its own chain rules and the project's no longer reach its tasks (BTN-553); each feed of a
|
|
@@ -4,7 +4,7 @@ import { fail } from '../notice/notice.js';
|
|
|
4
4
|
* file's format is a new version, a step in `migrations.ts` and a new frozen sample in `test/fixtures/schema-v<N>/`.
|
|
5
5
|
* A future import into a database reads it to know what it imports.
|
|
6
6
|
*/
|
|
7
|
-
export const SCHEMA_VERSION =
|
|
7
|
+
export const SCHEMA_VERSION = 26;
|
|
8
8
|
/** A file without a version is from before versions: 1. */
|
|
9
9
|
export function versionOf(raw) {
|
|
10
10
|
const version = typeof raw === 'object' && raw !== null && !Array.isArray(raw) ? raw.version : undefined;
|
|
@@ -47,6 +47,10 @@ export function parseTaskId(id) {
|
|
|
47
47
|
const match = /^([A-Z][A-Z0-9_]*)-([1-9]\d*)$/.exec(id);
|
|
48
48
|
return match === null ? null : { project: match[1], number: Number(match[2]) };
|
|
49
49
|
}
|
|
50
|
+
/** A time entry's hours in whole minutes, at least one: what a tracker's time tracking takes (`TaskSource.logTime`). */
|
|
51
|
+
export function entryMinutes(hours) {
|
|
52
|
+
return Math.max(1, Math.round(hours * 60));
|
|
53
|
+
}
|
|
50
54
|
/** The task's link by its project's template (`TrackerSetup.issueUrl`), as the page fills it. */
|
|
51
55
|
export function issueLink(template, task) {
|
|
52
56
|
const parsed = parseTaskId(task);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { idPrefixOf } from '../config.js';
|
|
1
2
|
import { defaultProfile, profileFor } from '../profiles/model.js';
|
|
2
3
|
/** The key of a tracker that has projects and no profile. */
|
|
3
4
|
export const noProfile = (kind) => `none:${kind}`;
|
|
@@ -27,6 +28,12 @@ export function trackerPlans(config, set) {
|
|
|
27
28
|
}
|
|
28
29
|
return plans;
|
|
29
30
|
}
|
|
31
|
+
/** The profiles with projects of a tracker that takes a task's time (`logsTime`): Tally writes the time through them (EKR-35). */
|
|
32
|
+
export function timeTrackers(config, set, adapters) {
|
|
33
|
+
return [...trackerPlans(config, set).values()].flatMap((plan) => adapters[plan.kind]?.logsTime !== true || plan.profile === undefined || plan.projects.length === 0
|
|
34
|
+
? []
|
|
35
|
+
: [{ kind: plan.kind, values: plan.profile.values, places: plan.places, prefixes: [...new Set(plan.projects.map((project) => idPrefixOf(config, project, adapters)))] }]);
|
|
36
|
+
}
|
|
30
37
|
/**
|
|
31
38
|
* The tracker whose default profile links a task of no known project: the one most projects run on, a tie going to the
|
|
32
39
|
* first project's in the order of the config; none without projects. It took the shared `tracker` before BTN-345.
|
|
@@ -2,13 +2,13 @@ import { parentPort, workerData } from 'node:worker_threads';
|
|
|
2
2
|
import { collect } from './collect.js';
|
|
3
3
|
import { dbSettings } from './config.js';
|
|
4
4
|
// One collector run on its own thread: parsing transcripts would stall the service's event loop.
|
|
5
|
-
const { settings, root, home, huly } = workerData;
|
|
5
|
+
const { settings, root, home, huly, trackers } = workerData;
|
|
6
6
|
const log = (message) => console.log(`${new Date().toISOString()} ${message}`);
|
|
7
7
|
const run = async () => {
|
|
8
8
|
const server = settings ?? dbSettings(process.env);
|
|
9
9
|
if (server === null)
|
|
10
10
|
throw new Error('no database: neither a local one nor TALLY_DB_HOST');
|
|
11
|
-
return collect(server, root, home, log, huly);
|
|
11
|
+
return collect(server, root, home, log, huly, trackers);
|
|
12
12
|
};
|
|
13
13
|
const code = await run().catch((error) => {
|
|
14
14
|
log(`tally: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}`);
|
|
@@ -35,7 +35,8 @@ const CHUNK_BYTES = 8 * 1024 * 1024;
|
|
|
35
35
|
const EVEN_KEEL_TIMEOUT_MS = 5_000;
|
|
36
36
|
// One collector run: the exit code is 1 when a file failed to load, everything else is written anyway.
|
|
37
37
|
// `root` — Even Keel's code, `home` — its data (the same folder in a checkout, BTN-265).
|
|
38
|
-
|
|
38
|
+
// `trackers` — the GitLab and Jira profiles the time of their tasks is written through (EKR-35).
|
|
39
|
+
export async function collect(settings, root, home, log, huly, trackers = []) {
|
|
39
40
|
const started = Date.now();
|
|
40
41
|
const config = parseConfig(JSON.parse(readFileSync(process.env.TALLY_CONFIG ?? join(root, 'tally', 'tally.config.json'), 'utf8')));
|
|
41
42
|
const stateDir = process.env.EVEN_KEEL_STATE_DIR ?? join(home, 'state');
|
|
@@ -128,7 +129,7 @@ export async function collect(settings, root, home, log, huly) {
|
|
|
128
129
|
});
|
|
129
130
|
const stepped = await refreshSteps(db, config.steps);
|
|
130
131
|
const tasks = await refreshTasks(db, hulyOf, log);
|
|
131
|
-
const reports = await reportTaskTimes(db, config.reportsSince, hulyOf, log);
|
|
132
|
+
const reports = await reportTaskTimes(db, config.reportsSince, hulyOf, trackers, log);
|
|
132
133
|
const classified = await classifySpans(db, config.classify, log);
|
|
133
134
|
const unpriced = unpricedToLog(await db.unpricedModels(), config.unpriced);
|
|
134
135
|
if (unpriced.length > 0)
|
package/dist/tally/src/db.js
CHANGED
|
@@ -487,7 +487,10 @@ export class TallyDb {
|
|
|
487
487
|
order by tt.last_at`, [since, idleMinutes]);
|
|
488
488
|
return result.rows.map((row) => ({ task: row.task, hours: Number(row.hours), date: row.last_at.toISOString() }));
|
|
489
489
|
}
|
|
490
|
+
/** Hours `null` — the tracker refuses time for the task: it needs no report and is not asked for again. */
|
|
490
491
|
async markReported(reported) {
|
|
492
|
+
if (reported.size === 0)
|
|
493
|
+
return;
|
|
491
494
|
await this.client.query(`update tasks t set reported_h = x.hours, reported_at = now()
|
|
492
495
|
from jsonb_to_recordset($1::jsonb) as x(task text, hours numeric)
|
|
493
496
|
where t.task = x.task`, [JSON.stringify([...reported].map(([task, hours]) => ({ task, hours })))]);
|
package/dist/tally/src/steps.js
CHANGED
|
@@ -3,6 +3,7 @@ import { fetchTasks, reportTimes } from './huly.js';
|
|
|
3
3
|
import { byCredentials } from './huly-profiles.js';
|
|
4
4
|
import { findSigns, signKey, spansOf } from './signs.js';
|
|
5
5
|
import { rulesFor, runsOf, stepsKey } from './step-runs.js';
|
|
6
|
+
import { connectTracker, reportTrackerTimes } from './tracker-times.js';
|
|
6
7
|
import { turnsKey, turnsOf } from './turns.js';
|
|
7
8
|
const TASK_MAX_AGE_MINUTES = 60;
|
|
8
9
|
const REPORT_IDLE_MINUTES = 60;
|
|
@@ -85,7 +86,8 @@ export async function refreshTasks(db, hulyOf, log) {
|
|
|
85
86
|
}
|
|
86
87
|
return fetched;
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
+
/** A task a Huly profile reaches is reported to Huly; the rest go to the GitLab or Jira profile of their prefix (EKR-35). */
|
|
90
|
+
export async function reportTaskTimes(db, since, hulyOf, trackers, log, connect = connectTracker(HULY_TIMEOUT_MS)) {
|
|
89
91
|
if (since === null)
|
|
90
92
|
return 0;
|
|
91
93
|
const pending = await db.pendingReports(since, REPORT_IDLE_MINUTES);
|
|
@@ -100,7 +102,10 @@ export async function reportTaskTimes(db, since, hulyOf, log) {
|
|
|
100
102
|
log(`tally: Huly time reports of ${credentials.workspace} not written: ${error.message}`);
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
|
-
|
|
105
|
+
const elsewhere = pending.filter((report) => hulyOf(report.task) === undefined);
|
|
106
|
+
const reported = await reportTrackerTimes(elsewhere, trackers, log, connect);
|
|
107
|
+
await db.markReported(reported);
|
|
108
|
+
return written + [...reported.values()].filter((hours) => hours !== null).length;
|
|
104
109
|
}
|
|
105
110
|
export async function classifySpans(db, settings, log) {
|
|
106
111
|
if (settings.perRun === 0)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ADAPTERS } from '../../src/tracker/adapters.js';
|
|
2
|
+
import { REPORT_DESCRIPTION } from './huly.js';
|
|
3
|
+
/** Connects through the adapter of the profile's tracker, as the service's own trackers do. */
|
|
4
|
+
export const connectTracker = (timeoutMs) => async (tracker) => {
|
|
5
|
+
const setup = ADAPTERS[tracker.kind]?.setup(tracker.values, tracker.places);
|
|
6
|
+
if (setup === undefined)
|
|
7
|
+
throw new Error('the profile has no credentials');
|
|
8
|
+
return await setup.connect(timeoutMs);
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The time reports of the tasks of projects on another tracker than Huly (GitLab, Jira; EKR-35), each through the
|
|
12
|
+
* profile its prefix runs on, a tracker connected only for reports of its own. By task the hours written; `null` — the
|
|
13
|
+
* tracker refuses time in the task's project, so the task needs no report. A failure ends that tracker's batch:
|
|
14
|
+
* what was written stays, the rest waits for the next run.
|
|
15
|
+
*/
|
|
16
|
+
export async function reportTrackerTimes(reports, trackers, log, connect) {
|
|
17
|
+
const done = new Map();
|
|
18
|
+
for (const tracker of trackers) {
|
|
19
|
+
const prefixes = new Set(tracker.prefixes);
|
|
20
|
+
const own = reports.filter((report) => prefixes.has(prefixOf(report.task)));
|
|
21
|
+
if (own.length === 0)
|
|
22
|
+
continue;
|
|
23
|
+
const title = ADAPTERS[tracker.kind]?.title ?? tracker.kind;
|
|
24
|
+
const refused = new Set();
|
|
25
|
+
let source;
|
|
26
|
+
try {
|
|
27
|
+
source = await connect(tracker);
|
|
28
|
+
for (const report of own) {
|
|
29
|
+
const written = (await source.logTime?.(report.task, { hours: report.hours, at: report.date, summary: REPORT_DESCRIPTION })) ?? false;
|
|
30
|
+
done.set(report.task, written ? report.hours : null);
|
|
31
|
+
const prefix = prefixOf(report.task);
|
|
32
|
+
if (written || refused.has(prefix))
|
|
33
|
+
continue;
|
|
34
|
+
refused.add(prefix);
|
|
35
|
+
log(`tally: ${title} refuses time in ${prefix} (time tracking off, or no right to log work): its tasks get no time report`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
log(`tally: ${title} time reports of ${tracker.prefixes.join(', ')} not written: ${error.message}`);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
await source?.close().catch(() => { });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return done;
|
|
46
|
+
}
|
|
47
|
+
const prefixOf = (task) => task.slice(0, task.lastIndexOf('-'));
|