@foldspace_npm/harness 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -31
- package/bin/attach.mjs +779 -107
- package/bin/cli.mjs +139 -11
- package/bin/deploy.mjs +37 -33
- package/bin/inject.mjs +64 -295
- package/package.json +6 -7
- package/src/action-observer.mjs +271 -0
- package/src/attach-helpers.mjs +162 -0
- package/src/attach-preflight.mjs +332 -0
- package/src/bootstrap-script.mjs +120 -0
- package/src/cdp-request-manager.mjs +61 -0
- package/src/cli-help.mjs +143 -0
- package/src/cli-registry.mjs +309 -0
- package/src/diagnostics.mjs +482 -0
- package/src/init.mjs +192 -18
- package/src/project-config.mjs +37 -0
- package/src/protocol.mjs +181 -0
- package/src/session-summary.mjs +133 -0
- package/templates/agent-starter/CLAUDE.md +31 -8
- package/templates/agent-starter/README.md +26 -3
- package/templates/agent-starter/foldspace.dev.json +1 -3
- package/templates/agent-starter/package.json +4 -4
- package/bin/buildExtension.mjs +0 -90
- package/bin/packageExtension.mjs +0 -29
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @foldspace_npm/harness
|
|
2
2
|
|
|
3
|
-
Build
|
|
3
|
+
Build the portable `dist/index.js` action artifact and verify it against a live
|
|
4
|
+
app.
|
|
4
5
|
|
|
5
6
|
**This package is the part that is the same in both architectures.** Everything
|
|
6
7
|
else about how a builder runs differs between them; this does not.
|
|
@@ -13,7 +14,7 @@ else about how a builder runs differs between them; this does not.
|
|
|
13
14
|
|---|---|---|
|
|
14
15
|
| Who runs the agent | Claude Code on the builder's desktop | Claude Agent SDK in GCP |
|
|
15
16
|
| Whose browser | an isolated Chrome the harness launches | the user's **own** Chrome |
|
|
16
|
-
| How code reaches the page | CDP
|
|
17
|
+
| How code reaches the page | harness CDP preparation | builder extension loads the cloud artifact |
|
|
17
18
|
| Prerequisites | Claude Code, a client repo, Node, an isolated Chrome profile | the extension installed |
|
|
18
19
|
| Session and cookies | in a profile the harness creates | the user's own, untouched |
|
|
19
20
|
| Code and history | a git repo on the builder's machine | a workspace in the hosted environment |
|
|
@@ -26,8 +27,8 @@ constraint this package exists to protect.
|
|
|
26
27
|
|
|
27
28
|
- `agent/actions/*` and `agent/api/*` — a handler is `fetch` plus `runTask`,
|
|
28
29
|
nothing more. The actions built for Figma run unmodified in either track.
|
|
29
|
-
- `foldspace
|
|
30
|
-
- `foldspace
|
|
30
|
+
- `foldspace build` — esbuild → `dist/index.js`
|
|
31
|
+
- `foldspace deploy` — publish to `agent/actions/<env>/<productId>/<agentApiName>`
|
|
31
32
|
- fixtures and tests
|
|
32
33
|
- **the verb interface** below
|
|
33
34
|
|
|
@@ -50,20 +51,49 @@ exact failure this package was created to end. And the verb interface only stays
|
|
|
50
51
|
honest while both implementations sit behind it; separate them and "the same
|
|
51
52
|
action runs in both modes" quietly stops being true.
|
|
52
53
|
|
|
53
|
-
A hosted
|
|
54
|
-
|
|
54
|
+
A hosted environment uses the same action source and build contract, but local
|
|
55
|
+
`inject` and `attach` remain CDP-only commands. The harness does not generate a
|
|
56
|
+
customer application extension.
|
|
55
57
|
|
|
56
58
|
---
|
|
57
59
|
|
|
58
60
|
## Use
|
|
59
61
|
|
|
62
|
+
### Discover the CLI
|
|
63
|
+
|
|
64
|
+
Human-readable help is grouped by workflow:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
foldspace help
|
|
68
|
+
foldspace help attach
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Coding agents can inspect the same versioned command and capability contract:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
foldspace help --json
|
|
75
|
+
foldspace help attach --json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The installed `harness` binary is an alias for `foldspace`.
|
|
79
|
+
|
|
80
|
+
The JSON describes current options, prerequisites, side effects, risks,
|
|
81
|
+
capabilities, and next steps. It does not claim that future hosted-environment
|
|
82
|
+
capability enforcement is already implemented.
|
|
83
|
+
|
|
60
84
|
### Create a project
|
|
61
85
|
|
|
62
86
|
Create a configured actions project from the template bundled with the installed
|
|
63
|
-
harness version:
|
|
87
|
+
harness version. Missing values are prompted when stdin is a terminal:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx --yes @foldspace_npm/harness init
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Non-interactive / CI form:
|
|
64
94
|
|
|
65
95
|
```bash
|
|
66
|
-
|
|
96
|
+
npx --yes @foldspace_npm/harness init my-agent \
|
|
67
97
|
--product-id FR8JUQZAQRZB \
|
|
68
98
|
--agent-api-name my-agent \
|
|
69
99
|
--domain app.example.com \
|
|
@@ -79,24 +109,17 @@ node bin/cli.mjs init ../my-agent \
|
|
|
79
109
|
--domain app.example.com
|
|
80
110
|
```
|
|
81
111
|
|
|
82
|
-
Until `@foldspace_npm/harness` is published, install the local checkout in the
|
|
83
|
-
generated project instead of running the standard install step:
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
cd ../my-agent
|
|
87
|
-
npm install --ignore-scripts --save-dev /absolute/path/to/harness
|
|
88
|
-
```
|
|
89
|
-
|
|
90
112
|
`--name` is optional and defaults to the target directory name. The product ID
|
|
91
113
|
must be the bare ID, not an `EU-…` SDK key. The domain may be a hostname or an
|
|
92
114
|
HTTP(S) URL without a port or path.
|
|
93
115
|
|
|
94
116
|
For safety, `init` requires a target path that does not exist. It does not
|
|
95
|
-
|
|
117
|
+
initialize Git or overwrite files. On a TTY it can offer
|
|
118
|
+
`npm install --ignore-scripts` after scaffolding. After creation:
|
|
96
119
|
|
|
97
120
|
```bash
|
|
98
121
|
cd my-agent
|
|
99
|
-
npm install --ignore-scripts
|
|
122
|
+
npm install --ignore-scripts # if you skipped the install prompt
|
|
100
123
|
npm run build
|
|
101
124
|
npm run inject
|
|
102
125
|
npm run attach
|
|
@@ -105,6 +128,35 @@ npm run attach
|
|
|
105
128
|
The generated npm scripts intentionally remain the normal project interface;
|
|
106
129
|
`foldspace init` is the one-time project creation command.
|
|
107
130
|
|
|
131
|
+
### Choose an attach mode
|
|
132
|
+
|
|
133
|
+
- **Swap (default):** the page already uses the configured product and agent.
|
|
134
|
+
- **Bootstrap (`--bootstrap`):** the page has no Foldspace SDK.
|
|
135
|
+
- **Replace (`--replace`):** the page embeds a different product or agent, or
|
|
136
|
+
has an SDK without the configured agent.
|
|
137
|
+
|
|
138
|
+
Use `foldspace help attach` for mode requirements, effects, and safety options.
|
|
139
|
+
|
|
140
|
+
### Verify actions through the agent
|
|
141
|
+
|
|
142
|
+
`foldspace attach` does not invoke action handlers directly. It loads the local
|
|
143
|
+
artifact, verifies that its action names exactly match the configured SDK agent,
|
|
144
|
+
and then observes action callbacks while you exercise the normal agent
|
|
145
|
+
experience.
|
|
146
|
+
|
|
147
|
+
Action output identifies SDK callbacks and local `execute`/`render` phases:
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
[actions] sdk:action show_account_360 executed
|
|
151
|
+
[actions] local-handler:execute show_account_360 succeeded 412ms
|
|
152
|
+
[actions] local-handler:render show_account_360 succeeded 18ms
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Only action names, parameter keys, statuses, and durations are recorded; handler
|
|
156
|
+
parameter values, results, and error messages are not. On detach, repeated page
|
|
157
|
+
failures and bounded action observations are summarized. The observer and
|
|
158
|
+
diagnostics are injected by the harness, so `dist/index.js` is not rewritten.
|
|
159
|
+
|
|
108
160
|
### Add the harness to an existing project
|
|
109
161
|
|
|
110
162
|
```bash
|
|
@@ -113,26 +165,22 @@ npm i -D @foldspace_npm/harness
|
|
|
113
165
|
|
|
114
166
|
```json
|
|
115
167
|
{ "scripts": {
|
|
116
|
-
"dev": "foldspace
|
|
117
|
-
"build": "foldspace
|
|
118
|
-
"inject": "foldspace
|
|
119
|
-
"attach": "foldspace
|
|
120
|
-
"deploy": "foldspace
|
|
168
|
+
"dev": "foldspace build --watch",
|
|
169
|
+
"build": "foldspace build",
|
|
170
|
+
"inject": "foldspace inject",
|
|
171
|
+
"attach": "foldspace attach",
|
|
172
|
+
"deploy": "foldspace deploy"
|
|
121
173
|
} }
|
|
122
174
|
```
|
|
123
175
|
|
|
124
|
-
| Command | A | B |
|
|
125
|
-
|---|:--:|:--:|
|
|
126
|
-
| `foldspace init` | ✅ | ✅ |
|
|
127
|
-
| `foldspace-build` | ✅ | ✅ |
|
|
128
|
-
| `foldspace-deploy` | ✅ | ✅ — it *is* the delivery mechanism |
|
|
129
|
-
| `foldspace-inject` | ✅ | — no browser to launch |
|
|
130
|
-
| `foldspace-attach` | ✅ | replaced by the extension bridge |
|
|
131
|
-
|
|
132
176
|
Every command resolves the **consuming** repo — `process.cwd()`, or
|
|
133
177
|
`FOLDSPACE_PROJECT_DIR` so a hosted builder can point it at a workspace it
|
|
134
178
|
controls. Config comes from the consumer's `foldspace.dev.json`.
|
|
135
179
|
|
|
180
|
+
`foldspace deploy` is an explicit remote publication step that reads product
|
|
181
|
+
and agent identity from the selected target in `foldspace.dev.json`. It requires
|
|
182
|
+
local cloud credentials and is separate from local verification.
|
|
183
|
+
|
|
136
184
|
---
|
|
137
185
|
|
|
138
186
|
## Why this package exists at all
|