@raidiant/notifai 0.2.1 → 0.4.0
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/README.md +20 -4
- package/dist/atomic-file.d.ts +4 -0
- package/dist/atomic-file.js +60 -10
- package/dist/atomic-file.js.map +1 -1
- package/dist/client.d.ts +25 -2
- package/dist/client.js +45 -1
- package/dist/client.js.map +1 -1
- package/dist/commands.d.ts +85 -6
- package/dist/commands.js +1133 -322
- package/dist/commands.js.map +1 -1
- package/dist/config-schema.d.ts +62 -0
- package/dist/config-schema.js +312 -0
- package/dist/config-schema.js.map +1 -0
- package/dist/config.d.ts +38 -3
- package/dist/config.js +61 -14
- package/dist/config.js.map +1 -1
- package/dist/file-lock.d.ts +26 -0
- package/dist/file-lock.js +268 -0
- package/dist/file-lock.js.map +1 -0
- package/dist/harnesses.d.ts +28 -0
- package/dist/harnesses.js +40 -0
- package/dist/harnesses.js.map +1 -0
- package/dist/hook-adapter.d.ts +27 -0
- package/dist/hook-adapter.js +188 -0
- package/dist/hook-adapter.js.map +1 -0
- package/dist/hook-input.d.ts +10 -0
- package/dist/hook-input.js +64 -0
- package/dist/hook-input.js.map +1 -0
- package/dist/hooks.d.ts +66 -10
- package/dist/hooks.js +751 -276
- package/dist/hooks.js.map +1 -1
- package/dist/install-hooks.d.ts +40 -16
- package/dist/install-hooks.js +217 -73
- package/dist/install-hooks.js.map +1 -1
- package/dist/interactive.d.ts +4 -0
- package/dist/interactive.js +604 -0
- package/dist/interactive.js.map +1 -0
- package/dist/logging.d.ts +142 -0
- package/dist/logging.js +533 -0
- package/dist/logging.js.map +1 -0
- package/dist/main.js +201 -51
- package/dist/main.js.map +1 -1
- package/dist/opencode-plugin.d.ts +7 -7
- package/dist/opencode-plugin.js +12 -13
- package/dist/opencode-plugin.js.map +1 -1
- package/dist/ui/banner.d.ts +22 -0
- package/dist/ui/banner.js +87 -0
- package/dist/ui/banner.js.map +1 -0
- package/dist/ui/config-view.d.ts +32 -0
- package/dist/ui/config-view.js +108 -0
- package/dist/ui/config-view.js.map +1 -0
- package/dist/ui/help.d.ts +46 -0
- package/dist/ui/help.js +105 -0
- package/dist/ui/help.js.map +1 -0
- package/dist/ui/theme.d.ts +108 -0
- package/dist/ui/theme.js +261 -0
- package/dist/ui/theme.js.map +1 -0
- package/package.json +11 -9
- package/src/atomic-file.ts +86 -7
- package/src/client.test.ts +12 -0
- package/src/client.ts +72 -4
- package/src/commands.test.ts +971 -44
- package/src/commands.ts +1323 -337
- package/src/config-schema.test.ts +152 -0
- package/src/config-schema.ts +363 -0
- package/src/config.test.ts +6 -5
- package/src/config.ts +85 -16
- package/src/file-lock-process-worker.test.ts +64 -0
- package/src/file-lock.test.ts +279 -0
- package/src/file-lock.ts +318 -0
- package/src/harnesses.test.ts +48 -0
- package/src/harnesses.ts +59 -0
- package/src/hook-adapter.test.ts +187 -0
- package/src/hook-adapter.ts +212 -0
- package/src/hook-input.test.ts +39 -0
- package/src/hook-input.ts +72 -0
- package/src/hooks.test.ts +1318 -240
- package/src/hooks.ts +1046 -296
- package/src/install-hooks.test.ts +90 -41
- package/src/install-hooks.ts +259 -74
- package/src/interactive.ts +692 -0
- package/src/logging-process-worker.test.ts +39 -0
- package/src/logging.test.ts +453 -0
- package/src/logging.ts +639 -0
- package/src/main.ts +220 -48
- package/src/opencode-plugin.ts +15 -16
- package/src/session-end-log-lock-worker.test.ts +35 -0
- package/src/skill.test.ts +11 -0
- package/src/ui/banner.ts +95 -0
- package/src/ui/config-view.test.ts +88 -0
- package/src/ui/config-view.ts +138 -0
- package/src/ui/help.ts +124 -0
- package/src/ui/theme.test.ts +92 -0
- package/src/ui/theme.ts +279 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
BOOLEAN_CONFIG_KEYS,
|
|
4
|
+
CONFIG_KEYS,
|
|
5
|
+
NUMERIC_CONFIG_KEYS,
|
|
6
|
+
configBounds,
|
|
7
|
+
type ConfigKey,
|
|
8
|
+
} from './config.js'
|
|
9
|
+
import {
|
|
10
|
+
CONFIG_GROUPS,
|
|
11
|
+
acceptedValues,
|
|
12
|
+
configInfo,
|
|
13
|
+
configKeysByGroup,
|
|
14
|
+
describeSource,
|
|
15
|
+
formatDuration,
|
|
16
|
+
formatValue,
|
|
17
|
+
} from './config-schema.js'
|
|
18
|
+
|
|
19
|
+
describe('coverage', () => {
|
|
20
|
+
it('describes every configuration key', () => {
|
|
21
|
+
// The failure this prevents is silent: a key added to `config.ts` without
|
|
22
|
+
// an entry here still resolves, still applies, and still appears in
|
|
23
|
+
// `config show` — with no label, no summary and no way for the reader to
|
|
24
|
+
// find out what it does.
|
|
25
|
+
for (const key of CONFIG_KEYS) {
|
|
26
|
+
const info = configInfo(key)
|
|
27
|
+
expect(info.label, key).toBeTruthy()
|
|
28
|
+
expect(info.summary, key).toBeTruthy()
|
|
29
|
+
expect(info.detail, key).toBeTruthy()
|
|
30
|
+
expect(info.detail.length, key).toBeGreaterThan(info.summary.length)
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('files every key under exactly one declared group', () => {
|
|
35
|
+
const grouped = CONFIG_GROUPS.flatMap((group) => configKeysByGroup(group.id).map((info) => info.key))
|
|
36
|
+
expect([...grouped].sort()).toEqual([...CONFIG_KEYS].sort())
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('keeps summaries short enough to sit beside a value', () => {
|
|
40
|
+
for (const key of CONFIG_KEYS) {
|
|
41
|
+
expect(configInfo(key).summary.length, key).toBeLessThanOrEqual(80)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('agrees with config.ts about which keys are numbers and toggles', () => {
|
|
46
|
+
// Two sources of truth for a key's type would let the prompt offer a text
|
|
47
|
+
// box for something `config set` will only accept as `true` or `false`.
|
|
48
|
+
for (const key of NUMERIC_CONFIG_KEYS) expect(configInfo(key).kind, key).toBe('integer')
|
|
49
|
+
for (const key of BOOLEAN_CONFIG_KEYS) expect(configInfo(key).kind, key).toBe('boolean')
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('offers choices for every enum key', () => {
|
|
53
|
+
for (const key of CONFIG_KEYS) {
|
|
54
|
+
const info = configInfo(key)
|
|
55
|
+
if (info.kind !== 'enum') continue
|
|
56
|
+
expect(info.choices, key).toBeDefined()
|
|
57
|
+
expect(info.choices!.length, key).toBeGreaterThan(1)
|
|
58
|
+
for (const choice of info.choices!) expect(info.choiceHints?.[choice], `${key}.${choice}`).toBeTruthy()
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
describe('acceptedValues', () => {
|
|
64
|
+
it('states the range for a bounded number', () => {
|
|
65
|
+
const bounds = configBounds('ask_grace_seconds')!
|
|
66
|
+
expect(acceptedValues('ask_grace_seconds')).toBe(
|
|
67
|
+
`a whole number from ${bounds.min}s–${bounds.max}s`,
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('lists the choices for an enum', () => {
|
|
72
|
+
expect(acceptedValues('sound')).toContain('none')
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('names both values for a toggle', () => {
|
|
76
|
+
expect(acceptedValues('require_idle')).toBe('true or false')
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
describe('formatValue', () => {
|
|
81
|
+
it('renders toggles as words rather than JSON', () => {
|
|
82
|
+
expect(formatValue('require_idle', true)).toBe('yes')
|
|
83
|
+
expect(formatValue('require_idle', false)).toBe('no')
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('explains what an unset value means instead of printing null', () => {
|
|
87
|
+
// `sound = null` is accurate and tells the reader nothing about what will
|
|
88
|
+
// happen; the whole complaint about the old output in one line.
|
|
89
|
+
expect(formatValue('sound', null)).toBe('each notification uses the sound for its kind')
|
|
90
|
+
expect(formatValue('devices', null)).toBe('every device that can receive')
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('renders durations in units a person reads', () => {
|
|
94
|
+
expect(formatValue('ask_grace_seconds', 300)).toBe('5m')
|
|
95
|
+
expect(formatValue('ttl_seconds', 86400)).toBe('1d')
|
|
96
|
+
expect(formatValue('wait_seconds', 10)).toBe('10s')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('joins a device list', () => {
|
|
100
|
+
expect(formatValue('devices', ['dev_a', 'dev_b'])).toBe('dev_a, dev_b')
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
describe('formatDuration', () => {
|
|
105
|
+
it('keeps exact values readable across scales', () => {
|
|
106
|
+
expect(formatDuration(0, 's')).toBe('0s (immediately)')
|
|
107
|
+
expect(formatDuration(45, 's')).toBe('45s')
|
|
108
|
+
expect(formatDuration(120, 's')).toBe('2m')
|
|
109
|
+
expect(formatDuration(3600, 's')).toBe('1h')
|
|
110
|
+
expect(formatDuration(90, 's')).toBe('1m 30s')
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
describe('describeSource', () => {
|
|
115
|
+
it('turns a tagged path into words plus the file', () => {
|
|
116
|
+
expect(describeSource('default')).toEqual({ label: 'default', path: null })
|
|
117
|
+
expect(describeSource('global:/home/me/.config/notifai/config.toml')).toEqual({
|
|
118
|
+
label: 'this machine',
|
|
119
|
+
path: '/home/me/.config/notifai/config.toml',
|
|
120
|
+
})
|
|
121
|
+
expect(describeSource('project:/repo/.notifai/config.toml').label).toBe('this project (shared)')
|
|
122
|
+
expect(describeSource('project-local:/repo/.notifai/config.local.toml').label).toBe(
|
|
123
|
+
'this project (personal)',
|
|
124
|
+
)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it('does not invent a label for an unrecognised layer', () => {
|
|
128
|
+
expect(describeSource('future-layer:/tmp/x').label).toBe('future-layer')
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
describe('examples', () => {
|
|
133
|
+
it('suggests a value `config set` would actually accept', () => {
|
|
134
|
+
// The explain screen prints `notifai config set <key> <example>` as a
|
|
135
|
+
// copyable line, so an example that fails validation is worse than none.
|
|
136
|
+
for (const key of CONFIG_KEYS as readonly ConfigKey[]) {
|
|
137
|
+
const info = configInfo(key)
|
|
138
|
+
if (info.example === undefined) continue
|
|
139
|
+
if (info.kind === 'integer') {
|
|
140
|
+
const bounds = configBounds(key)
|
|
141
|
+
const parsed = Number(info.example)
|
|
142
|
+
expect(Number.isInteger(parsed), key).toBe(true)
|
|
143
|
+
if (bounds) {
|
|
144
|
+
expect(parsed, key).toBeGreaterThanOrEqual(bounds.min)
|
|
145
|
+
expect(parsed, key).toBeLessThanOrEqual(bounds.max)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (info.kind === 'boolean') expect(['true', 'false']).toContain(info.example)
|
|
149
|
+
if (info.kind === 'enum') expect(info.choices).toContain(info.example)
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
})
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every configuration key means, in the reader's words.
|
|
3
|
+
*
|
|
4
|
+
* `config.ts` already documented all fourteen keys carefully — but in TypeScript
|
|
5
|
+
* comments, which is the one audience that never needed them. Someone running
|
|
6
|
+
* `notifai config show` saw `require_idle = true` and had no way to learn what
|
|
7
|
+
* it did short of reading the source, so this module is that knowledge moved to
|
|
8
|
+
* where it can be printed.
|
|
9
|
+
*
|
|
10
|
+
* It is the single source for `config show`, `config set`'s errors, `config
|
|
11
|
+
* explain`, the help footer, and the interactive settings screen. One
|
|
12
|
+
* description, rendered five ways, so the surfaces cannot disagree.
|
|
13
|
+
*
|
|
14
|
+
* `summary` is the one-line form that fits beside a value in a list.
|
|
15
|
+
* `detail` is the paragraph shown once the reader has asked for this key
|
|
16
|
+
* specifically — progressive disclosure, so a list of fourteen settings stays
|
|
17
|
+
* a list and not an essay.
|
|
18
|
+
*/
|
|
19
|
+
import { CLI_SOUNDS, INTERRUPTION_LEVELS } from '@raidiant/notifai-protocol'
|
|
20
|
+
import { LOG_LEVELS, configBounds, type ConfigKey } from './config.js'
|
|
21
|
+
|
|
22
|
+
export type ConfigKind = 'string' | 'url' | 'integer' | 'boolean' | 'enum' | 'list'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Which surface a key belongs to. Grouping is the difference between fourteen
|
|
26
|
+
* flat keys and four short lists a reader can hold in their head.
|
|
27
|
+
*/
|
|
28
|
+
export type ConfigGroup = 'questions' | 'delivery' | 'project' | 'diagnostics' | 'connection'
|
|
29
|
+
|
|
30
|
+
export const CONFIG_GROUPS: { id: ConfigGroup; title: string; blurb: string }[] = [
|
|
31
|
+
{
|
|
32
|
+
id: 'questions',
|
|
33
|
+
title: 'Questions & presence',
|
|
34
|
+
blurb: 'When a question an agent registered is allowed to leave this terminal and reach your devices.',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'delivery',
|
|
38
|
+
title: 'Delivery defaults',
|
|
39
|
+
blurb: 'What a notification looks and behaves like when a command does not say otherwise.',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'project',
|
|
43
|
+
title: 'This project',
|
|
44
|
+
blurb: 'How work in this directory identifies itself, and the house rules agents read before notifying.',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'diagnostics',
|
|
48
|
+
title: 'Local logs',
|
|
49
|
+
blurb: 'What this machine records about its own activity, so an agent can find out afterwards what happened.',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 'connection',
|
|
53
|
+
title: 'Connection',
|
|
54
|
+
blurb: 'Which Notifai service this machine talks to. Most people never change this.',
|
|
55
|
+
},
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
export interface ConfigKeyInfo {
|
|
59
|
+
key: ConfigKey
|
|
60
|
+
/** Human words for the key, used as a list label. */
|
|
61
|
+
label: string
|
|
62
|
+
group: ConfigGroup
|
|
63
|
+
kind: ConfigKind
|
|
64
|
+
/** One line. Must fit beside a value without wrapping on an 80-column terminal. */
|
|
65
|
+
summary: string
|
|
66
|
+
/** The full explanation, shown when the reader asks about this key. */
|
|
67
|
+
detail: string
|
|
68
|
+
/** Allowed values for `enum`. */
|
|
69
|
+
choices?: readonly string[]
|
|
70
|
+
/** What a choice means, keyed by choice. */
|
|
71
|
+
choiceHints?: Record<string, string>
|
|
72
|
+
/** Unit suffix rendered after numbers, e.g. `s`. */
|
|
73
|
+
unit?: string
|
|
74
|
+
/** What the key means when it holds no value. */
|
|
75
|
+
unsetMeans?: string
|
|
76
|
+
/** A valid value, for error messages and placeholders. */
|
|
77
|
+
example?: string
|
|
78
|
+
/**
|
|
79
|
+
* Advanced keys are hidden behind an explicit reveal in the interactive
|
|
80
|
+
* settings screen. They are still listed by `config show` — hiding a value
|
|
81
|
+
* that is in force would be worse than showing one nobody needs.
|
|
82
|
+
*/
|
|
83
|
+
advanced?: boolean
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const INFO: Record<ConfigKey, Omit<ConfigKeyInfo, 'key'>> = {
|
|
87
|
+
ask_notifications: {
|
|
88
|
+
label: 'Send questions to my devices',
|
|
89
|
+
group: 'questions',
|
|
90
|
+
kind: 'boolean',
|
|
91
|
+
summary: 'Whether a registered question may reach your phone and Mac at all',
|
|
92
|
+
detail:
|
|
93
|
+
'The master switch for question routing. When this is off, a question an agent registers with `notifai ask` stays in the terminal and never leaves this machine, whatever the presence settings say. Turn it off to stop being reached for a while without uninstalling the harness hooks.',
|
|
94
|
+
example: 'true',
|
|
95
|
+
},
|
|
96
|
+
require_idle: {
|
|
97
|
+
label: 'Only when I have stepped away',
|
|
98
|
+
group: 'questions',
|
|
99
|
+
kind: 'boolean',
|
|
100
|
+
summary: 'Whether sitting at this keyboard holds a question back',
|
|
101
|
+
detail:
|
|
102
|
+
'Off (the default) means notify me even while I am using this machine. `ask_grace_seconds` still runs, so the terminal is offered the question first; I just do not need to walk away before it may leave. Turn this on when local keyboard or mouse activity should keep questions in the terminal.\n\nThis is separate from `ask_notifications`, which switches routing off altogether: wanting to be reached only while away is different from not wanting to be reached.',
|
|
103
|
+
example: 'false',
|
|
104
|
+
},
|
|
105
|
+
away_after_seconds: {
|
|
106
|
+
label: 'Away after',
|
|
107
|
+
group: 'questions',
|
|
108
|
+
kind: 'integer',
|
|
109
|
+
unit: 's',
|
|
110
|
+
summary: 'Keyboard and mouse idle time before this machine counts as unattended',
|
|
111
|
+
detail:
|
|
112
|
+
'How long the keyboard and mouse must be quiet before you count as away. Only consulted while `require_idle` is on.\n\nWhere the operating system exposes no idle signal, silence since your last prompt is used instead, which is the conservative reading.',
|
|
113
|
+
example: '120',
|
|
114
|
+
},
|
|
115
|
+
ask_grace_seconds: {
|
|
116
|
+
label: 'Terminal-first grace',
|
|
117
|
+
group: 'questions',
|
|
118
|
+
kind: 'integer',
|
|
119
|
+
unit: 's',
|
|
120
|
+
summary: 'Optional delay before a question may reach your devices',
|
|
121
|
+
detail:
|
|
122
|
+
'Zero (the default) sends the question to your devices as soon as the agent turn ends. Set a positive duration to offer the terminal an exclusive answer window first; the timer is measured from the moment the agent asked.\n\nA timer and nothing more. It is honoured whether or not presence is consulted at all, because how long to wait and whether anyone is watching are separate questions, and answering one should not answer the other.',
|
|
123
|
+
example: '0',
|
|
124
|
+
},
|
|
125
|
+
hook_reply_timeout_seconds: {
|
|
126
|
+
label: 'Hook wait for an answer',
|
|
127
|
+
group: 'questions',
|
|
128
|
+
kind: 'integer',
|
|
129
|
+
unit: 's',
|
|
130
|
+
summary: 'How long the harness hook blocks waiting for your answer',
|
|
131
|
+
detail:
|
|
132
|
+
'After a question has gone out, the harness continuation owner waits up to this long for your answer. The device reply window uses the same bound, so Notifai never accepts an answer after an agent with no dormant-session wake has already returned.\n\nThe ceiling exists because command-hook harnesses bound their Stop processes. Grace plus this value plus installer headroom stays inside that budget.',
|
|
133
|
+
example: '480',
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
sound: {
|
|
137
|
+
label: 'Sound',
|
|
138
|
+
group: 'delivery',
|
|
139
|
+
kind: 'enum',
|
|
140
|
+
choices: CLI_SOUNDS,
|
|
141
|
+
choiceHints: {
|
|
142
|
+
default: 'the standard notification tone',
|
|
143
|
+
done: 'the completion chime',
|
|
144
|
+
attention: 'used for questions that want an answer',
|
|
145
|
+
alert: 'the most insistent tone',
|
|
146
|
+
none: 'silent — arrives without a sound',
|
|
147
|
+
},
|
|
148
|
+
summary: 'Override the sound every notification uses',
|
|
149
|
+
detail:
|
|
150
|
+
'Normally the sound comes from what the notification is: progress updates are silent, completions get the done chime, questions get the attention tone. Setting this pins one sound for everything sent from here, overriding those profiles.\n\nA common use is `none`, to make a noisy project completely silent.',
|
|
151
|
+
unsetMeans: 'each notification uses the sound for its kind',
|
|
152
|
+
},
|
|
153
|
+
interruption_level: {
|
|
154
|
+
label: 'Interruption level',
|
|
155
|
+
group: 'delivery',
|
|
156
|
+
kind: 'enum',
|
|
157
|
+
choices: INTERRUPTION_LEVELS,
|
|
158
|
+
choiceHints: {
|
|
159
|
+
passive: 'no sound or wake — waits in the notification list',
|
|
160
|
+
active: 'wakes the screen and plays the sound',
|
|
161
|
+
time_sensitive: 'may break through Focus modes',
|
|
162
|
+
},
|
|
163
|
+
summary: 'Override how insistently notifications arrive',
|
|
164
|
+
detail:
|
|
165
|
+
'How hard a notification tries to reach you, in the operating system\'s terms. Like the sound, this is normally decided by what the notification is; setting it pins one level for everything.\n\n`time_sensitive` can pierce a Focus mode, so it is worth reserving for the cases that genuinely earn it.',
|
|
166
|
+
unsetMeans: 'each notification uses the level for its kind',
|
|
167
|
+
},
|
|
168
|
+
devices: {
|
|
169
|
+
label: 'Default devices',
|
|
170
|
+
group: 'delivery',
|
|
171
|
+
kind: 'list',
|
|
172
|
+
summary: 'Which of your devices receive by default',
|
|
173
|
+
detail:
|
|
174
|
+
'A comma-separated list of device ids. When set, notifications go only to these devices unless a command overrides it.\n\nRun `notifai devices` to see the ids and which of them can currently receive.',
|
|
175
|
+
unsetMeans: 'every device that can receive',
|
|
176
|
+
example: 'dev_abc123,dev_def456',
|
|
177
|
+
},
|
|
178
|
+
ttl_seconds: {
|
|
179
|
+
label: 'Delivery window',
|
|
180
|
+
group: 'delivery',
|
|
181
|
+
kind: 'integer',
|
|
182
|
+
unit: 's',
|
|
183
|
+
summary: 'How long the service keeps trying to deliver before giving up',
|
|
184
|
+
detail:
|
|
185
|
+
'A notification for a device that is off or offline is held for this long and delivered when the device reappears. After it lapses the notification is dropped rather than arriving stale.\n\nThe default of 86400 is one day.',
|
|
186
|
+
example: '86400',
|
|
187
|
+
},
|
|
188
|
+
wait_seconds: {
|
|
189
|
+
label: 'Wait for outcomes',
|
|
190
|
+
group: 'delivery',
|
|
191
|
+
kind: 'integer',
|
|
192
|
+
unit: 's',
|
|
193
|
+
summary: 'How long `send` waits to report what happened to a notification',
|
|
194
|
+
detail:
|
|
195
|
+
'After a notification is accepted, `notifai send` can wait for the delivery outcome so its exit code reflects what actually happened rather than only that the service took it.\n\nSet to 0 to return as soon as the service accepts, which is the fastest option and the one that tells you least.',
|
|
196
|
+
example: '10',
|
|
197
|
+
},
|
|
198
|
+
collapse_key: {
|
|
199
|
+
label: 'Collapse key',
|
|
200
|
+
group: 'delivery',
|
|
201
|
+
kind: 'string',
|
|
202
|
+
summary: 'Replace earlier notifications carrying the same key',
|
|
203
|
+
detail:
|
|
204
|
+
'Two notifications sharing a collapse key do not stack — the newer one replaces the older on the lock screen. This is how a status that changes repeatedly stays one line instead of becoming twenty.\n\nSetting it here applies one key to everything sent from here, which is usually too broad; most uses pass `--collapse-key` per send instead.',
|
|
205
|
+
unsetMeans: 'each notification stands on its own',
|
|
206
|
+
advanced: true,
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
project: {
|
|
210
|
+
label: 'Project id',
|
|
211
|
+
group: 'project',
|
|
212
|
+
kind: 'string',
|
|
213
|
+
summary: 'The name this project reports itself as',
|
|
214
|
+
detail:
|
|
215
|
+
'Stamped on every notification sent from this directory, and how the companion apps group and filter what arrives. Normally set once in `.notifai/config.toml` and committed, so everyone working on the repository reports the same name.',
|
|
216
|
+
unsetMeans: 'notifications arrive without a project',
|
|
217
|
+
example: 'my-app',
|
|
218
|
+
},
|
|
219
|
+
notify_criteria: {
|
|
220
|
+
label: 'House rules for agents',
|
|
221
|
+
group: 'project',
|
|
222
|
+
kind: 'string',
|
|
223
|
+
summary: 'Free text an agent reads before deciding whether to notify you',
|
|
224
|
+
detail:
|
|
225
|
+
'Your own guidance, in your own words, about what is worth a notification in this project — read by agents before they send. Something like "only tell me about failures and finished deploys; never per-file progress".\n\nIt is advice to the agent, not a filter the service enforces.',
|
|
226
|
+
unsetMeans: 'agents fall back to their default judgement',
|
|
227
|
+
example: 'Only failures and completed deploys',
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
log_level: {
|
|
231
|
+
label: 'Log level',
|
|
232
|
+
group: 'diagnostics',
|
|
233
|
+
kind: 'enum',
|
|
234
|
+
choices: LOG_LEVELS,
|
|
235
|
+
choiceHints: {
|
|
236
|
+
off: 'record nothing',
|
|
237
|
+
error: 'only failures',
|
|
238
|
+
info: 'commands, notifications, and every question decision',
|
|
239
|
+
debug: 'adds config resolution and per-request detail',
|
|
240
|
+
},
|
|
241
|
+
summary: 'How much this machine records about what it did',
|
|
242
|
+
detail:
|
|
243
|
+
'Notifai keeps a local record of what it did — every command, every notification, and in particular every decision a harness hook made about whether a question could leave the terminal. Hooks run headless, so without this there is no account of them at all: `notifai logs` is how an agent finds out afterwards why a question never reached your phone.\n\nThe log never leaves this machine. It is not uploaded, and nothing sends it anywhere.\n\n`debug` also records which config layer won and the detail of each request, which is what to turn on when something is behaving in a way the ordinary log does not explain.',
|
|
244
|
+
example: 'info',
|
|
245
|
+
},
|
|
246
|
+
log_max_bytes: {
|
|
247
|
+
label: 'Log file size',
|
|
248
|
+
group: 'diagnostics',
|
|
249
|
+
kind: 'integer',
|
|
250
|
+
summary: 'How large the log grows before it is rotated',
|
|
251
|
+
detail:
|
|
252
|
+
'When the active log reaches this size it is renamed aside and a fresh one starts. Together with the number of files kept, this is the whole disk budget: nothing here grows without a ceiling.',
|
|
253
|
+
advanced: true,
|
|
254
|
+
example: '2000000',
|
|
255
|
+
},
|
|
256
|
+
log_max_files: {
|
|
257
|
+
label: 'Log files kept',
|
|
258
|
+
group: 'diagnostics',
|
|
259
|
+
kind: 'integer',
|
|
260
|
+
summary: 'How many rotated log files are kept before the oldest is deleted',
|
|
261
|
+
detail:
|
|
262
|
+
'Counts the active file. At the defaults — three files of two megabytes — the logs occupy about six megabytes, which is weeks of ordinary agent traffic.\n\nRaise it when you need to look further back than the log currently reaches; lower it to one to keep only the file being written.',
|
|
263
|
+
advanced: true,
|
|
264
|
+
example: '3',
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
base_url: {
|
|
268
|
+
label: 'Service URL',
|
|
269
|
+
group: 'connection',
|
|
270
|
+
kind: 'url',
|
|
271
|
+
summary: 'Which Notifai service this machine talks to',
|
|
272
|
+
detail:
|
|
273
|
+
'Points the CLI at a Notifai service. The default is the hosted service, and signing in stores the URL the credential belongs to, so this rarely needs setting by hand.\n\nChanging it does not move your credential: a URL that does not match the one you paired against will not authenticate.',
|
|
274
|
+
advanced: true,
|
|
275
|
+
example: 'https://notifai.fly.dev',
|
|
276
|
+
},
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export function configInfo(key: ConfigKey): ConfigKeyInfo {
|
|
280
|
+
return { key, ...INFO[key] }
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Every key in its group, in the order a reader should meet them. */
|
|
284
|
+
export function configKeysByGroup(group: ConfigGroup): ConfigKeyInfo[] {
|
|
285
|
+
return (Object.keys(INFO) as ConfigKey[])
|
|
286
|
+
.filter((key) => INFO[key].group === group)
|
|
287
|
+
.map((key) => configInfo(key))
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/** Bounds rendered the way an error message wants them, or null. */
|
|
291
|
+
export function boundsHint(key: ConfigKey): string | null {
|
|
292
|
+
const bounds = configBounds(key)
|
|
293
|
+
if (bounds === undefined) return null
|
|
294
|
+
const info = INFO[key]
|
|
295
|
+
const unit = info.unit ?? ''
|
|
296
|
+
return `${bounds.min}${unit}–${bounds.max}${unit}`
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** What a `config set` caller may legally pass, phrased for an error message. */
|
|
300
|
+
export function acceptedValues(key: ConfigKey): string {
|
|
301
|
+
const info = INFO[key]
|
|
302
|
+
switch (info.kind) {
|
|
303
|
+
case 'boolean':
|
|
304
|
+
return 'true or false'
|
|
305
|
+
case 'enum':
|
|
306
|
+
return (info.choices ?? []).join(', ')
|
|
307
|
+
case 'integer': {
|
|
308
|
+
const bounds = boundsHint(key)
|
|
309
|
+
return bounds === null ? 'a whole number' : `a whole number from ${bounds}`
|
|
310
|
+
}
|
|
311
|
+
case 'list':
|
|
312
|
+
return 'a comma-separated list'
|
|
313
|
+
case 'url':
|
|
314
|
+
return 'a URL'
|
|
315
|
+
case 'string':
|
|
316
|
+
return 'any text'
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** How a resolved value should read in a list. */
|
|
321
|
+
export function formatValue(key: ConfigKey, value: unknown): string {
|
|
322
|
+
const info = INFO[key]
|
|
323
|
+
if (value === null || value === undefined) return info.unsetMeans ?? 'not set'
|
|
324
|
+
if (Array.isArray(value)) return value.length === 0 ? (info.unsetMeans ?? 'not set') : value.join(', ')
|
|
325
|
+
if (typeof value === 'boolean') return value ? 'yes' : 'no'
|
|
326
|
+
if (typeof value === 'number' && info.unit !== undefined) return formatDuration(value, info.unit)
|
|
327
|
+
return String(value)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Where a value came from, in words rather than in a tagged path.
|
|
332
|
+
*
|
|
333
|
+
* `global:/Users/you/.config/notifai/config.toml` answers "which file" but not
|
|
334
|
+
* "why is this the value" — and the second question is the one someone reading
|
|
335
|
+
* `config show` is actually asking. The path is still available for anyone
|
|
336
|
+
* about to edit the file; it is just no longer the whole answer.
|
|
337
|
+
*/
|
|
338
|
+
export function describeSource(source: string): { label: string; path: string | null } {
|
|
339
|
+
if (source === 'default') return { label: 'default', path: null }
|
|
340
|
+
if (source === 'flag') return { label: 'this command', path: null }
|
|
341
|
+
const separator = source.indexOf(':')
|
|
342
|
+
if (separator === -1) return { label: source, path: null }
|
|
343
|
+
const layer = source.slice(0, separator)
|
|
344
|
+
const filePath = source.slice(separator + 1)
|
|
345
|
+
const labels: Record<string, string> = {
|
|
346
|
+
session: 'this session',
|
|
347
|
+
'project-local': 'this project (personal)',
|
|
348
|
+
project: 'this project (shared)',
|
|
349
|
+
global: 'this machine',
|
|
350
|
+
}
|
|
351
|
+
return { label: labels[layer] ?? layer, path: filePath === '' ? null : filePath }
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** Seconds as something a person reads: `300s` is true, `5m` is legible. */
|
|
355
|
+
export function formatDuration(value: number, unit: string): string {
|
|
356
|
+
if (unit !== 's') return `${value}${unit}`
|
|
357
|
+
if (value === 0) return '0s (immediately)'
|
|
358
|
+
if (value < 60) return `${value}s`
|
|
359
|
+
if (value % 86400 === 0) return `${value / 86400}d`
|
|
360
|
+
if (value % 3600 === 0) return `${value / 3600}h`
|
|
361
|
+
if (value % 60 === 0) return `${value / 60}m`
|
|
362
|
+
return `${Math.floor(value / 60)}m ${value % 60}s`
|
|
363
|
+
}
|
package/src/config.test.ts
CHANGED
|
@@ -88,15 +88,16 @@ describe('harness config layers', () => {
|
|
|
88
88
|
expect(loadConfig({ cwd, env, sessionId: 'a/b' }).away_after_seconds.value).toBe(120)
|
|
89
89
|
})
|
|
90
90
|
|
|
91
|
-
it('defaults
|
|
91
|
+
it('defaults question routing to on without requiring the user to be idle', () => {
|
|
92
92
|
const { env, cwd } = setup({})
|
|
93
93
|
const config = loadConfig({ cwd, env })
|
|
94
94
|
expect(config.ask_notifications.value).toBe(true)
|
|
95
|
+
expect(config.require_idle).toEqual({ value: false, source: 'default' })
|
|
95
96
|
expect(config.away_after_seconds.value).toBe(120)
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
expect(config.hook_reply_timeout_seconds.value).toBe(
|
|
99
|
-
expect(config.ask_grace_seconds
|
|
97
|
+
// Immediate escalation by default leaves the whole hook budget available
|
|
98
|
+
// for the reply wait. Users can still opt into a terminal-first grace.
|
|
99
|
+
expect(config.hook_reply_timeout_seconds.value).toBe(480)
|
|
100
|
+
expect(config.ask_grace_seconds).toEqual({ value: 0, source: 'default' })
|
|
100
101
|
})
|
|
101
102
|
})
|
|
102
103
|
|