@able-autonomy/able 0.0.17 → 0.0.19
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 +6 -1
- package/package.json +1 -1
- package/src/workspaces/new.ts +23 -14
package/able.ts
CHANGED
|
@@ -101,6 +101,11 @@ if (command === 'config') {
|
|
|
101
101
|
process.exit(0)
|
|
102
102
|
}
|
|
103
103
|
// `bunx` keeps the copy it fetched first; asking for @latest once refreshes it. A host that pins Able runs its pin instead.
|
|
104
|
+
// The version this `able` is: what `bunx` runs here, so `able upgrade` can be checked.
|
|
105
|
+
if (command === '-v' || command === '--version') {
|
|
106
|
+
console.log((await Bun.file(join(import.meta.dir, 'package.json')).json()).version)
|
|
107
|
+
process.exit(0)
|
|
108
|
+
}
|
|
104
109
|
if (command === 'upgrade') {
|
|
105
110
|
const { name, version: current } = await Bun.file(join(import.meta.dir, 'package.json')).json()
|
|
106
111
|
const latest = Bun.spawnSync(['bun', 'info', name, 'version'], { stderr: 'ignore' }).stdout.toString().trim().split('\n').at(-1) ?? ''
|
|
@@ -142,7 +147,7 @@ if (delegate) {
|
|
|
142
147
|
}
|
|
143
148
|
if (command !== 'gh') {
|
|
144
149
|
console.error(
|
|
145
|
-
"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 ws <new|ls|current|refresh|merge|rm|start|stop|status|take|build|attach> workspaces\n able agents <run|scan|load|blocks|checks|classify|propose|report|show|pick> where each agent-file rule belongs",
|
|
150
|
+
"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|rm|start|stop|status|take|build|attach> workspaces\n able agents <run|scan|load|blocks|checks|classify|propose|report|show|pick> where each agent-file rule belongs",
|
|
146
151
|
)
|
|
147
152
|
process.exit(command ? 1 : 0)
|
|
148
153
|
}
|
package/package.json
CHANGED
package/src/workspaces/new.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
// able ws new <slug> [--brief] [--no-fetch]: a worktree on `feat/<slug>` cut from origin's trunk, in `workspaces.dir`,
|
|
2
|
-
// what a worktree can't inherit: the host's `copy` files and its `onCreate` commands, with this workspace's facts
|
|
3
|
-
// `ABLE_WS_*`. Services are not started: `able ws start` does that. Every check runs before anything is created.
|
|
1
|
+
// able ws new <slug> [--no-brief] [--no-fetch]: a worktree on `feat/<slug>` cut from origin's trunk, in `workspaces.dir`,
|
|
2
|
+
// then what a worktree can't inherit: the host's `copy` files and its `onCreate` commands, with this workspace's facts
|
|
3
|
+
// in `ABLE_WS_*`. Services are not started: `able ws start` does that. Every check runs before anything is created.
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
// it
|
|
7
|
-
//
|
|
5
|
+
// The workspace's brief, `<journal>/workspaces/<slug>.md`, is published first when origin's trunk doesn't carry it as
|
|
6
|
+
// the main checkout has it: the file alone is committed after its checks (when it has changes) and the trunk pushed, so
|
|
7
|
+
// the cut carries it. Already on origin as it is here: nothing to publish. Nowhere: refused, unless `--no-brief`.
|
|
8
|
+
// Running it again after a failure picks up where it stopped: a brief committed but not pushed is pushed, since the
|
|
9
|
+
// only unpushed changes it allows are the brief's own. `--brief`, the old way to ask for this, is still accepted.
|
|
8
10
|
|
|
9
11
|
import { copyFileSync, existsSync, mkdirSync } from 'node:fs'
|
|
10
12
|
import { dirname, join, relative, resolve } from 'node:path'
|
|
11
13
|
import { loadConfig, trailerArgs } from '../../config.ts'
|
|
12
14
|
import { runChecks } from '../checks.ts'
|
|
13
|
-
import { count, failOnMerge, fetchTrunk, git, gitLoud, mainRoot } from '../git.ts'
|
|
15
|
+
import { count, failOnMerge, fetchTrunk, git, gitLoud, gitQuiet, lines, mainRoot } from '../git.ts'
|
|
14
16
|
import { runCommand } from '../run.ts'
|
|
15
17
|
import { status, working } from '../status.ts'
|
|
16
18
|
import { bold, dim, fail, green, yellow } from '../ui.ts'
|
|
@@ -18,7 +20,7 @@ import { branchOf, readState, workspaces, writeState } from './state.ts'
|
|
|
18
20
|
|
|
19
21
|
const args = process.argv.slice(4)
|
|
20
22
|
const slug = args.find((a) => !a.startsWith('-'))
|
|
21
|
-
if (!slug) fail('usage: able ws new <slug> [--brief] [--no-fetch]')
|
|
23
|
+
if (!slug) fail('usage: able ws new <slug> [--no-brief] [--no-fetch]')
|
|
22
24
|
if (!/^[a-z0-9][a-z0-9-]*$/.test(slug)) fail(`invalid name '${slug}': lowercase letters, digits and dashes only`)
|
|
23
25
|
|
|
24
26
|
const main = mainRoot()
|
|
@@ -43,15 +45,22 @@ if (!args.includes('--no-fetch')) {
|
|
|
43
45
|
fetchTrunk(main, config.trunk)
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const { trunk, journal } = config
|
|
49
|
+
const file = `${journal}/workspaces/${slug}.md`
|
|
50
|
+
const local = existsSync(join(main, file))
|
|
51
|
+
const onOrigin = gitQuiet(main, 'cat-file', '-e', `origin/${trunk}:${file}`)
|
|
52
|
+
// Untracked, edited, or committed differently from origin's trunk: the cut wouldn't carry it as it is here.
|
|
53
|
+
const differs = local && (Boolean(git(main, 'status', '--porcelain', '--', file)) || !gitQuiet(main, 'diff', '--quiet', `origin/${trunk}`, '--', file))
|
|
54
|
+
if (!local && !onOrigin && !args.includes('--no-brief')) fail(`no brief at ${file}; write it first, or pass --no-brief for a workspace without one`)
|
|
55
|
+
|
|
56
|
+
if (differs) {
|
|
50
57
|
if (git(main, 'rev-parse', '--abbrev-ref', 'HEAD') !== trunk) fail(`the main checkout is not on ${trunk}`)
|
|
51
58
|
failOnMerge(main)
|
|
52
59
|
step('publishing the brief')
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
// Unpushed work other than the brief would leave with it. The brief's own commit (a run that stopped before its
|
|
61
|
+
// push) is fine: this run pushes it.
|
|
62
|
+
const others = lines(main, 'diff', '--name-only', `origin/${trunk}...${trunk}`).filter((f) => f !== file)
|
|
63
|
+
if (others.length) fail(`${trunk} has unpushed changes that would leave with the brief:\n${git(main, 'log', '--oneline', `origin/${trunk}..${trunk}`)}`)
|
|
55
64
|
if (git(main, 'status', '--porcelain', '--', file)) {
|
|
56
65
|
const at = { slug: 'main', path: main, portOffset: 0, main }
|
|
57
66
|
if (!runChecks(config, [file], at)) fail('a check failed; nothing committed')
|