@able-autonomy/able 0.2.0 → 0.2.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/able.ts +4 -3
- package/package.json +1 -1
- package/src/{bloat → audit/bloat}/apply.test.ts +1 -1
- package/src/{bloat → audit/bloat}/apply.ts +3 -3
- package/src/{bloat → audit/bloat}/blocks.ts +2 -2
- package/src/{bloat → audit/bloat}/checks.ts +3 -3
- package/src/{bloat → audit/bloat}/compare.ts +3 -3
- package/src/{bloat → audit/bloat}/findings.ts +3 -3
- package/src/{bloat → audit/bloat}/grid.ts +6 -6
- package/src/{bloat → audit/bloat}/index.ts +25 -25
- package/src/{bloat → audit/bloat}/load.ts +2 -2
- package/src/{bloat → audit/bloat}/picker.ts +1 -1
- package/src/{bloat → audit/bloat}/report.ts +2 -2
- package/src/{bloat → audit/bloat}/scan.ts +3 -3
- package/src/{bloat → audit/bloat}/show.ts +1 -1
- package/src/{bloat → audit/bloat}/steps.ts +2 -2
- package/src/{bloat → audit/bloat}/types.ts +4 -4
- package/src/audit/index.ts +19 -0
- package/src/workspaces/merge.ts +2 -2
- /package/src/{bloat → audit/bloat}/kinds.ts +0 -0
package/able.ts
CHANGED
|
@@ -90,6 +90,8 @@ async function installationToken(repo: string) {
|
|
|
90
90
|
return token as string
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
// The bloat diagnostic's names before `able audit bloat`, still accepted until #27: rewritten to it before anything runs.
|
|
94
|
+
if (process.argv[2] === 'bloat' || process.argv[2] === 'agents') process.argv.splice(2, 1, 'audit', 'bloat')
|
|
93
95
|
const [command, ...args] = process.argv.slice(2)
|
|
94
96
|
if (command === 'sync') {
|
|
95
97
|
await import('./sync.ts')
|
|
@@ -129,8 +131,7 @@ if (command === 'upgrade') {
|
|
|
129
131
|
process.exit(0)
|
|
130
132
|
}
|
|
131
133
|
const modules: Record<string, string> = {
|
|
132
|
-
|
|
133
|
-
agents: './src/bloat/index.ts',
|
|
134
|
+
audit: './src/audit/index.ts',
|
|
134
135
|
commit: './src/commit.ts',
|
|
135
136
|
init: './src/init.ts',
|
|
136
137
|
push: './src/push.ts',
|
|
@@ -154,7 +155,7 @@ if (delegate) {
|
|
|
154
155
|
}
|
|
155
156
|
if (command !== 'gh') {
|
|
156
157
|
console.error(
|
|
157
|
-
"usage: able gh <gh arguments> run gh as Able's GitHub App\n able sync [--dry-run] file follow-ups and write ended weeks' records\n able config [--json] print the host's able.config.ts\n able init [--list|--remove] sets this project up on this machine (WIP)\n able commit \"<message>\" [<path>…] a pathspec commit after the touched folders' checks\n able push pushes this branch with its tags\n able upgrade makes bunx run the latest published able\n able -v prints this able's version\n able ws <new|ls|current|refresh|merge|preview|rm|start|stop|status|take|build|attach> workspaces\n able bloat <status|scan|load|blocks|checks|classify|propose|report|show|pick|history> the bloat diagnostic: where each agent-file rule belongs",
|
|
158
|
+
"usage: able gh <gh arguments> run gh as Able's GitHub App\n able sync [--dry-run] file follow-ups and write ended weeks' records\n able config [--json] print the host's able.config.ts\n able init [--list|--remove] sets this project up on this machine (WIP)\n able commit \"<message>\" [<path>…] a pathspec commit after the touched folders' checks\n able push pushes this branch with its tags\n able upgrade makes bunx run the latest published able\n able -v prints this able's version\n able ws <new|ls|current|refresh|merge|preview|rm|start|stop|status|take|build|attach> workspaces\n able audit bloat <status|scan|load|blocks|checks|classify|propose|report|show|pick|history|apply|compare> the bloat diagnostic: where each agent-file rule belongs",
|
|
158
159
|
)
|
|
159
160
|
process.exit(command ? 1 : 0)
|
|
160
161
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ import { applyTally, lineage, pick, readReport, type Report } from './report.ts'
|
|
|
9
9
|
// Able's report of 18 Nov 14:49, copied so recording doesn't touch the journal, with picks of its own and nothing applied.
|
|
10
10
|
async function picked() {
|
|
11
11
|
const path = join(await mkdtemp(join(tmpdir(), 'able-apply-')), '2026-11-18-1449.json')
|
|
12
|
-
await copyFile(join(import.meta.dir, '
|
|
12
|
+
await copyFile(join(import.meta.dir, '../../../../journal/bloat/2026-11-18-1449.json'), path)
|
|
13
13
|
const report = readReport(path)
|
|
14
14
|
for (const r of report.rules) {
|
|
15
15
|
if (r.n) r.pick = r.n <= 4 ? 'yes' : r.n === 5 ? 'no' : undefined
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// so the next report can follow each rule to its new place (report.ts, lineage). Downloaded skills are never cut into
|
|
4
4
|
// blocks (blocks.ts), so no finding is ever in one.
|
|
5
5
|
|
|
6
|
-
import { dim } from '
|
|
6
|
+
import { dim } from '../../ui.ts'
|
|
7
7
|
import { kinds } from './kinds.ts'
|
|
8
8
|
import { applyTally, saveReport, type Report } from './report.ts'
|
|
9
9
|
import { findingLine } from './show.ts'
|
|
@@ -24,14 +24,14 @@ export const left = (report: Report) => ({ groups: todo(report), ...applyTally(r
|
|
|
24
24
|
export type Left = ReturnType<typeof left>
|
|
25
25
|
|
|
26
26
|
export function render({ groups, applied }: Left) {
|
|
27
|
-
if (!groups.length) return ` Nothing to apply: ${applied ? `all ${applied} yes picks are applied` : 'no yes picks yet (able bloat pick)'}.`
|
|
27
|
+
if (!groups.length) return ` Nothing to apply: ${applied ? `all ${applied} yes picks are applied` : 'no yes picks yet (able audit bloat pick)'}.`
|
|
28
28
|
const out: string[] = []
|
|
29
29
|
groups.forEach((g, i) => {
|
|
30
30
|
out.push(` ${i + 1}. ${kinds[g.kind].letter} ${g.kind.toUpperCase()} ${g.findings.length} ${dim(`→ ${kinds[g.kind].becomes}`)}`)
|
|
31
31
|
for (const r of g.findings) out.push(...findingLine(r))
|
|
32
32
|
out.push('')
|
|
33
33
|
})
|
|
34
|
-
out.push(dim(` One kind at a time, the host's commit checks after each. Then: able bloat apply --record <n> [<target>]`))
|
|
34
|
+
out.push(dim(` One kind at a time, the host's commit checks after each. Then: able audit bloat apply --record <n> [<target>]`))
|
|
35
35
|
return out.join('\n')
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -140,13 +140,13 @@ export function blocks(root: string, entries: Entry[]): Blocks {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
/** One line for `able bloat status`. */
|
|
143
|
+
/** One line for `able audit bloat status`. */
|
|
144
144
|
export function summary(b: Blocks) {
|
|
145
145
|
const files = new Set(b.blocks.map((x) => x.path)).size
|
|
146
146
|
return `${b.blocks.length} blocks in ${files} file${files === 1 ? '' : 's'}${b.skipped.length ? `, ${b.skipped.length} skipped` : ''}`
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
/** The human view of `able bloat blocks`: per file, each block's short id, lines, heading and opening words. */
|
|
149
|
+
/** The human view of `able audit bloat blocks`: per file, each block's short id, lines, heading and opening words. */
|
|
150
150
|
export function render(b: Blocks) {
|
|
151
151
|
const out: string[] = []
|
|
152
152
|
for (const [path, list] of Map.groupBy(b.blocks, (x) => x.path)) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { existsSync, readFileSync } from 'node:fs'
|
|
7
7
|
import { dirname, join, normalize } from 'node:path'
|
|
8
|
-
import { loadConfig, type AbleConfig } from '
|
|
8
|
+
import { loadConfig, type AbleConfig } from '../../../config.ts'
|
|
9
9
|
import { clip, n, type Entry } from './scan.ts'
|
|
10
10
|
import type { Level, LintRule, Linter, Checks } from './types.ts'
|
|
11
11
|
|
|
@@ -186,7 +186,7 @@ export async function checks(root: string, entries: Entry[], files: string[]): P
|
|
|
186
186
|
return { commit, merge: (config.checks?.merge ?? []).map(commandText), linters, settings, recipes, scripts }
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
/** One line for `able bloat status`. */
|
|
189
|
+
/** One line for `able audit bloat status`. */
|
|
190
190
|
export function summary(c: Checks) {
|
|
191
191
|
const rules = c.linters.reduce((s, l) => s + l.rules.length, 0)
|
|
192
192
|
const deny = c.settings.reduce((s, x) => s + x.deny.length, 0)
|
|
@@ -196,7 +196,7 @@ export function summary(c: Checks) {
|
|
|
196
196
|
|
|
197
197
|
const list = (names: string[], max = 64) => clip(names.join(', '), max)
|
|
198
198
|
|
|
199
|
-
/** The human view of `able bloat checks`. */
|
|
199
|
+
/** The human view of `able audit bloat checks`. */
|
|
200
200
|
export function render(c: Checks) {
|
|
201
201
|
const out: string[] = []
|
|
202
202
|
out.push(' COMMIT CHECKS (able.config.ts, per folder)')
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// report files: the words at start per folder as predicted (the old report's, less what was applied) against the
|
|
3
3
|
// actual (the new report's), what happened to each applied finding, and any finding that went without being picked.
|
|
4
4
|
|
|
5
|
-
import { dim, green, red } from '
|
|
5
|
+
import { dim, green, red } from '../../ui.ts'
|
|
6
6
|
import { atStart, reportCode, type Finding, type Report } from './report.ts'
|
|
7
7
|
import { clip, fit, n } from './scan.ts'
|
|
8
8
|
import type { Comparison } from './types.ts'
|
|
@@ -51,13 +51,13 @@ export function render(c: Comparison, names: { old: string; next: string }) {
|
|
|
51
51
|
for (const a of c.applied) {
|
|
52
52
|
out.push(` ${String(a.n).padStart(3)} ${a.kind.padEnd(12)} ${fit(a.path, 34).padEnd(34)} ${a.gone ? clip(a.state, 60) : red(a.state)}`)
|
|
53
53
|
}
|
|
54
|
-
if (!c.applied.length) out.push(dim(' none: nothing was recorded with able bloat apply --record'))
|
|
54
|
+
if (!c.applied.length) out.push(dim(' none: nothing was recorded with able audit bloat apply --record'))
|
|
55
55
|
const gone = (title: string, why: string, list: Comparison['unpicked']) => {
|
|
56
56
|
if (!list.length) return
|
|
57
57
|
out.push('', ` ${title} ${list.length} ${dim(why)}`)
|
|
58
58
|
for (const u of list) out.push(` ${String(u.n).padStart(3)} ${u.kind.padEnd(12)} ${fit(u.path, 34).padEnd(34)} "${clip(u.text.replace(/\s+/g, ' '), 40)}"`)
|
|
59
59
|
}
|
|
60
|
-
gone('GONE, NOT RECORDED', 'picked yes and gone, but no able bloat apply --record says where', c.unrecorded)
|
|
60
|
+
gone('GONE, NOT RECORDED', 'picked yes and gone, but no able audit bloat apply --record says where', c.unrecorded)
|
|
61
61
|
gone('GONE WITHOUT A YES', 'a rule lost, or its words changed so its id did', c.unpicked)
|
|
62
62
|
return out.join('\n')
|
|
63
63
|
}
|
|
@@ -52,7 +52,7 @@ export function check(findings: Findings, blocks: Block[]): Checked {
|
|
|
52
52
|
for (const { block: id, rules: found = [] } of findings.findings ?? []) {
|
|
53
53
|
const block = byId.get(id)
|
|
54
54
|
if (!block) {
|
|
55
|
-
errors.push(`${id}: no such block (cut again with able bloat blocks)`)
|
|
55
|
+
errors.push(`${id}: no such block (cut again with able audit bloat blocks)`)
|
|
56
56
|
continue
|
|
57
57
|
}
|
|
58
58
|
for (const r of found) {
|
|
@@ -85,13 +85,13 @@ export function readFindings(path: string): Findings | undefined {
|
|
|
85
85
|
/** Rules step 6 still owes a proposal: every rule not kept. */
|
|
86
86
|
export const unproposed = (c: Checked) => c.rules.filter((r) => r.kind !== 'keep' && !r.proposal)
|
|
87
87
|
|
|
88
|
-
/** One line for `able bloat status` at step 6. */
|
|
88
|
+
/** One line for `able audit bloat status` at step 6. */
|
|
89
89
|
export const proposeSummary = (c: Checked) => {
|
|
90
90
|
const owed = c.rules.filter((r) => r.kind !== 'keep').length
|
|
91
91
|
return `${owed - unproposed(c).length} of ${owed} proposed`
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
/** One line for `able bloat status`. */
|
|
94
|
+
/** One line for `able audit bloat status`. */
|
|
95
95
|
export function summary(c: Checked) {
|
|
96
96
|
const byKind = Object.keys(kinds)
|
|
97
97
|
.map((k) => [k, c.rules.filter((r) => r.kind === k).length] as const)
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Cells are sized by words for now; `show` marks them by kind once classify has run.
|
|
3
3
|
|
|
4
4
|
import { dirname } from 'node:path'
|
|
5
|
-
import { folderOf } from '
|
|
6
|
-
import { dim, paint256, tty } from '
|
|
5
|
+
import { folderOf } from '../../checks.ts'
|
|
6
|
+
import { dim, paint256, tty } from '../../ui.ts'
|
|
7
7
|
import type { Blocks } from './blocks.ts'
|
|
8
8
|
import type { Checks } from './checks.ts'
|
|
9
9
|
import type { Checked } from './findings.ts'
|
|
@@ -33,7 +33,7 @@ const centre = (s: string) => {
|
|
|
33
33
|
return `${' '.repeat(left)}${t}${' '.repeat(box - t.length - left)}`
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/** `able bloat scan --grid`: the files as a periodic table, one box each. */
|
|
36
|
+
/** `able audit bloat scan --grid`: the files as a periodic table, one box each. */
|
|
37
37
|
export function files(entries: Entry[]) {
|
|
38
38
|
const out: string[] = []
|
|
39
39
|
const sorted = [...entries].sort((a, b) => order.indexOf(a.kind) - order.indexOf(b.kind))
|
|
@@ -60,7 +60,7 @@ const greens = [237, 22, 28, 34, 40]
|
|
|
60
60
|
const plain = ['·', '░', '▒', '▓', '█']
|
|
61
61
|
const square = (level: number) => (tty ? paint256(greens[level])('■') : plain[level])
|
|
62
62
|
|
|
63
|
-
/** `able bloat blocks --grid`: per file, a card with a row per section and one square per block. */
|
|
63
|
+
/** `able audit bloat blocks --grid`: per file, a card with a row per section and one square per block. */
|
|
64
64
|
export function blocks(b: Blocks) {
|
|
65
65
|
const out: string[] = []
|
|
66
66
|
for (const [path, list] of Map.groupBy(b.blocks, (x) => x.path)) {
|
|
@@ -92,7 +92,7 @@ export function blocks(b: Blocks) {
|
|
|
92
92
|
const shade = (count: number, present = count > 0) => (!present ? 0 : count < 2 ? 1 : count < 10 ? 2 : count < 50 ? 3 : 4)
|
|
93
93
|
const sum = (ns: number[]) => ns.reduce((a, b) => a + b, 0)
|
|
94
94
|
|
|
95
|
-
/** `able bloat checks --grid`: per folder, which tools enforce anything there, shaded by how much. */
|
|
95
|
+
/** `able audit bloat checks --grid`: per folder, which tools enforce anything there, shaded by how much. */
|
|
96
96
|
export function enforcement(c: Checks, entries: Entry[]) {
|
|
97
97
|
const folders = [...new Set(['.', ...Object.keys(c.commit), ...entries.filter((e) => e.kind === 'instructions').map((e) => dirname(e.path))])].sort()
|
|
98
98
|
// A config belongs to the nearest folder row at or above it (outs/android/outstanding/detekt.yml is outs/android's)
|
|
@@ -137,7 +137,7 @@ export function enforcement(c: Checks, entries: Entry[]) {
|
|
|
137
137
|
const kindColour: Record<Kind, number> = { keep: 34, scoped: 178, lint: 39, check: 39, enforced: 39, guard: 39, discoverable: 244, expiring: 244, duplicate: 244, conflict: 196 }
|
|
138
138
|
const mark = (kind?: Kind) => (kind ? paint256(kindColour[kind])(kinds[kind].letter) : '·')
|
|
139
139
|
|
|
140
|
-
/** `able bloat classify`: per file, a row per section and one mark per rule, by kind; `·` a block that is all context. */
|
|
140
|
+
/** `able audit bloat classify`: per file, a row per section and one mark per rule, by kind; `·` a block that is all context. */
|
|
141
141
|
export function byKind(b: Blocks, c: Checked) {
|
|
142
142
|
const out: string[] = []
|
|
143
143
|
const rulesOf = Map.groupBy(c.rules, (r) => r.block)
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
// able bloat: the bloat diagnostic. What a host's agent files load, the rules in them,
|
|
2
|
-
// a report (knowledge/product/modules/
|
|
1
|
+
// able audit bloat: the bloat diagnostic, the Audit module's first. What a host's agent files load, the rules in them,
|
|
2
|
+
// and where each rule belongs, as a report (knowledge/product/modules/audit.md).
|
|
3
3
|
//
|
|
4
|
-
// able bloat status every step in order, one line each, for the latest report
|
|
5
|
-
// able bloat scan [--json|--grid] step 1: every agent file, its kind and size (--grid: one box per file)
|
|
6
|
-
// able bloat load [--json] step 2: when each file loads, and the words at start per folder
|
|
7
|
-
// able bloat blocks [--json|--grid] step 3: the files cut into blocks, with spans and stable ids (--grid: one square per block)
|
|
8
|
-
// able bloat checks [--json|--grid] step 4: what the host already enforces (--grid: per folder, per tool)
|
|
9
|
-
// able bloat classify [--json] step 5's result: the agent's findings checked against the blocks, drawn by kind
|
|
10
|
-
// able bloat propose [--json] step 6's result: each rule not kept with its proposal, or what is still owed
|
|
11
|
-
// able bloat report step 7: checks the findings and writes a report to <journal>/bloat/<date>-<hhmm>.json
|
|
12
|
-
// able bloat show [<report>] [--step <n>|--json] step 8: a report read back from its file (the latest by default)
|
|
13
|
-
// able bloat history [--json] every report, oldest first, one line each: the picker and the trend
|
|
14
|
-
// able bloat pick [<yes|no> <n>…]… [--report <report>] step 9: the operator's picks in the latest report, or the one named
|
|
4
|
+
// able audit bloat status every step in order, one line each, for the latest report
|
|
5
|
+
// able audit bloat scan [--json|--grid] step 1: every agent file, its kind and size (--grid: one box per file)
|
|
6
|
+
// able audit bloat load [--json] step 2: when each file loads, and the words at start per folder
|
|
7
|
+
// able audit bloat blocks [--json|--grid] step 3: the files cut into blocks, with spans and stable ids (--grid: one square per block)
|
|
8
|
+
// able audit bloat checks [--json|--grid] step 4: what the host already enforces (--grid: per folder, per tool)
|
|
9
|
+
// able audit bloat classify [--json] step 5's result: the agent's findings checked against the blocks, drawn by kind
|
|
10
|
+
// able audit bloat propose [--json] step 6's result: each rule not kept with its proposal, or what is still owed
|
|
11
|
+
// able audit bloat report step 7: checks the findings and writes a report to <journal>/bloat/<date>-<hhmm>.json
|
|
12
|
+
// able audit bloat show [<report>] [--step <n>|--json] step 8: a report read back from its file (the latest by default)
|
|
13
|
+
// able audit bloat history [--json] every report, oldest first, one line each: the picker and the trend
|
|
14
|
+
// able audit bloat pick [<yes|no> <n>…]… [--report <report>] step 9: the operator's picks in the latest report, or the one named
|
|
15
15
|
// (no arguments on a terminal: checkboxes)
|
|
16
|
-
// able bloat apply [--json] step 10: the yes picks not applied yet, in the order the agent applies them
|
|
17
|
-
// able bloat apply --record <n> [<target>] step 10: finding n is applied, to target (its proposal's by default)
|
|
18
|
-
// able bloat compare [<report>] [<new>] [--json] step 11: a report against the one before it (the latest by default),
|
|
16
|
+
// able audit bloat apply [--json] step 10: the yes picks not applied yet, in the order the agent applies them
|
|
17
|
+
// able audit bloat apply --record <n> [<target>] step 10: finding n is applied, to target (its proposal's by default)
|
|
18
|
+
// able audit bloat compare [<report>] [<new>] [--json] step 11: a report against the one before it (the latest by default),
|
|
19
19
|
// or two reports named, old then new
|
|
20
20
|
//
|
|
21
21
|
// Read-only on the host's agent files: the only files written are the findings (by the skill) and the report. The
|
|
22
22
|
// agent changes them at step 10, as the skill says, only when the operator asks.
|
|
23
23
|
|
|
24
24
|
import { basename, join, relative } from 'node:path'
|
|
25
|
-
import { hostRoot, loadConfig } from '
|
|
26
|
-
import { confirm, dim, fail, green, tty } from '
|
|
25
|
+
import { hostRoot, loadConfig } from '../../../config.ts'
|
|
26
|
+
import { confirm, dim, fail, green, tty } from '../../ui.ts'
|
|
27
27
|
import * as apply from './apply.ts'
|
|
28
28
|
import * as blocks from './blocks.ts'
|
|
29
29
|
import * as checks from './checks.ts'
|
|
@@ -38,7 +38,7 @@ import * as show from './show.ts'
|
|
|
38
38
|
import { steps, who } from './steps.ts'
|
|
39
39
|
import type { Compared } from './types.ts'
|
|
40
40
|
|
|
41
|
-
const [sub = '', ...args] = process.argv.slice(
|
|
41
|
+
const [sub = '', ...args] = process.argv.slice(4)
|
|
42
42
|
const valued = ['--step', '--report', '--record']
|
|
43
43
|
const names = args.filter((a, i) => !a.startsWith('--') && !valued.includes(args[i - 1] ?? ''))
|
|
44
44
|
const option = (name: string) => (args.includes(name) ? args[args.indexOf(name) + 1] : undefined)
|
|
@@ -79,7 +79,7 @@ const latest = once(async () => {
|
|
|
79
79
|
return path ? { path, report: report.readReport(path) } : undefined
|
|
80
80
|
})
|
|
81
81
|
type Latest = Awaited<ReturnType<typeof latest>>
|
|
82
|
-
const requireLatest = async () => (await latest()) ?? fail(option('--report') || (sub === 'show' && names[0]) ? 'no such report' : 'no report yet: able bloat report writes one')
|
|
82
|
+
const requireLatest = async () => (await latest()) ?? fail(option('--report') || (sub === 'show' && names[0]) ? 'no such report' : 'no report yet: able audit bloat report writes one')
|
|
83
83
|
/** Steps 7 to 9 all show the latest report; only their line in `status` differs. */
|
|
84
84
|
const latestView = (summary: (l: NonNullable<Latest>) => string, none: string) =>
|
|
85
85
|
built<Latest>({ result: latest, summary: (l) => (l ? summary(l) : none), render: (l) => (l ? show.render(l.report, l.path, root) : ' No report yet.') })
|
|
@@ -95,7 +95,7 @@ const views: Record<string, Built<unknown>> = {
|
|
|
95
95
|
render: (c) =>
|
|
96
96
|
c
|
|
97
97
|
? [grid.byKind(cut(), c), ...(c.errors.length ? ['', ' ERRORS', ...c.errors.map((e) => ` ${e}`)] : [])].join('\n')
|
|
98
|
-
: ` No findings yet: the skill (able-
|
|
98
|
+
: ` No findings yet: the skill (able-audit-bloat) writes ${findings.findingsPath} at step 5.`,
|
|
99
99
|
}),
|
|
100
100
|
propose: built({
|
|
101
101
|
result: classified,
|
|
@@ -112,7 +112,7 @@ const views: Record<string, Built<unknown>> = {
|
|
|
112
112
|
: ' No findings yet.',
|
|
113
113
|
}),
|
|
114
114
|
report: latestView((l) => `latest: ${relative(root, l.path)}`, 'not run yet'),
|
|
115
|
-
show: latestView(() => 'able bloat show', 'no report yet'),
|
|
115
|
+
show: latestView(() => 'able audit bloat show', 'no report yet'),
|
|
116
116
|
pick: latestView((l) => report.tally(l.report).line, 'no report yet'),
|
|
117
117
|
apply: built<apply.Left | undefined>({
|
|
118
118
|
result: once(async () => {
|
|
@@ -145,7 +145,7 @@ async function pair(): Promise<Compared | undefined> {
|
|
|
145
145
|
async function recordApplied() {
|
|
146
146
|
const l = await requireLatest()
|
|
147
147
|
const n = Number(option('--record'))
|
|
148
|
-
if (!Number.isInteger(n) || n < 1) fail('usage: able bloat apply --record <n> [<target>]')
|
|
148
|
+
if (!Number.isInteger(n) || n < 1) fail('usage: able audit bloat apply --record <n> [<target>]')
|
|
149
149
|
const r = await apply.record(l.path, l.report, n, names[0])
|
|
150
150
|
if (typeof r === 'string') fail(r)
|
|
151
151
|
if (json) return console.log(JSON.stringify({ report: relative(root, l.path), n, applied: r.applied }))
|
|
@@ -194,7 +194,7 @@ async function writePicks() {
|
|
|
194
194
|
if (x === 'yes' || x === 'no') answer = x
|
|
195
195
|
else if (/^\d+$/.test(x)) answers.set(Number(x), answer)
|
|
196
196
|
else fail(`not a finding number: ${x}`)
|
|
197
|
-
} else fail('usage: able bloat pick [<yes|no> <n>…]… [--report <report>] (no arguments on a terminal opens the checkboxes)')
|
|
197
|
+
} else fail('usage: able audit bloat pick [<yes|no> <n>…]… [--report <report>] (no arguments on a terminal opens the checkboxes)')
|
|
198
198
|
const unknown = await report.pick(l.path, l.report, answers)
|
|
199
199
|
if (unknown.length) fail(`no finding numbered ${unknown.join(', ')} in ${relative(root, l.path)}`)
|
|
200
200
|
const { yes, no, open } = report.tally(l.report)
|
|
@@ -251,7 +251,7 @@ else if (views[sub]) {
|
|
|
251
251
|
// Nothing to show is `null` in JSON, so a reader always gets JSON.
|
|
252
252
|
console.log(json ? JSON.stringify(r ?? null) : `\n${asGrid && view.grid ? view.grid(r) : view.render(r)}\n`)
|
|
253
253
|
} else {
|
|
254
|
-
console.error(`usage: able bloat status | ${Object.keys(views).join(' | ')} [--json] [--grid]`)
|
|
254
|
+
console.error(`usage: able audit bloat status | ${Object.keys(views).join(' | ')} [--json] [--grid]`)
|
|
255
255
|
process.exit(sub ? 1 : 0)
|
|
256
256
|
}
|
|
257
257
|
|
|
@@ -140,14 +140,14 @@ export function load(root: string, entries: Entry[]): LoadMap {
|
|
|
140
140
|
return { files, folders, outside }
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
/** One line for `able bloat status`. */
|
|
143
|
+
/** One line for `able audit bloat status`. */
|
|
144
144
|
export function summary(map: LoadMap) {
|
|
145
145
|
const words = map.folders.map((f) => f.host)
|
|
146
146
|
const range = words.length > 1 ? `${n(Math.min(...words))}-${n(Math.max(...words))}` : n(words[0] ?? 0)
|
|
147
147
|
return `${map.folders.length} folder${map.folders.length === 1 ? '' : 's'}, ${range} at start, +${n(map.folders[0]?.outside ?? 0)} outside`
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
/** The human view of `able bloat load`. */
|
|
150
|
+
/** The human view of `able audit bloat load`. */
|
|
151
151
|
export function render(map: LoadMap) {
|
|
152
152
|
const out: string[] = []
|
|
153
153
|
const width = Math.min(40, Math.max(4, ...map.files.map((f) => f.path.length)))
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Plain keys and ANSI codes on Bun's raw stdin, no dependency; outside a terminal, `pick yes|no <n>…` does the same.
|
|
4
4
|
|
|
5
5
|
import { relative } from 'node:path'
|
|
6
|
-
import { bold, dim, paint256 } from '
|
|
6
|
+
import { bold, dim, paint256 } from '../../ui.ts'
|
|
7
7
|
import { kinds } from './kinds.ts'
|
|
8
8
|
import type { Report } from './report.ts'
|
|
9
9
|
import { clip, fit } from './scan.ts'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Step 7, report: checks the agent's findings (every block classified, every rule not kept proposed), merges them with
|
|
2
2
|
// steps 1 to 4, works out the impact, and writes the report to `<journal>/bloat/<yyyy-mm-dd>-<hhmm>.json`. Every report is
|
|
3
|
-
// kept. Step 9's picks are written into the same file by `able bloat pick`. The report is the one source `show` and the
|
|
3
|
+
// kept. Step 9's picks are written into the same file by `able audit bloat pick`. The report is the one source `show` and the
|
|
4
4
|
// dashboard read; it holds each rule's span, so a view can highlight its words.
|
|
5
5
|
//
|
|
6
6
|
// On disk (`able.bloat.report@1`) a rule keeps no copy of its words or its path: both come from its block (the block's
|
|
@@ -228,7 +228,7 @@ export function build(input: {
|
|
|
228
228
|
...input.summaries,
|
|
229
229
|
report: relative(input.root, input.path),
|
|
230
230
|
show: `${root ? root.before - root.after : 0} words leave the root's start`,
|
|
231
|
-
compare: input.previous ? 'able bloat compare: this report against the one before' : 'waits for a second report',
|
|
231
|
+
compare: input.previous ? 'able audit bloat compare: this report against the one before' : 'waits for a second report',
|
|
232
232
|
}
|
|
233
233
|
const report: Report = {
|
|
234
234
|
format,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { existsSync, lstatSync, readFileSync, realpathSync } from 'node:fs'
|
|
5
5
|
import { join, relative } from 'node:path'
|
|
6
|
-
import { lines as gitLines } from '
|
|
6
|
+
import { lines as gitLines } from '../../git.ts'
|
|
7
7
|
import type { FileKind, SkillOrigin, Entry } from './types.ts'
|
|
8
8
|
|
|
9
9
|
export type { FileKind, SkillOrigin, Entry }
|
|
@@ -81,13 +81,13 @@ export function scan(root: string, files: string[]): Entry[] {
|
|
|
81
81
|
.sort((a, b) => a.path.localeCompare(b.path))
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
/** One line for `able bloat status`. */
|
|
84
|
+
/** One line for `able audit bloat status`. */
|
|
85
85
|
export const summary = (entries: Entry[]) => `${entries.length} files, ${n(entries.reduce((sum, e) => sum + e.words, 0))} words`
|
|
86
86
|
|
|
87
87
|
/** A path cut in the middle to fit, so the view stays narrow enough for a terminal and a chat. */
|
|
88
88
|
export const fit = (path: string, max: number) => (path.length <= max ? path : `${path.slice(0, 12)}...${path.slice(-(max - 15))}`)
|
|
89
89
|
|
|
90
|
-
/** The human view of `able bloat scan`. */
|
|
90
|
+
/** The human view of `able audit bloat scan`. */
|
|
91
91
|
export function render(entries: Entry[]) {
|
|
92
92
|
const width = Math.min(48, Math.max(4, ...entries.map((e) => e.path.length)))
|
|
93
93
|
const lines = [` ${'PATH'.padEnd(width)} ${'KIND'.padEnd(16)} ${'WORDS'.padStart(6)} ${'LINES'.padStart(5)}`]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// `--step <n>` prints one step's full view from the same file, so any step can be looked at again later.
|
|
3
3
|
|
|
4
4
|
import { relative } from 'node:path'
|
|
5
|
-
import { dim } from '
|
|
5
|
+
import { dim } from '../../ui.ts'
|
|
6
6
|
import * as blocks from './blocks.ts'
|
|
7
7
|
import * as checks from './checks.ts'
|
|
8
8
|
import * as grid from './grid.ts'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// The steps of a report, as data: `able bloat status` walks them, the skill follows them, a dashboard page will show them.
|
|
1
|
+
// The steps of a report, as data: `able audit bloat status` walks them, the skill follows them, a dashboard page will show them.
|
|
2
2
|
|
|
3
3
|
export type StepKind = 'mechanical' | 'agent' | 'operator'
|
|
4
4
|
|
|
5
5
|
export interface Step {
|
|
6
6
|
n: number
|
|
7
|
-
/** The step's one name, also its command: `able bloat <id>`. */
|
|
7
|
+
/** The step's one name, also its command: `able audit bloat <id>`. */
|
|
8
8
|
id: string
|
|
9
9
|
kind: StepKind
|
|
10
10
|
}
|
|
@@ -148,7 +148,7 @@ export interface Finding extends Rule {
|
|
|
148
148
|
line: number
|
|
149
149
|
words: number
|
|
150
150
|
pick?: 'yes' | 'no'
|
|
151
|
-
/** Step 10: where a yes pick went, recorded by `able bloat apply --record` once the agent has made the change. */
|
|
151
|
+
/** Step 10: where a yes pick went, recorded by `able audit bloat apply --record` once the agent has made the change. */
|
|
152
152
|
applied?: { at: string; target: string }
|
|
153
153
|
/** Lineage: the id of the finding in the report before that this rule came from, when it was applied and moved here
|
|
154
154
|
* (its words found again in the file it was applied to). */
|
|
@@ -185,17 +185,17 @@ export interface Comparison {
|
|
|
185
185
|
applied: { n: number; id: string; kind: Kind; path: string; target: string; gone: boolean; became?: { id: string; kind: Kind; path: string }; state: string }[]
|
|
186
186
|
/** Findings of the old report that are gone though nobody picked them yes: a rule lost, or its words changed. */
|
|
187
187
|
unpicked: { n: number; id: string; kind: Kind; path: string; text: string }[]
|
|
188
|
-
/** Yes picks that are gone though nothing recorded where they went (`able bloat apply --record` was missed). */
|
|
188
|
+
/** Yes picks that are gone though nothing recorded where they went (`able audit bloat apply --record` was missed). */
|
|
189
189
|
unrecorded: { n: number; id: string; kind: Kind; path: string; text: string }[]
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
/** `able bloat compare --json`: the comparison and the two reports' names. */
|
|
192
|
+
/** `able audit bloat compare --json`: the comparison and the two reports' names. */
|
|
193
193
|
export interface Compared {
|
|
194
194
|
c: Comparison
|
|
195
195
|
names: { old: string; next: string }
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
/** One report in the diagnostic's history (`able bloat history`): what the report picker shows of it, and a point on
|
|
198
|
+
/** One report in the diagnostic's history (`able audit bloat history`): what the report picker shows of it, and a point on
|
|
199
199
|
* the trend charts. Worked out from the report file, so it never disagrees with it. */
|
|
200
200
|
export interface HistoryLine {
|
|
201
201
|
/** The report's name, its file's: `2026-11-18-1449`. */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// able audit: the Audit module (knowledge/product/modules/audit.md). On-demand diagnostics, each writing a frozen
|
|
2
|
+
// report the operator picks from, with history and compare.
|
|
3
|
+
//
|
|
4
|
+
// able audit lists the audits
|
|
5
|
+
// able audit bloat <step> … the bloat diagnostic (bloat/index.ts); cli/able.ts rewrites `able bloat` and `able agents` to it
|
|
6
|
+
|
|
7
|
+
const audits: Record<string, { about: string; run: () => Promise<unknown> }> = {
|
|
8
|
+
bloat: { about: 'where each rule in the agent files belongs', run: () => import('./bloat/index.ts') },
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const name = process.argv[3] ?? ''
|
|
12
|
+
if (Object.hasOwn(audits, name)) await audits[name]!.run()
|
|
13
|
+
else {
|
|
14
|
+
const list = Object.entries(audits).map(([n, a]) => ` able audit ${n} <step> ${a.about}`)
|
|
15
|
+
console.error(['usage: able audit <audit> <step> …', ...list].join('\n'))
|
|
16
|
+
process.exit(name ? 1 : 0)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {}
|
package/src/workspaces/merge.ts
CHANGED
|
@@ -34,7 +34,7 @@ if (dirty && !msg) fail(`${dirty} uncommitted file(s); commit them (able commit)
|
|
|
34
34
|
const keepOpen = args.includes('--keep-open')
|
|
35
35
|
const brief = join(ws.path, config.journal, 'workspaces', `${ws.slug}.md`)
|
|
36
36
|
if (!keepOpen && existsSync(brief) && !readFileSync(brief, 'utf8').includes('\n## Ledger\n'))
|
|
37
|
-
fail(`${relative(ws.path, brief)} has no ## Ledger; close the workspace first (the able-close
|
|
37
|
+
fail(`${relative(ws.path, brief)} has no ## Ledger; close the workspace first (the able-ws-close skill), then merge, or land what is done with --keep-open`)
|
|
38
38
|
|
|
39
39
|
const step = working(`merge ${ws.slug}`)
|
|
40
40
|
step(`fetching origin/${trunk}`)
|
|
@@ -99,6 +99,6 @@ console.log(
|
|
|
99
99
|
),
|
|
100
100
|
)
|
|
101
101
|
console.log(
|
|
102
|
-
keepOpen ? `\n ${dim('the workspace stays open: keep working here, and close it (able-close
|
|
102
|
+
keepOpen ? `\n ${dim('the workspace stays open: keep working here, and close it (able-ws-close) before its last merge')}\n` : `\n ${dim('next, from the main checkout:')} able ws rm ${ws.slug}\n`,
|
|
103
103
|
)
|
|
104
104
|
status({ state: 'done', msg: `merge: ${ws.branch} is on origin/${trunk}` })
|
|
File without changes
|