@buildaharness/app-node 0.0.0-stage → 0.2.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/LICENSE +138 -0
- package/README.md +53 -2
- package/dist/app-render.d.ts +28 -0
- package/dist/args.d.ts +35 -0
- package/dist/atomic-write.d.ts +6 -0
- package/dist/claude-cli-node.d.ts +5 -0
- package/dist/commands.d.ts +15 -0
- package/dist/consent-store.d.ts +6 -0
- package/dist/fs-backend.d.ts +16 -0
- package/dist/git-exclude.d.ts +9 -0
- package/dist/host.d.ts +47 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +1059 -0
- package/dist/index.js.map +1 -0
- package/dist/json-config-store.d.ts +20 -0
- package/dist/line-queue.d.ts +8 -0
- package/dist/network-containment.d.ts +23 -0
- package/dist/non-interactive.d.ts +7 -0
- package/dist/paths.d.ts +8 -0
- package/dist/prompts.d.ts +39 -0
- package/dist/render.d.ts +33 -0
- package/dist/resolver.d.ts +3 -0
- package/dist/self-update-node.d.ts +13 -0
- package/dist/settings-store.d.ts +12 -0
- package/dist/shell.d.ts +21 -0
- package/dist/terminal.d.ts +11 -0
- package/package.json +44 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work.
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
45
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
46
|
+
authorized to submit on behalf of the copyright owner.
|
|
47
|
+
|
|
48
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
49
|
+
whom a Contribution has been received by the Licensor and subsequently
|
|
50
|
+
incorporated within the Work.
|
|
51
|
+
|
|
52
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
53
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
54
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
55
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
56
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
57
|
+
Work and such Derivative Works in Source or Object form.
|
|
58
|
+
|
|
59
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
60
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
61
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
62
|
+
(except as stated in this section) patent license to make, have made,
|
|
63
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
64
|
+
where such license applies only to those patent claims licensable
|
|
65
|
+
by such Contributor that are necessarily infringed by their
|
|
66
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
67
|
+
with the Work to which such Contribution(s) was submitted.
|
|
68
|
+
|
|
69
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
70
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
71
|
+
modifications, and in Source or Object form, provided that You
|
|
72
|
+
meet the following conditions:
|
|
73
|
+
|
|
74
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
75
|
+
Works a copy of this License; and
|
|
76
|
+
|
|
77
|
+
(b) You must cause any modified files to carry prominent notices
|
|
78
|
+
stating that You changed the files; and
|
|
79
|
+
|
|
80
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
81
|
+
that You distribute, all copyright, patent, trademark, and
|
|
82
|
+
attribution notices from the Source form of the Work,
|
|
83
|
+
excluding those notices that do not pertain to any part of
|
|
84
|
+
the Derivative Works; and
|
|
85
|
+
|
|
86
|
+
(d) If the Work includes a "NOTICE" text file, You must include a
|
|
87
|
+
readable copy of the attribution notices contained within such
|
|
88
|
+
NOTICE file, in any medium, with or without modifications.
|
|
89
|
+
|
|
90
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
91
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
92
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
93
|
+
this License, without any additional terms or conditions.
|
|
94
|
+
|
|
95
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
96
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
97
|
+
except as required for reasonable and customary use in describing the
|
|
98
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
99
|
+
|
|
100
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed
|
|
101
|
+
to in writing, Licensor provides the Work on an "AS IS" BASIS,
|
|
102
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
103
|
+
implied, including, without limitation, any warranties or conditions
|
|
104
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
105
|
+
PARTICULAR PURPOSE.
|
|
106
|
+
|
|
107
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
108
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
109
|
+
unless required by applicable law or agreed to in writing, shall
|
|
110
|
+
any Contributor be liable to You for damages, including any direct,
|
|
111
|
+
indirect, special, incidental, or exemplary damages of any character
|
|
112
|
+
arising as a result of this License or out of the use or inability
|
|
113
|
+
to use the Work, even if such Contributor has been advised of the
|
|
114
|
+
possibility of such damages.
|
|
115
|
+
|
|
116
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
117
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
118
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
119
|
+
or other liability obligations and/or rights consistent with this
|
|
120
|
+
License. However, in accepting such obligations, You may act only
|
|
121
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
122
|
+
of any other Contributor.
|
|
123
|
+
|
|
124
|
+
END OF TERMS AND CONDITIONS
|
|
125
|
+
|
|
126
|
+
Copyright 2025 3IVIS
|
|
127
|
+
|
|
128
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
129
|
+
you may not use this file except in compliance with the License.
|
|
130
|
+
You may obtain a copy of the License at
|
|
131
|
+
|
|
132
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
133
|
+
|
|
134
|
+
Unless required by applicable law or agreed to in writing, software
|
|
135
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
136
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
137
|
+
See the License for the specific language governing permissions and
|
|
138
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @buildaharness/app-node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Node.js half of the shared app parts. The parts that also run in a browser are in `@buildaharness/runtime`.
|
|
4
|
+
|
|
5
|
+
| Part | What it does | Failure |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| `appPaths(identity, home?)` | `{ dataDir, configFile }` under `~/.buildaharness/<legacy.dataDirName or id>` | none |
|
|
8
|
+
| `nodeFsBackend({ privateRoots? })` | `FsBackend`; paths under a private root (default `~/.buildaharness`) are written owner-only | a missing file reads as undefined |
|
|
9
|
+
| `jsonConfigStore<C>(path, { warn? })` | `ConfigStore<C>` in one JSON file: merge on save, atomic owner-only writes, saves queued | a corrupt file warns and reads as `{}` |
|
|
10
|
+
| `fileSettingsStore(path, { warn? })` | `SettingsStore` (`getSetting`/`setSetting`) in one JSON file: owner-only (0600), temp file and rename, writes queued; `undefined` removes a key. For spending totals, activity logs, job markers | a file that is not a JSON object warns and reads as empty |
|
|
11
|
+
| `runShellCommand(command, cwd, { timeoutMs?, maxOutputBytes?, networkAllowlist?, env? })` | Runs an already approved command with a reduced environment (`env` names; default PATH, HOME, LANG) | a non-zero exit is a result; a spawn failure throws |
|
|
12
|
+
| `startNetworkContainment(allowlist)` | A loopback proxy that refuses other hosts; `getNetworkContainmentProxy` is the shared, cached one | not an OS sandbox: raw sockets bypass it |
|
|
13
|
+
| `excludeFromGit(workspaceRoot, dirs, { appName? })` | Adds folders to the repository's `info/exclude` | never rejects |
|
|
14
|
+
| `nodeResolver()` | `AddressResolver` over the system's DNS | rejects as `dns.lookup` does |
|
|
15
|
+
|
|
16
|
+
`AppIdentity`, `ConfigStore` and `defineSettings` (the settings table) are in `@buildaharness/runtime`. Aielia imports
|
|
17
|
+
all of these. Framework exports: these parts are about the app, not a flow.
|
|
18
|
+
|
|
19
|
+
## Command-line base
|
|
20
|
+
|
|
21
|
+
| Part | What it does | Failure |
|
|
22
|
+
|---|---|---|
|
|
23
|
+
| `createCliHost({ identity, commands?, input?, output?, nonInteractive?, env?, prompt? })` | `print`, `write`, `confirm`, `yesNo`, `ask`, `select`, `serve(handle)`, `help`, `onInterrupt`, `close`. `serve` runs registered commands and passes other lines to `handle`, one at a time, until input closes or `exit`/`quit` | `require-tty` without a terminal throws `StartupError` |
|
|
24
|
+
| `createPrompter({ source, say, decline?, isYes?, pendingAtClose? })` | The prompts alone, over a readline interface | no answer is "no": closed or broken input, a second question while one waits. `select` gives the last option |
|
|
25
|
+
| `createLineQueue(handle, onError)` | One line at a time, in order | a throw goes to `onError`; later lines still run |
|
|
26
|
+
| `resolveNonInteractiveMode(env, variable)` | `decline` or `require-tty`; the host reads `<envPrefix>_NON_INTERACTIVE_APPROVAL` | another value warns and counts as unset |
|
|
27
|
+
| `stripTerminalControls`, `oneLine`, `indentBlock` | Make untrusted text safe to show. The host's `print` and `write` filter already | none |
|
|
28
|
+
| `parseCommandLine(argv, spec)`, `commandLineHelp(spec)` | `app [command] [options] words`, with `--help` and `--version` | an unknown option is `{ kind: 'error' }` |
|
|
29
|
+
| `CommandSpec`, `commandKey`, `formatCommandHelp`, `isQuitCommand` | A slash-command list and its help text | none |
|
|
30
|
+
| `runJob(host, job)`, `formatJobEvent` | Shows a runtime job; Ctrl+C stops softly, twice hard | a failed job prints its message |
|
|
31
|
+
| `reviewApproval(host, approvals, id)`, `formatPending`, `formatApproveResult` | Shows a staged action as it is now and applies it on a yes to that preview | no: rejected. No answer: left pending. Changed: shown and asked again |
|
|
32
|
+
| `runAppJob(host, job)`, `reviewDecision(host, session, decision)`, `formatDecision`, `formatDecisionResult`, `formatAppEvent` | The same for a runtime app session: `runAppJob` prints progress of an `AppJob` and returns `{ outcome, decisions }`; `reviewDecision` shows a `Decision`, lets the person leave items out, and resolves it only on a yes | no or no answer: declined. Changed: the new decision is shown, up to three times. Names are shown as the parts gave them (already escaped) |
|
|
33
|
+
|
|
34
|
+
Without `decline`, piped input can answer a prompt that is already waiting (lines read earlier stay commands, never
|
|
35
|
+
answers). A script that must never approve sets the mode to `decline`.
|
|
36
|
+
|
|
37
|
+
`examples/notes-app.ts` is a whole app on these (`src/example-app.test.ts` drives it). There is no `runSession` yet: it
|
|
38
|
+
needs the runtime's app-to-screen interface.
|
|
39
|
+
|
|
40
|
+
## Place in the stack
|
|
41
|
+
|
|
42
|
+
Above `runtime`, beside `nodes`. It may import `flow-spec`, `harness` and `runtime`, and Node's built-in modules.
|
|
43
|
+
`aielia` and `node-service` may import it. Browser code must not (`scripts/eslint-layers.mjs`).
|
|
44
|
+
|
|
45
|
+
## Development
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run typecheck:app-node
|
|
49
|
+
npm run test:app-node
|
|
50
|
+
npm run build:app-node
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The repository's root test run uses a browser-like environment, so a test file here starts with
|
|
54
|
+
`// @vitest-environment node`.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AppEvent, AppJob, AppOutcome, AppSession, Decision } from '@buildaharness/runtime';
|
|
2
|
+
import { CliHost } from './host.js';
|
|
3
|
+
/** What a person sees while an action runs (progress, stages, notes). Other events (decisions, the end) are for the caller. */
|
|
4
|
+
export declare function formatAppEvent(event: AppEvent): string | undefined;
|
|
5
|
+
/** A decision as the person is asked about it. */
|
|
6
|
+
export declare function formatDecision(decision: Decision): string;
|
|
7
|
+
export interface AppJobRun<R> {
|
|
8
|
+
outcome: AppOutcome<R>;
|
|
9
|
+
/** Every decision the action staged, in order. Answer them with `reviewDecision`. */
|
|
10
|
+
decisions: Decision[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Prints an action's progress until it ends and collects its decisions. Ctrl+C asks it to stop after the current step, a second
|
|
14
|
+
* one stops it at once. A stop or a failure is printed ("Stopped.", "Failed: ...") and comes back in `outcome`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function runAppJob<R>(host: CliHost, job: AppJob<R>): Promise<AppJobRun<R>>;
|
|
17
|
+
/** What is said of the result of an approved decision. Shapes are those of the shared file move and its undo. */
|
|
18
|
+
export declare function formatDecisionResult(result: unknown, o?: {
|
|
19
|
+
undoHint?: string;
|
|
20
|
+
}): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Shows a decision as it is now and applies it only on a yes to what was shown. With more than one item the person may leave
|
|
23
|
+
* some out. With nobody to ask (no terminal, or the non-interactive mode `decline`) it is declined. If it changed meanwhile the
|
|
24
|
+
* new one is shown instead, up to three times. Prints the outcome and returns it: `done` also when the person declined.
|
|
25
|
+
*/
|
|
26
|
+
export declare function reviewDecision(host: CliHost, session: AppSession, decision: Decision, o?: {
|
|
27
|
+
undoHint?: string;
|
|
28
|
+
}): Promise<AppOutcome<unknown>>;
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface ArgOption {
|
|
2
|
+
type: 'boolean' | 'string';
|
|
3
|
+
/** One letter. */
|
|
4
|
+
short?: string;
|
|
5
|
+
help: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ArgCommand {
|
|
8
|
+
help: string;
|
|
9
|
+
options?: Record<string, ArgOption>;
|
|
10
|
+
}
|
|
11
|
+
export interface ArgSpec {
|
|
12
|
+
name: string;
|
|
13
|
+
version: string;
|
|
14
|
+
summary?: string;
|
|
15
|
+
/** Accepted with or without a command. `--help` and `--version` are built in. */
|
|
16
|
+
options?: Record<string, ArgOption>;
|
|
17
|
+
/** A command is recognised only as the first argument. */
|
|
18
|
+
commands?: Record<string, ArgCommand>;
|
|
19
|
+
}
|
|
20
|
+
export type ParsedArgs = {
|
|
21
|
+
kind: 'help';
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'version';
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'error';
|
|
26
|
+
message: string;
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'run';
|
|
29
|
+
command?: string;
|
|
30
|
+
options: Record<string, string | boolean | undefined>;
|
|
31
|
+
words: string[];
|
|
32
|
+
};
|
|
33
|
+
/** `argv` is the user's arguments only, i.e. `process.argv.slice(2)`. */
|
|
34
|
+
export declare function parseCommandLine(argv: readonly string[], spec: ArgSpec): ParsedArgs;
|
|
35
|
+
export declare function commandLineHelp(spec: ArgSpec): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes `text` to `path` through a temp file in the same folder and a rename, so a crash mid-write never leaves half a file.
|
|
3
|
+
* The folder is made owner-only when it is new, and the file is owner-only (0600): the temp file is new each time, so the mode
|
|
4
|
+
* always applies and the rename carries it over an older, possibly world-readable, file.
|
|
5
|
+
*/
|
|
6
|
+
export declare function writeFileAtomic(path: string, text: string): Promise<void>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ProcessRunner, ToolGateHost } from '@buildaharness/runtime';
|
|
2
|
+
/** Runs a command with no stdin and piped output. Output is decoded a chunk at a time as UTF-8. */
|
|
3
|
+
export declare const createNodeProcessRunner: () => ProcessRunner;
|
|
4
|
+
/** Listens on an ephemeral loopback port: newline-delimited requests, one reply line each. */
|
|
5
|
+
export declare const createNodeToolGateHost: () => ToolGateHost;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface CommandSpec {
|
|
2
|
+
/** The command and any fixed subcommand words, no arguments: '/memory export'. The first word is the dispatch key. */
|
|
3
|
+
name: string;
|
|
4
|
+
/** What help prints for it, arguments included. */
|
|
5
|
+
usage: string;
|
|
6
|
+
description: string;
|
|
7
|
+
/** Other dispatch keys that run the same command ('/new' for '/clear'). */
|
|
8
|
+
aliases?: string[];
|
|
9
|
+
}
|
|
10
|
+
/** First word of a command name: the key a dispatch table matches on. */
|
|
11
|
+
export declare function commandKey(name: string): string;
|
|
12
|
+
/** One line per command: usage, padded, then the description. */
|
|
13
|
+
export declare function formatCommandHelp(commands: readonly CommandSpec[]): string;
|
|
14
|
+
/** A bare `exit` / `quit` (with or without a leading slash, any case) ends the session; anything longer is an ordinary message. An exact command match, not a reading of the message. */
|
|
15
|
+
export declare function isQuitCommand(message: string): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConsentStore } from '@buildaharness/runtime';
|
|
2
|
+
/**
|
|
3
|
+
* Keeps the accepted terms version in a JSON file: `{ "version": "...", "acceptedAt": "<ISO time>" }`. A missing or unreadable
|
|
4
|
+
* file reads as "none". The folder is made when it is missing.
|
|
5
|
+
*/
|
|
6
|
+
export declare function fileConsentStore(path: string): ConsentStore;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FsBackend } from '@buildaharness/runtime';
|
|
2
|
+
/**
|
|
3
|
+
* node:fs/promises-backed FsBackend.
|
|
4
|
+
*
|
|
5
|
+
* The same backend writes both an app's own state (transcripts, checkpoints, experience, reminders) and
|
|
6
|
+
* the user's workspace files. Only paths under a private root are made owner-only, like the config and
|
|
7
|
+
* activity log; other files keep the permissions they would get anyway.
|
|
8
|
+
*/
|
|
9
|
+
export declare function nodeFsBackend(options?: {
|
|
10
|
+
privateRoots?: string[];
|
|
11
|
+
}): FsBackend;
|
|
12
|
+
/**
|
|
13
|
+
* Size and SHA-256 of a file's bytes, `undefined` when it does not exist. For `createFileMover`'s `fingerprint`: unlike a text reading it
|
|
14
|
+
* tells two different binary files (Word, PDF, images) apart. Reads the whole file, so the caller limits what it asks about.
|
|
15
|
+
*/
|
|
16
|
+
export declare function nodeFileFingerprint(path: string): Promise<string | undefined>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps an app's own state directories out of version control when the workspace is inside a git repo, by adding them to
|
|
3
|
+
* `<gitdir>/info/exclude` — the per-clone ignore file git itself provides for this. The user's tracked `.gitignore` is never
|
|
4
|
+
* touched, and a non-git directory is left exactly as it was. Idempotent and best-effort: resolves with the entries it added
|
|
5
|
+
* and never rejects (a read-only .git must not stop the app from starting). The file work is done before the call returns.
|
|
6
|
+
*/
|
|
7
|
+
export declare function excludeFromGit(workspaceRoot: string, dirs: readonly string[], options?: {
|
|
8
|
+
appName?: string;
|
|
9
|
+
}): Promise<string[]>;
|
package/dist/host.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AppIdentity } from '@buildaharness/runtime';
|
|
2
|
+
import { CommandSpec } from './commands.js';
|
|
3
|
+
import { NonInteractiveMode } from './non-interactive.js';
|
|
4
|
+
import { SelectOption, YesNoAnswer } from './prompts.js';
|
|
5
|
+
export interface HostCommand extends CommandSpec {
|
|
6
|
+
/** Without `run`, the entry only appears in help (a subcommand of an entry that has it). */
|
|
7
|
+
run?(args: string[]): void | Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/** A reason the app refuses to start; show the message to the user as it is. */
|
|
10
|
+
export declare class StartupError extends Error {
|
|
11
|
+
}
|
|
12
|
+
export interface CliHost {
|
|
13
|
+
/** One line or block, control sequences removed. */
|
|
14
|
+
print(text: string): void;
|
|
15
|
+
/** The same filter, without the newline: for streamed output. */
|
|
16
|
+
write(text: string): void;
|
|
17
|
+
/** False when no answer can be read, and always in `decline` mode. */
|
|
18
|
+
confirm(question: string): Promise<boolean>;
|
|
19
|
+
/** `none`: no answer could be read. In `decline` mode the answer is `no`. */
|
|
20
|
+
yesNo(question: string): Promise<YesNoAnswer>;
|
|
21
|
+
/** Free text. Undefined when nothing could be read, and in `decline` mode (input is not touched). */
|
|
22
|
+
ask(question: string): Promise<string | undefined>;
|
|
23
|
+
/** The last option on any answer that names none. Put the safe choice last. */
|
|
24
|
+
select(question: string, options: readonly SelectOption[]): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Handles input until it closes or the user types `exit`/`quit`: registered commands run, every other non-empty line
|
|
27
|
+
* goes to `handle`, one at a time. Resolves when the queued lines have been handled, and closes the host.
|
|
28
|
+
*/
|
|
29
|
+
serve(handle?: (line: string) => Promise<void>): Promise<void>;
|
|
30
|
+
/** Ctrl+C goes to the newest listener instead of ending the session, while the host is reading a terminal. Returns the remover. */
|
|
31
|
+
onInterrupt(listener: () => void): () => void;
|
|
32
|
+
help(): string;
|
|
33
|
+
readonly nonInteractive: NonInteractiveMode | undefined;
|
|
34
|
+
close(): void;
|
|
35
|
+
}
|
|
36
|
+
export interface CliHostOptions {
|
|
37
|
+
identity: AppIdentity;
|
|
38
|
+
commands?: HostCommand[];
|
|
39
|
+
input?: NodeJS.ReadableStream;
|
|
40
|
+
output?: NodeJS.WritableStream;
|
|
41
|
+
/** Default: the `<envPrefix>_NON_INTERACTIVE_APPROVAL` environment variable, if set. */
|
|
42
|
+
nonInteractive?: NonInteractiveMode;
|
|
43
|
+
env?: Record<string, string | undefined>;
|
|
44
|
+
/** Shown by `serve` when input is a terminal. Default `> `. */
|
|
45
|
+
prompt?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function createCliHost(o: CliHostOptions): CliHost;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Node.js ports for apps built from Build A Harness parts. */
|
|
2
|
+
export { appPaths, BUILDAHARNESS_DIR } from './paths.js';
|
|
3
|
+
export { nodeFsBackend, nodeFileFingerprint } from './fs-backend.js';
|
|
4
|
+
export { jsonConfigStore } from './json-config-store.js';
|
|
5
|
+
export { fileSettingsStore } from './settings-store.js';
|
|
6
|
+
export { fileConsentStore } from './consent-store.js';
|
|
7
|
+
export { runShellCommand } from './shell.js';
|
|
8
|
+
export type { ShellCommandOptions } from './shell.js';
|
|
9
|
+
export { startNetworkContainment, getNetworkContainmentProxy, resetNetworkContainmentProxiesForTests } from './network-containment.js';
|
|
10
|
+
export type { NetworkContainmentProxy } from './network-containment.js';
|
|
11
|
+
export { excludeFromGit } from './git-exclude.js';
|
|
12
|
+
export { nodeResolver } from './resolver.js';
|
|
13
|
+
export { stripTerminalControls, oneLine, indentBlock } from './terminal.js';
|
|
14
|
+
export { createLineQueue } from './line-queue.js';
|
|
15
|
+
export { createPrompter } from './prompts.js';
|
|
16
|
+
export type { Prompter, PrompterOptions, PromptSource, SelectOption, YesNoAnswer } from './prompts.js';
|
|
17
|
+
export { resolveNonInteractiveMode } from './non-interactive.js';
|
|
18
|
+
export type { NonInteractiveMode } from './non-interactive.js';
|
|
19
|
+
export { commandKey, formatCommandHelp, isQuitCommand } from './commands.js';
|
|
20
|
+
export type { CommandSpec } from './commands.js';
|
|
21
|
+
export { parseCommandLine, commandLineHelp } from './args.js';
|
|
22
|
+
export type { ArgSpec, ArgCommand, ArgOption, ParsedArgs } from './args.js';
|
|
23
|
+
export { createCliHost, StartupError } from './host.js';
|
|
24
|
+
export type { CliHost, CliHostOptions, HostCommand } from './host.js';
|
|
25
|
+
export { formatJobEvent, runJob, formatPending, formatApproveResult, reviewApproval } from './render.js';
|
|
26
|
+
export type { ReviewOutcome } from './render.js';
|
|
27
|
+
export { formatAppEvent, formatDecision, formatDecisionResult, runAppJob, reviewDecision } from './app-render.js';
|
|
28
|
+
export type { AppJobRun } from './app-render.js';
|
|
29
|
+
export { createNodeProcessRunner, createNodeToolGateHost } from './claude-cli-node.js';
|
|
30
|
+
export { replaceBinary, cleanupStaleUpdateFiles, createNodeUpdateFiles, createFileUpdateCache } from './self-update-node.js';
|