@acryldev/blends 1.7.2 → 1.7.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/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acryldev/save",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Save the app to its own git repository, and share it: a repository of its own on GitHub, created and pushed only after a person confirms the plan. Refuses a file that holds a secret, and a private app going to a public remote.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/plugins/save/plugin.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"provides": [],
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@deepseek-ai/cordis": "4.0.4",
|
|
9
|
-
"@acryldev/app-persistence": "0.1.
|
|
9
|
+
"@acryldev/app-persistence": "0.1.3"
|
|
10
10
|
},
|
|
11
11
|
"mount": "add the scripts \"save\": \"node plugins/save/cli.ts\" and \"share\": \"node plugins/save/share-cli.ts\" to package.json; mount the plugin to give the agent a save_app tool",
|
|
12
12
|
"entries": {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `npm run share [-- --owner <account>]`: show what sharing this app would send, and ask. Only a plain yes at the
|
|
2
|
+
* `npm run share [-- --owner <account>] [--visibility private|public]`: show what sharing this app would send, and ask. Only a plain yes at the
|
|
3
|
+
* terminal sends it. --visibility decides who may see a new repository and is kept in blend.yaml (metadata.visibility).
|
|
3
4
|
* --json print the plan as JSON and send nothing (what a program, or an agent, reads)
|
|
4
5
|
* --confirm <plan> send exactly this plan (the JSON `--json` printed, as it is or base64url-encoded so no shell can change it), and nothing when
|
|
5
6
|
* the app no longer matches it: for a person's own surface that showed them the plan and took their yes (the ACRYL
|
|
@@ -48,9 +49,27 @@ async function main(argv: readonly string[]): Promise<number> {
|
|
|
48
49
|
const { values } = parseArgs({
|
|
49
50
|
args: [...argv],
|
|
50
51
|
strict: true,
|
|
51
|
-
options: {
|
|
52
|
+
options: {
|
|
53
|
+
owner: { type: 'string' },
|
|
54
|
+
visibility: { type: 'string' },
|
|
55
|
+
json: { type: 'boolean' },
|
|
56
|
+
confirm: { type: 'string' },
|
|
57
|
+
},
|
|
52
58
|
})
|
|
53
|
-
|
|
59
|
+
if (
|
|
60
|
+
values.visibility !== undefined &&
|
|
61
|
+
values.visibility !== 'private' &&
|
|
62
|
+
values.visibility !== 'public'
|
|
63
|
+
) {
|
|
64
|
+
console.error('not shared: --visibility is private or public')
|
|
65
|
+
return 1
|
|
66
|
+
}
|
|
67
|
+
const options = {
|
|
68
|
+
...(values.owner === undefined ? {} : { owner: values.owner }),
|
|
69
|
+
...(values.visibility === undefined
|
|
70
|
+
? {}
|
|
71
|
+
: { visibility: values.visibility as 'private' | 'public' }),
|
|
72
|
+
}
|
|
54
73
|
if (values.confirm !== undefined) {
|
|
55
74
|
const confirmed = readPlan(values.confirm)
|
|
56
75
|
if (!isPlan(confirmed)) {
|
package/plugins/save/share.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* same guards hold: no file that holds a secret, and a private app never goes to a public repository.
|
|
6
6
|
*/
|
|
7
7
|
import { spawnSync } from 'node:child_process'
|
|
8
|
-
import { readFileSync } from 'node:fs'
|
|
8
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
9
9
|
import { basename, join } from 'node:path'
|
|
10
10
|
import {
|
|
11
11
|
connectRemote,
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
type SecretFinding,
|
|
19
19
|
saveApp,
|
|
20
20
|
type Visibility,
|
|
21
|
+
withVisibility,
|
|
21
22
|
} from '@acryldev/app-persistence'
|
|
22
23
|
|
|
23
24
|
/** What a share would send, and where. */
|
|
@@ -50,6 +51,8 @@ export type ShareResult =
|
|
|
50
51
|
export interface ShareOptions {
|
|
51
52
|
/** The GitHub account or organization for a new repository; the signed-in account when absent. */
|
|
52
53
|
readonly owner?: string
|
|
54
|
+
/** Who may see a new repository; blend.yaml's metadata.visibility when absent. A share with it records it there, so later saves agree. */
|
|
55
|
+
readonly visibility?: Visibility
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
/** What a share needs from the computer; tests give their own. */
|
|
@@ -100,18 +103,19 @@ export function planShare(
|
|
|
100
103
|
ports: SharePorts = sharePorts(appRoot),
|
|
101
104
|
): SharePlan | ShareRefused {
|
|
102
105
|
const identity = readAppIdentity(manifestOf(appRoot))
|
|
106
|
+
const visibility = options.visibility ?? identity.visibility
|
|
103
107
|
const changes = ports.pending()
|
|
104
108
|
const remote = ports.git.remoteUrl()
|
|
105
109
|
if (remote !== undefined) {
|
|
106
110
|
const known = ports.hosting.visibilityOf(remote)
|
|
107
|
-
if (
|
|
111
|
+
if (visibility === 'private' && known === 'public')
|
|
108
112
|
return refused(
|
|
109
113
|
`this app is private (blend.yaml metadata.visibility) but its remote ${remote} is public. Make the remote private, or set visibility: public if you mean to open it`,
|
|
110
114
|
)
|
|
111
115
|
return {
|
|
112
116
|
repository: remote,
|
|
113
117
|
create: false,
|
|
114
|
-
visibility: known === 'unknown' ?
|
|
118
|
+
visibility: known === 'unknown' ? visibility : known,
|
|
115
119
|
changes,
|
|
116
120
|
}
|
|
117
121
|
}
|
|
@@ -125,7 +129,7 @@ export function planShare(
|
|
|
125
129
|
const name = repositoryName(identity.name ?? basename(appRoot))
|
|
126
130
|
if (name === '')
|
|
127
131
|
return refused('the app has no name to call its repository by (blend.yaml metadata.name)')
|
|
128
|
-
return { repository: `${owner}/${name}`, create: true, visibility
|
|
132
|
+
return { repository: `${owner}/${name}`, create: true, visibility, changes }
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
export const sameSharePlan = (a: SharePlan, b: SharePlan): boolean =>
|
|
@@ -147,7 +151,14 @@ export function shareApp(
|
|
|
147
151
|
return refused(
|
|
148
152
|
'the app changed since this plan was shown, so nothing was sent. Read the new plan and confirm it',
|
|
149
153
|
)
|
|
150
|
-
|
|
154
|
+
let manifestText = manifestOf(appRoot)
|
|
155
|
+
if (
|
|
156
|
+
options.visibility !== undefined &&
|
|
157
|
+
readAppIdentity(manifestText).visibility !== options.visibility
|
|
158
|
+
) {
|
|
159
|
+
manifestText = withVisibility(manifestText, options.visibility)
|
|
160
|
+
writeFileSync(join(appRoot, 'blend.yaml'), manifestText)
|
|
161
|
+
}
|
|
151
162
|
try {
|
|
152
163
|
let remote = now.repository
|
|
153
164
|
if (now.create) {
|