noguard 1.1.0 → 1.1.1

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/bin/noguard.mjs CHANGED
@@ -1,216 +1,233 @@
1
- #!/usr/bin/env node
2
-
3
- const VERSION = '1.1.0'
4
- const HELP = `
5
- \x1b[1mNoGuard AI CLI v${VERSION}\x1b[0m
6
- The AI that doesn't say no — in your terminal, working on your project.
7
-
8
- Run \x1b[1mnoguard\x1b[0m inside a project folder. NoGuard can read, search and edit its files
9
- and run commands there, asking you before it changes anything.
10
-
11
- \x1b[1mUsage:\x1b[0m
12
- noguard Start a session in the current folder
13
- noguard "task" Start a session with a first message
14
- noguard -p "task" Do one task and print the result (no prompts; pipe input works too)
15
- noguard login Sign in with your NoGuard account
16
- noguard logout Sign out and revoke the token
17
- noguard me Show your account and credits
18
- noguard models List available models with tiers and pricing
19
- noguard usage [--days N] Show credit usage history
20
- noguard config Show config file location
21
- noguard endpoint [URL] Show or set the API endpoint
22
-
23
- \x1b[1mOptions:\x1b[0m
24
- --model, -m <name> Choose a model (alias or name, e.g. noguard-ultra)
25
- --print, -p Print mode: run one task and exit
26
- --accept-edits Let NoGuard edit files without asking (still asks before commands)
27
- --yolo Let NoGuard edit files and run commands without asking
28
- --no-tools Chat only: NoGuard can't see or change files
29
- --help, -h Show this help
30
- --version, -v Show version
31
-
32
- \x1b[1mIn-session commands:\x1b[0m
33
- /models, /model <name> List models, switch model
34
- /mode [ask|accept-edits|yolo] Show or change what needs your approval
35
- /init Write a NOGUARD.md describing this project
36
- /compact Free context by dropping old tool output
37
- /libraries, /library <id> Research libraries
38
- /clear Start a new conversation
39
- /credits Show remaining credits
40
- /help, /exit
41
-
42
- \x1b[1mProject instructions:\x1b[0m
43
- NoGuard reads NOGUARD.md (and CLAUDE.md or AGENTS.md) from the project folder and
44
- its parents, and ~/.noguard/NOGUARD.md, at the start of each session.
45
- `
46
-
47
- const COMMANDS = new Set(['login', 'logout', 'me', 'models', 'usage', 'config', 'endpoint', 'chat'])
48
- const VALUE_FLAGS = new Set(['--model', '-m', '--days'])
49
-
50
- function parseArgs(argv) {
51
- const flags = new Set()
52
- const values = {}
53
- const positional = []
54
- for (let i = 0; i < argv.length; i++) {
55
- const arg = argv[i]
56
- if (VALUE_FLAGS.has(arg)) values[arg] = argv[++i]
57
- else if (arg.startsWith('-') && arg.length > 1) flags.add(arg)
58
- else positional.push(arg)
59
- }
60
- return { flags, values, positional }
61
- }
62
-
63
- /** Piped input. With a typed task too, an open stdin that sends nothing (scripts, CI) is not waited on. */
64
- function readStdin(optional) {
65
- if (process.stdin.isTTY) return Promise.resolve('')
66
- return new Promise(resolve => {
67
- const chunks = []
68
- const done = () => { clearTimeout(idle); process.stdin.destroy(); resolve(Buffer.concat(chunks).toString('utf8')) }
69
- const idle = optional ? setTimeout(done, 500) : null
70
- process.stdin.on('data', chunk => { clearTimeout(idle); chunks.push(chunk) })
71
- process.stdin.on('end', done)
72
- process.stdin.on('error', done)
73
- })
74
- }
75
-
76
- async function main() {
77
- const args = process.argv.slice(2)
78
- const { flags, values, positional } = parseArgs(args)
79
- const command = COMMANDS.has(positional[0]) ? positional[0] : positional.length ? 'prompt' : undefined
80
-
81
- if (flags.has('--help') || flags.has('-h')) {
82
- console.log(HELP)
83
- return
84
- }
85
- if (flags.has('--version') || flags.has('-v')) {
86
- console.log(VERSION)
87
- return
88
- }
89
- const session = {
90
- model: values['--model'] ?? values['-m'],
91
- tools: !flags.has('--no-tools'),
92
- mode: flags.has('--yolo') || flags.has('--dangerously-skip-permissions') ? 'yolo' : flags.has('--accept-edits') ? 'accept-edits' : 'ask',
93
- }
94
- if (flags.has('-p') || flags.has('--print')) {
95
- const typed = (command === 'chat' ? positional.slice(1) : positional).join(' ')
96
- const piped = await readStdin(Boolean(typed))
97
- const prompt = [typed, piped.trim()].filter(Boolean).join('\n\n')
98
- if (!prompt) {
99
- console.error('\x1b[31m✗\x1b[0m Give a task: noguard -p "what to do" (or pipe text in).')
100
- process.exit(1)
101
- }
102
- const { runOnce } = await import('../lib/chat.mjs')
103
- await runOnce({ ...session, prompt })
104
- return
105
- }
106
-
107
- switch (command) {
108
- case 'login': {
109
- const { login } = await import('../lib/auth.mjs')
110
- await login()
111
- break
112
- }
113
- case 'logout': {
114
- const { logout } = await import('../lib/auth.mjs')
115
- await logout()
116
- break
117
- }
118
- case 'me': {
119
- const { getToken } = await import('../lib/config.mjs')
120
- const { get } = await import('../lib/api.mjs')
121
- if (!getToken()) { console.log('\x1b[31m✗\x1b[0m Not signed in. Run \x1b[1mnoguard login\x1b[0m first.'); return }
122
- try {
123
- const me = await get('/api/v1/me')
124
- console.log()
125
- console.log(` \x1b[1mAccount\x1b[0m`)
126
- console.log(` Email: ${me.email}`)
127
- console.log(` Tier: ${me.tier}`)
128
- console.log(` Verified: ${me.verified ? '\x1b[32myes\x1b[0m' : '\x1b[31mno\x1b[0m'}`)
129
- console.log(` Credits: \x1b[33m${me.credits}\x1b[0m (${me.available} available)`)
130
- console.log(` Token: ${me.token.name} (${me.token.uid})`)
131
- console.log()
132
- } catch (err) {
133
- if (err.status === 401) console.log('\x1b[31m✗\x1b[0m Session expired. Run \x1b[1mnoguard login\x1b[0m again.')
134
- else console.error(`\x1b[31m✗\x1b[0m ${err.message}`)
135
- }
136
- break
137
- }
138
- case 'models': {
139
- const { get } = await import('../lib/api.mjs')
140
- const { printModels } = await import('../lib/chat.mjs')
141
- try {
142
- const res = await get('/api/v1/models')
143
- printModels(res.data)
144
- } catch (err) {
145
- console.error(`\x1b[31m✗\x1b[0m ${err.message}`)
146
- }
147
- break
148
- }
149
- case 'usage': {
150
- const { getToken } = await import('../lib/config.mjs')
151
- const { get } = await import('../lib/api.mjs')
152
- if (!getToken()) { console.log('\x1b[31m✗\x1b[0m Not signed in. Run \x1b[1mnoguard login\x1b[0m first.'); return }
153
- const days = parseInt(values['--days'], 10) || 30
154
- try {
155
- const res = await get(`/api/v1/usage?days=${days}`)
156
- console.log()
157
- console.log(` \x1b[1mUsage (last ${res.days_covered} days)\x1b[0m`)
158
- if (res.by_day?.length) {
159
- for (const day of res.by_day) {
160
- console.log(` ${day.date} \x1b[33m${day.credits_spent}\x1b[0m credits ${day.requests} requests`)
161
- }
162
- } else {
163
- console.log(' \x1b[2mNo usage yet.\x1b[0m')
164
- }
165
- console.log()
166
- } catch (err) {
167
- if (err.status === 401) console.log('\x1b[31m✗\x1b[0m Session expired. Run \x1b[1mnoguard login\x1b[0m again.')
168
- else console.error(`\x1b[31m✗\x1b[0m ${err.message}`)
169
- }
170
- break
171
- }
172
- case 'config': {
173
- const { configPath, load } = await import('../lib/config.mjs')
174
- const cfg = load()
175
- console.log()
176
- console.log(` \x1b[1mConfig\x1b[0m`)
177
- console.log(` File: ${configPath()}`)
178
- console.log(` Endpoint: ${cfg.endpoint ?? 'https://noguard.ai'}`)
179
- console.log(` Signed: ${cfg.token ? '\x1b[32myes\x1b[0m' : '\x1b[31mno\x1b[0m'}`)
180
- if (cfg.account) console.log(` Account: ${cfg.account.email}`)
181
- console.log()
182
- break
183
- }
184
- case 'endpoint': {
185
- const sub = positional[1]
186
- if (sub) {
187
- const { setEndpoint } = await import('../lib/config.mjs')
188
- setEndpoint(sub)
189
- console.log(`\x1b[32m✓\x1b[0m Endpoint set to \x1b[1m${sub}\x1b[0m`)
190
- } else {
191
- const { getEndpoint } = await import('../lib/config.mjs')
192
- console.log(getEndpoint())
193
- }
194
- break
195
- }
196
- case 'prompt':
197
- case 'chat':
198
- case undefined: {
199
- const words = command === 'chat' ? positional.slice(1) : positional
200
- // A lone word is more likely a mistyped command than a task.
201
- if (command === 'prompt' && words.length === 1 && !/\s/.test(words[0])) {
202
- console.log(`\x1b[31m✗\x1b[0m Unknown command: ${words[0]}`)
203
- console.log(' Run \x1b[1mnoguard --help\x1b[0m for usage, or quote a task: noguard "fix the failing test"')
204
- process.exit(1)
205
- }
206
- const { chat } = await import('../lib/chat.mjs')
207
- await chat({ ...session, prompt: words.join(' ') || undefined })
208
- break
209
- }
210
- }
211
- }
212
-
213
- main().catch(err => {
214
- console.error(`\x1b[31m✗\x1b[0m ${err.message}`)
215
- process.exit(1)
216
- })
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ BOLD, RST, UNDERLINE,
5
+ NEON_CYAN, HOT_PINK, LIME, ORANGE, GOLD, SKY, BRIGHT_WHITE, SOFT_GRAY, DARK_GRAY,
6
+ gradient, NOGUARD_GRADIENT, sectionHeader,
7
+ } from '../lib/render.mjs'
8
+
9
+ const VERSION = '1.1.1'
10
+
11
+ function helpText() {
12
+ return `
13
+ ${gradient('NoGuard AI CLI', NOGUARD_GRADIENT)} ${SOFT_GRAY}v${VERSION}${RST}
14
+ ${SOFT_GRAY}The AI that doesn't say no — in your terminal, working on your project.${RST}
15
+
16
+ Run ${BRIGHT_WHITE}${BOLD}noguard${RST} inside a project folder. NoGuard can read, search and edit its files
17
+ and run commands there, asking you before it changes anything.
18
+
19
+ ${GOLD}${BOLD}Usage:${RST}
20
+ ${BRIGHT_WHITE}noguard${RST} ${SOFT_GRAY}Start a session in the current folder${RST}
21
+ ${BRIGHT_WHITE}noguard${RST} ${SKY}"task"${RST} ${SOFT_GRAY}Start a session with a first message${RST}
22
+ ${BRIGHT_WHITE}noguard${RST} ${NEON_CYAN}-p${RST} ${SKY}"task"${RST} ${SOFT_GRAY}Do one task and print the result (pipe input works too)${RST}
23
+ ${BRIGHT_WHITE}noguard login${RST} ${SOFT_GRAY}Sign in with your NoGuard account${RST}
24
+ ${BRIGHT_WHITE}noguard logout${RST} ${SOFT_GRAY}Sign out and revoke the token${RST}
25
+ ${BRIGHT_WHITE}noguard me${RST} ${SOFT_GRAY}Show your account and credits${RST}
26
+ ${BRIGHT_WHITE}noguard models${RST} ${SOFT_GRAY}List available models with tiers and pricing${RST}
27
+ ${BRIGHT_WHITE}noguard usage${RST} ${NEON_CYAN}[--days N]${RST} ${SOFT_GRAY}Show credit usage history${RST}
28
+ ${BRIGHT_WHITE}noguard config${RST} ${SOFT_GRAY}Show config file location${RST}
29
+ ${BRIGHT_WHITE}noguard endpoint${RST} ${SKY}[URL]${RST} ${SOFT_GRAY}Show or set the API endpoint${RST}
30
+
31
+ ${GOLD}${BOLD}Options:${RST}
32
+ ${NEON_CYAN}--model, -m${RST} ${SKY}<name>${RST} ${SOFT_GRAY}Choose a model (alias or name, e.g. noguard-ultra)${RST}
33
+ ${NEON_CYAN}--print, -p${RST} ${SOFT_GRAY}Print mode: run one task and exit${RST}
34
+ ${NEON_CYAN}--accept-edits${RST} ${SOFT_GRAY}Let NoGuard edit files without asking (still asks before commands)${RST}
35
+ ${NEON_CYAN}--yolo${RST} ${SOFT_GRAY}Let NoGuard edit files and run commands without asking${RST}
36
+ ${NEON_CYAN}--no-tools${RST} ${SOFT_GRAY}Chat only: NoGuard can't see or change files${RST}
37
+ ${NEON_CYAN}--help, -h${RST} ${SOFT_GRAY}Show this help${RST}
38
+ ${NEON_CYAN}--version, -v${RST} ${SOFT_GRAY}Show version${RST}
39
+
40
+ ${GOLD}${BOLD}In-session commands:${RST}
41
+ ${BRIGHT_WHITE}/models, /model <name>${RST} ${SOFT_GRAY}List models, switch model${RST}
42
+ ${BRIGHT_WHITE}/mode${RST} ${SKY}[ask|accept-edits|yolo]${RST} ${SOFT_GRAY}Show or change what needs your approval${RST}
43
+ ${BRIGHT_WHITE}/status${RST} ${SOFT_GRAY}Show session info, credits, model, and stats${RST}
44
+ ${BRIGHT_WHITE}/init${RST} ${SOFT_GRAY}Write a NOGUARD.md describing this project${RST}
45
+ ${BRIGHT_WHITE}/compact${RST} ${SOFT_GRAY}Free context by dropping old tool output${RST}
46
+ ${BRIGHT_WHITE}/libraries, /library <id>${RST} ${SOFT_GRAY}Research libraries${RST}
47
+ ${BRIGHT_WHITE}/clear${RST} ${SOFT_GRAY}Start a new conversation${RST}
48
+ ${BRIGHT_WHITE}/credits${RST} ${SOFT_GRAY}Show remaining credits${RST}
49
+ ${BRIGHT_WHITE}/help, /exit${RST}
50
+
51
+ ${GOLD}${BOLD}Project instructions:${RST}
52
+ NoGuard reads ${SKY}NOGUARD.md${RST} (and ${SKY}CLAUDE.md${RST} or ${SKY}AGENTS.md${RST}) from the project folder and
53
+ its parents, and ${SKY}~/.noguard/NOGUARD.md${RST}, at the start of each session.
54
+ `
55
+ }
56
+
57
+ const COMMANDS = new Set(['login', 'logout', 'me', 'models', 'usage', 'config', 'endpoint', 'chat'])
58
+ const VALUE_FLAGS = new Set(['--model', '-m', '--days'])
59
+
60
+ function parseArgs(argv) {
61
+ const flags = new Set()
62
+ const values = {}
63
+ const positional = []
64
+ for (let i = 0; i < argv.length; i++) {
65
+ const arg = argv[i]
66
+ if (VALUE_FLAGS.has(arg)) values[arg] = argv[++i]
67
+ else if (arg.startsWith('-') && arg.length > 1) flags.add(arg)
68
+ else positional.push(arg)
69
+ }
70
+ return { flags, values, positional }
71
+ }
72
+
73
+ /** Piped input. With a typed task too, an open stdin that sends nothing (scripts, CI) is not waited on. */
74
+ function readStdin(optional) {
75
+ if (process.stdin.isTTY) return Promise.resolve('')
76
+ return new Promise(resolve => {
77
+ const chunks = []
78
+ const done = () => { clearTimeout(idle); process.stdin.destroy(); resolve(Buffer.concat(chunks).toString('utf8')) }
79
+ const idle = optional ? setTimeout(done, 500) : null
80
+ process.stdin.on('data', chunk => { clearTimeout(idle); chunks.push(chunk) })
81
+ process.stdin.on('end', done)
82
+ process.stdin.on('error', done)
83
+ })
84
+ }
85
+
86
+ function fmtNumber(n) {
87
+ return Number(n).toLocaleString('en-US')
88
+ }
89
+
90
+ async function main() {
91
+ const args = process.argv.slice(2)
92
+ const { flags, values, positional } = parseArgs(args)
93
+ const command = COMMANDS.has(positional[0]) ? positional[0] : positional.length ? 'prompt' : undefined
94
+
95
+ if (flags.has('--help') || flags.has('-h')) {
96
+ console.log(helpText())
97
+ return
98
+ }
99
+ if (flags.has('--version') || flags.has('-v')) {
100
+ console.log(`${gradient('NoGuard', NOGUARD_GRADIENT)} ${SOFT_GRAY}v${VERSION}${RST}`)
101
+ return
102
+ }
103
+ const session = {
104
+ model: values['--model'] ?? values['-m'],
105
+ tools: !flags.has('--no-tools'),
106
+ mode: flags.has('--yolo') || flags.has('--dangerously-skip-permissions') ? 'yolo' : flags.has('--accept-edits') ? 'accept-edits' : 'ask',
107
+ }
108
+ if (flags.has('-p') || flags.has('--print')) {
109
+ const typed = (command === 'chat' ? positional.slice(1) : positional).join(' ')
110
+ const piped = await readStdin(Boolean(typed))
111
+ const prompt = [typed, piped.trim()].filter(Boolean).join('\n\n')
112
+ if (!prompt) {
113
+ console.error(`${HOT_PINK}✗${RST} Give a task: ${BRIGHT_WHITE}noguard -p "what to do"${RST} (or pipe text in).`)
114
+ process.exit(1)
115
+ }
116
+ const { runOnce } = await import('../lib/chat.mjs')
117
+ await runOnce({ ...session, prompt })
118
+ return
119
+ }
120
+
121
+ switch (command) {
122
+ case 'login': {
123
+ const { login } = await import('../lib/auth.mjs')
124
+ await login()
125
+ break
126
+ }
127
+ case 'logout': {
128
+ const { logout } = await import('../lib/auth.mjs')
129
+ await logout()
130
+ break
131
+ }
132
+ case 'me': {
133
+ const { getToken } = await import('../lib/config.mjs')
134
+ const { get } = await import('../lib/api.mjs')
135
+ if (!getToken()) { console.log(`${HOT_PINK}✗${RST} Not signed in. Run ${BOLD}noguard login${RST} first.`); return }
136
+ try {
137
+ const me = await get('/api/v1/me')
138
+ const tierColor = me.tier === 'ultra' ? GOLD : me.tier === 'pro' ? LIME : NEON_CYAN
139
+ console.log()
140
+ console.log(sectionHeader('Account'))
141
+ console.log()
142
+ console.log(` ${SOFT_GRAY}Email:${RST} ${BRIGHT_WHITE}${me.email}${RST}`)
143
+ console.log(` ${SOFT_GRAY}Tier:${RST} ${tierColor}${BOLD}${me.tier}${RST}`)
144
+ console.log(` ${SOFT_GRAY}Verified:${RST} ${me.verified ? `${LIME}yes${RST}` : `${HOT_PINK}no${RST}`}`)
145
+ console.log(` ${SOFT_GRAY}Credits:${RST} ${ORANGE}${BOLD}${fmtNumber(me.credits)}${RST} ${DARK_GRAY}(${fmtNumber(me.available)} available)${RST}`)
146
+ console.log(` ${SOFT_GRAY}Token:${RST} ${SKY}${me.token.name}${RST} ${DARK_GRAY}(${me.token.uid})${RST}`)
147
+ console.log()
148
+ } catch (err) {
149
+ if (err.status === 401) console.log(`${HOT_PINK}✗${RST} Session expired. Run ${BOLD}noguard login${RST} again.`)
150
+ else console.error(`${HOT_PINK}✗${RST} ${err.message}`)
151
+ }
152
+ break
153
+ }
154
+ case 'models': {
155
+ const { get } = await import('../lib/api.mjs')
156
+ const { printModels } = await import('../lib/chat.mjs')
157
+ try {
158
+ const res = await get('/api/v1/models')
159
+ printModels(res.data)
160
+ } catch (err) {
161
+ console.error(`${HOT_PINK}✗${RST} ${err.message}`)
162
+ }
163
+ break
164
+ }
165
+ case 'usage': {
166
+ const { getToken } = await import('../lib/config.mjs')
167
+ const { get } = await import('../lib/api.mjs')
168
+ if (!getToken()) { console.log(`${HOT_PINK}✗${RST} Not signed in. Run ${BOLD}noguard login${RST} first.`); return }
169
+ const days = parseInt(values['--days'], 10) || 30
170
+ try {
171
+ const res = await get(`/api/v1/usage?days=${days}`)
172
+ console.log()
173
+ console.log(sectionHeader(`Usage (last ${res.days_covered} days)`))
174
+ console.log()
175
+ if (res.by_day?.length) {
176
+ for (const day of res.by_day) {
177
+ console.log(` ${BRIGHT_WHITE}${day.date}${RST} ${ORANGE}${BOLD}${fmtNumber(day.credits_spent)}${RST} ${SOFT_GRAY}credits${RST} ${DARK_GRAY}${day.requests} requests${RST}`)
178
+ }
179
+ } else {
180
+ console.log(` ${SOFT_GRAY}No usage yet.${RST}`)
181
+ }
182
+ console.log()
183
+ } catch (err) {
184
+ if (err.status === 401) console.log(`${HOT_PINK}✗${RST} Session expired. Run ${BOLD}noguard login${RST} again.`)
185
+ else console.error(`${HOT_PINK}✗${RST} ${err.message}`)
186
+ }
187
+ break
188
+ }
189
+ case 'config': {
190
+ const { configPath, load } = await import('../lib/config.mjs')
191
+ const cfg = load()
192
+ console.log()
193
+ console.log(sectionHeader('Config'))
194
+ console.log()
195
+ console.log(` ${SOFT_GRAY}File:${RST} ${SKY}${configPath()}${RST}`)
196
+ console.log(` ${SOFT_GRAY}Endpoint:${RST} ${BRIGHT_WHITE}${cfg.endpoint ?? 'https://noguard.ai'}${RST}`)
197
+ console.log(` ${SOFT_GRAY}Signed:${RST} ${cfg.token ? `${LIME}yes${RST}` : `${HOT_PINK}no${RST}`}`)
198
+ if (cfg.account) console.log(` ${SOFT_GRAY}Account:${RST} ${BRIGHT_WHITE}${cfg.account.email}${RST}`)
199
+ console.log()
200
+ break
201
+ }
202
+ case 'endpoint': {
203
+ const sub = positional[1]
204
+ if (sub) {
205
+ const { setEndpoint } = await import('../lib/config.mjs')
206
+ setEndpoint(sub)
207
+ console.log(`${LIME}✓${RST} Endpoint set to ${BRIGHT_WHITE}${BOLD}${sub}${RST}`)
208
+ } else {
209
+ const { getEndpoint } = await import('../lib/config.mjs')
210
+ console.log(getEndpoint())
211
+ }
212
+ break
213
+ }
214
+ case 'prompt':
215
+ case 'chat':
216
+ case undefined: {
217
+ const words = command === 'chat' ? positional.slice(1) : positional
218
+ if (command === 'prompt' && words.length === 1 && !/\s/.test(words[0])) {
219
+ console.log(`${HOT_PINK}✗${RST} Unknown command: ${BRIGHT_WHITE}${words[0]}${RST}`)
220
+ console.log(` Run ${BRIGHT_WHITE}${BOLD}noguard --help${RST} for usage, or quote a task: ${BRIGHT_WHITE}noguard "fix the failing test"${RST}`)
221
+ process.exit(1)
222
+ }
223
+ const { chat } = await import('../lib/chat.mjs')
224
+ await chat({ ...session, prompt: words.join(' ') || undefined })
225
+ break
226
+ }
227
+ }
228
+ }
229
+
230
+ main().catch(err => {
231
+ console.error(`${HOT_PINK}✗${RST} ${err.message}`)
232
+ process.exit(1)
233
+ })
package/lib/agent.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  import { randomBytes, randomUUID } from 'node:crypto'
5
5
  import { ApiError, streamMessages } from './api.mjs'
6
6
  import { isInsideReal, resolvePath } from './files.mjs'
7
- import { clean, MarkdownStream, Spinner, toolHeader, toolResultLine, BOLD, CYAN, DIM, RED, RST, YELLOW } from './render.mjs'
7
+ import { clean, MarkdownStream, Spinner, toolHeader, toolResultLine, BOLD, DIM, RST, UNDERLINE, NEON_CYAN, HOT_PINK, LIME, ORANGE, BRIGHT_WHITE, SOFT_GRAY } from './render.mjs'
8
8
  import { systemPrompt } from './context.mjs'
9
9
  import { TOOLS_BY_NAME, toolDefinitions } from './tools.mjs'
10
10
 
@@ -183,10 +183,10 @@ export class Agent {
183
183
  }
184
184
  this.messages.push({ role: 'user', content: results })
185
185
  if (halt || this.controller.signal.aborted) {
186
- if (this.controller.signal.aborted) console.log(` ${DIM}⎿ Interrupted. Tell NoGuard what to do instead.${RST}`)
186
+ if (this.controller.signal.aborted) console.log(` ${SOFT_GRAY}⎿ Interrupted. Tell NoGuard what to do instead.${RST}`)
187
187
  break
188
188
  }
189
- if (step === MAX_STEPS - 1) console.log(`${YELLOW}⚠${RST} Stopped after ${MAX_STEPS} steps. Send a message to continue.`)
189
+ if (step === MAX_STEPS - 1) console.log(`${ORANGE}⚠${RST} Stopped after ${MAX_STEPS} steps. Send a message to continue.`)
190
190
  }
191
191
  } finally {
192
192
  this.spinner.stop()
@@ -270,7 +270,7 @@ export class Agent {
270
270
  await new Promise(r => setTimeout(r, 2000))
271
271
  continue
272
272
  }
273
- console.log(`${RED}✗${RST} Connection error: ${err.message}`)
273
+ console.log(`${HOT_PINK}✗${RST} Connection error: ${err.message}`)
274
274
  return { blocks: [], spent: 0, balance: null, stop: true, failed: true }
275
275
  }
276
276
  }
@@ -282,10 +282,10 @@ export class Agent {
282
282
  }
283
283
 
284
284
  #explain(err) {
285
- if (err.status === 401 || err.code === 'invalid_token') console.log(`${RED}✗${RST} Session expired. Run ${BOLD}noguard login${RST} again.`)
286
- else if (err.code === 'out_of_credits' || err.status === 402) console.log(`${YELLOW}⚠${RST} ${err.message}\n Top up at \x1b[4mhttps://noguard.ai/credits${RST}`)
287
- else if (err.code === 'model_unavailable') console.log(`${YELLOW}⚠${RST} ${err.message} Run /models to pick another.`)
288
- else console.log(`${RED}✗${RST} ${err.message}`)
285
+ if (err.status === 401 || err.code === 'invalid_token') console.log(`${HOT_PINK}✗${RST} Session expired. Run ${BOLD}noguard login${RST} again.`)
286
+ else if (err.code === 'out_of_credits' || err.status === 402) console.log(`${ORANGE}⚠${RST} ${err.message}\n Top up at ${NEON_CYAN}${UNDERLINE}https://noguard.ai/credits${RST}`)
287
+ else if (err.code === 'model_unavailable') console.log(`${ORANGE}⚠${RST} ${err.message} Run /models to pick another.`)
288
+ else console.log(`${HOT_PINK}✗${RST} ${err.message}`)
289
289
  return err.message
290
290
  }
291
291
 
@@ -367,7 +367,7 @@ export class Agent {
367
367
  finished.push(call)
368
368
  }
369
369
  if (streamError) {
370
- console.log(`${RED}✗${RST} ${streamError}`)
370
+ console.log(`${HOT_PINK}✗${RST} ${streamError}`)
371
371
  return { blocks: finished.filter(b => b.type === 'text'), spent, balance, stop: true, failed: true }
372
372
  }
373
373
  if (stopReason === 'max_tokens' && !finished.some(b => b.type === 'tool_use')) {
@@ -382,19 +382,19 @@ export class Agent {
382
382
  const fail = (message, extra = {}) => ({ result: { type: 'tool_result', tool_use_id: call.id, content: message, is_error: true }, ...extra })
383
383
  if (!tool) {
384
384
  console.log(toolHeader(call.name))
385
- console.log(toolResultLine(`Unknown tool`, RED))
385
+ console.log(toolResultLine(`Unknown tool`, HOT_PINK))
386
386
  return fail(`There is no tool named ${call.name}.`)
387
387
  }
388
388
  let label = ''
389
389
  try { label = tool.label(call.input, this.ctx) } catch { /* bad input shows no label */ }
390
390
  console.log(toolHeader(tool.name, label))
391
391
  if (call.parseError) {
392
- console.log(toolResultLine('Invalid arguments', RED))
392
+ console.log(toolResultLine('Invalid arguments', HOT_PINK))
393
393
  return fail(`The tool arguments were not valid JSON (${call.parseError}). The reply may have been cut off; try again with smaller input.`)
394
394
  }
395
395
  const missing = (tool.input_schema.required ?? []).filter(key => call.input[key] === undefined)
396
396
  if (missing.length) {
397
- console.log(toolResultLine(`Missing ${missing.join(', ')}`, RED))
397
+ console.log(toolResultLine(`Missing ${missing.join(', ')}`, HOT_PINK))
398
398
  return fail(`Missing required argument${missing.length > 1 ? 's' : ''}: ${missing.join(', ')}.`)
399
399
  }
400
400
  const reason = this.permissions.check(tool, call.input, this.cwd)
@@ -405,16 +405,16 @@ export class Agent {
405
405
  if (tool.kind === 'exec') {
406
406
  // The header may be shortened: show exactly what will run before asking.
407
407
  const command = clean(String(call.input.command ?? ''))
408
- if (command !== label) console.log(command.split('\n').map(line => ` ${CYAN}${line}${RST}`).join('\n'))
408
+ if (command !== label) console.log(command.split('\n').map(line => ` ${NEON_CYAN}${line}${RST}`).join('\n'))
409
409
  if (call.input.description) console.log(` ${DIM}${clean(String(call.input.description))}${RST}`)
410
410
  }
411
411
  const always = this.permissions.alwaysLabel(tool, call.input)
412
- const answer = await this.ui.ask(` ${YELLOW}?${RST} Allow NoGuard to ${reason}? ${BOLD}y${RST}es${always ? ` · ${BOLD}a${RST}lways (${always})` : ''} · ${BOLD}n${RST}o, or type what to do instead ${CYAN}›${RST} `)
412
+ const answer = await this.ui.ask(` ${ORANGE}?${RST} Allow NoGuard to ${reason}? ${LIME}y${RST}es${always ? ` · ${NEON_CYAN}a${RST}lways (${always})` : ''} · ${HOT_PINK}n${RST}o, or type what to do instead ${NEON_CYAN}›${RST} `)
413
413
  if (answer === null) {
414
414
  const why = this.ui.interactive
415
415
  ? 'Not run: the user interrupted.'
416
416
  : `Not run: this needs approval, and nobody can approve it in print mode. Rerun with --accept-edits or --yolo to allow it.`
417
- console.log(toolResultLine(this.ui.interactive ? 'Interrupted' : 'Needs approval (print mode)', YELLOW))
417
+ console.log(toolResultLine(this.ui.interactive ? 'Interrupted' : 'Needs approval (print mode)', ORANGE))
418
418
  return fail(why, { halt: true })
419
419
  }
420
420
  const reply = answer.trim()
@@ -423,7 +423,7 @@ export class Agent {
423
423
  if (always) this.permissions.alwaysAllow(tool, call.input)
424
424
  } else if (!(word === '' || word === 'y' || word === 'yes')) {
425
425
  const feedback = ['n', 'no'].includes(word) ? '' : reply
426
- console.log(toolResultLine('Denied', YELLOW))
426
+ console.log(toolResultLine('Denied', ORANGE))
427
427
  if (feedback) {
428
428
  return fail('The user denied this action.', { feedback: `The user denied that and said: ${feedback}` })
429
429
  }
@@ -439,7 +439,7 @@ export class Agent {
439
439
  }
440
440
  this.spinner.stop()
441
441
  if (outcome.error) {
442
- console.log(toolResultLine(clean(outcome.error), RED))
442
+ console.log(toolResultLine(clean(outcome.error), HOT_PINK))
443
443
  return fail(outcome.error)
444
444
  }
445
445
  if (outcome.display) console.log(toolResultLine(outcome.display))