@synopackageland/cli 0.14.1 → 0.15.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.
Files changed (114) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +26 -16
  3. package/dist/build-spk/generator.d.ts +3 -2
  4. package/dist/build-spk/generator.js +6 -846
  5. package/dist/build-spk/resource-worker.d.ts +2 -14
  6. package/dist/build-spk/resource-worker.js +3 -166
  7. package/dist/cli.js +208 -56
  8. package/dist/compose/analyze.d.ts +3 -61
  9. package/dist/compose/analyze.js +35 -776
  10. package/dist/compose/env.d.ts +5 -3
  11. package/dist/compose/env.js +17 -25
  12. package/dist/compose/runner.js +23 -6
  13. package/dist/contract/web-launch.d.ts +1 -12
  14. package/dist/contract/web-launch.js +10 -74
  15. package/dist/ctl/cli.d.ts +36 -0
  16. package/dist/ctl/cli.js +218 -0
  17. package/dist/ctl/descriptor.d.ts +81 -0
  18. package/dist/ctl/descriptor.js +93 -0
  19. package/dist/ctl/dsm-auth.d.ts +10 -0
  20. package/dist/ctl/dsm-auth.js +30 -0
  21. package/dist/ctl/errors.d.ts +17 -0
  22. package/dist/ctl/errors.js +32 -0
  23. package/dist/ctl/flows.d.ts +11 -0
  24. package/dist/ctl/flows.js +52 -0
  25. package/dist/ctl/input.d.ts +20 -0
  26. package/dist/ctl/input.js +128 -0
  27. package/dist/ctl/json.d.ts +2 -0
  28. package/dist/ctl/json.js +38 -0
  29. package/dist/ctl/redaction.d.ts +15 -0
  30. package/dist/ctl/redaction.js +198 -0
  31. package/dist/ctl/service.d.ts +38 -0
  32. package/dist/ctl/service.js +156 -0
  33. package/dist/ctl/store.d.ts +51 -0
  34. package/dist/ctl/store.js +93 -0
  35. package/dist/ctl/transfers.d.ts +14 -0
  36. package/dist/ctl/transfers.js +74 -0
  37. package/dist/ctl/transport.d.ts +11 -0
  38. package/dist/ctl/transport.js +79 -0
  39. package/dist/deploy/deploy.d.ts +4 -3
  40. package/dist/deploy/deploy.js +5 -210
  41. package/dist/deploy/plan.js +26 -7
  42. package/dist/dev.js +5 -4
  43. package/dist/error-registry.js +1020 -834
  44. package/dist/info.js +120 -28
  45. package/dist/init.js +188 -64
  46. package/dist/inspect.js +21 -6
  47. package/dist/runtime/executor-digests.json +1 -12
  48. package/dist/skill.js +51 -9
  49. package/dist/standalone/api-description-inspect.d.ts +4 -0
  50. package/dist/standalone/api-description-inspect.js +12 -0
  51. package/dist/standalone/api-description.d.ts +7 -0
  52. package/dist/standalone/api-description.js +73 -0
  53. package/dist/standalone/build.d.ts +3 -0
  54. package/dist/standalone/build.js +140 -33
  55. package/dist/standalone/compose-errors.d.ts +3 -0
  56. package/dist/standalone/compose-errors.js +243 -0
  57. package/dist/standalone/compose.d.ts +97 -10
  58. package/dist/standalone/compose.js +306 -75
  59. package/dist/standalone/daemon.js +111 -29
  60. package/dist/standalone/dsm-window.js +39 -8
  61. package/dist/standalone/identity-gateway.d.ts +9 -2
  62. package/dist/standalone/identity-gateway.js +282 -66
  63. package/dist/standalone/inspect-spk.d.ts +12 -0
  64. package/dist/standalone/inspect-spk.js +666 -136
  65. package/dist/standalone/lifecycle.js +124 -42
  66. package/dist/standalone/manifest.d.ts +8 -1
  67. package/dist/standalone/manifest.js +303 -86
  68. package/dist/standalone/resource.js +6 -2
  69. package/dist/standalone/spk.d.ts +4 -1
  70. package/dist/standalone/spk.js +138 -39
  71. package/dist/template-paths.d.ts +0 -2
  72. package/dist/template-paths.js +0 -5
  73. package/dist/test-command.d.ts +1 -1
  74. package/dist/test-command.js +1 -1
  75. package/dist/validate.d.ts +3 -3
  76. package/dist/validate.js +32 -140
  77. package/package.json +5 -3
  78. package/schema/synopkgland-api-v1.schema.json +423 -0
  79. package/skills/SKILL.md +3 -1
  80. package/skills/reference/compose.md +349 -0
  81. package/skills/reference/create.md +8 -17
  82. package/skills/reference/ctl.md +41 -0
  83. package/skills/reference/deploy.md +1 -1
  84. package/skills/reference/files.md +4 -0
  85. package/skills/reference/identity-gateway.md +8 -144
  86. package/skills/reference/wrap.md +10 -39
  87. package/assets/go/daemon/fixture_linux_test.go +0 -15
  88. package/assets/go/daemon/fixture_other_test.go +0 -7
  89. package/assets/go/daemon/go.mod +0 -5
  90. package/assets/go/daemon/main.go +0 -636
  91. package/assets/go/daemon/main_test.go +0 -315
  92. package/assets/go/daemon/network.go +0 -107
  93. package/assets/go/daemon/network_test.go +0 -86
  94. package/assets/go/daemon/process_linux.go +0 -55
  95. package/assets/go/daemon/process_linux_test.go +0 -161
  96. package/assets/go/daemon/process_other.go +0 -14
  97. package/assets/go/daemon/testdata/child.go +0 -44
  98. package/assets/go/gateway/auth.go +0 -101
  99. package/assets/go/gateway/auth_test.go +0 -216
  100. package/assets/go/gateway/cgi.go +0 -133
  101. package/assets/go/gateway/cgi_test.go +0 -156
  102. package/assets/go/gateway/csrf.go +0 -73
  103. package/assets/go/gateway/csrf_test.go +0 -155
  104. package/assets/go/gateway/directory.go +0 -108
  105. package/assets/go/gateway/directory_test.go +0 -202
  106. package/assets/go/gateway/gateway.go +0 -412
  107. package/assets/go/gateway/gateway_test.go +0 -676
  108. package/assets/go/gateway/go.mod +0 -5
  109. package/assets/go/gateway/groups.go +0 -66
  110. package/assets/go/gateway/main.go +0 -45
  111. package/dist/build-spk/gateway.d.ts +0 -31
  112. package/dist/build-spk/gateway.js +0 -60
  113. package/dist/compose/privilege.d.ts +0 -14
  114. package/dist/compose/privilege.js +0 -102
@@ -17,8 +17,8 @@ or expected behavior. An unknown answer is not a pass.
17
17
  | Is data private to each app user? | Test two ordinary users in both directions, including search, shares, downloads and APIs. OpenList needs distinct `base_path` and permissions; JIT alone does not create private storage. Jellyfin library visibility is not proof of object-level isolation. Paperless owner-NULL objects can become visible to everyone: deleting a user before their documents can expose them. Ask whether shared data is intended; do not promise isolation the app lacks. |
18
18
  | What starts login, and which base/callback paths does the app use? | Verify redirects, trailing slash, query and HTTP/HTTPS behavior. `redirects` accepts local paths without a query. OIDC callbacks require exact allowlists; `rewrite_json` handles supported JSON login redirects. Test the actual desktop/bare-root entry separately from a direct SSO URL. |
19
19
  | What really controls the listen address and port? | Verify the exact upstream environment/config key and actual kernel listener. OpenList uses `ADDR`, not `ADDRESS`. Set `127.0.0.1`; turn off every auxiliary public listener (FTP/SFTP/S3/debug/metrics as applicable). |
20
- | Can every container run at an arbitrary non-root UID/GID? | Require package UID/GID materialization, `cap_drop: [ALL]`, `no-new-privileges:true`, and `network_mode: host` for every service. Bridge cannot reach the native loopback issuer. Host networking shares the NAS network namespace; it is not network isolation. An image that needs root or extra privileges is unsupported by this policy. |
21
- | Where is data kept, and when does it exist? | Bind DSM's persistent `${SYNOPKG_PKGVAR}` root. DSM creates and owns it before resource acquisition; preinst only writes incoming `compose/.env`, never mkdir/chown `@appdata`. Do not mount upgrade-replaced `target/compose/data`. Test an actual package upgrade. Current support has no external share mounts, named volumes, extra Compose files or container secrets/config resources. |
20
+ | Can every container run at an arbitrary non-root UID/GID? | Use package UID/GID by default, cap_drop ALL and no-new-privileges. Only verified OIDC consumers need host networking. Explicit container-root is bounded to bridge and named volumes; test image compatibility. See compose.md. |
21
+ | Where is data kept, and when does it exist? | Declare private storage differences; the nonroot SDK prepare checks DSM-owned pkgvar and creates bounded private subdirectories. Ownership/timing is a device blocker. Named volumes and local multiple files are supported; external Shares and file secret/config delivery remain unsupported. |
22
22
  | What deletes the app account, sessions and owned data? | Use the supported CLI/REST interface through native `account.on_delete.exec`, then explicitly scoped `remove`. Keep secrets in package-owned 0600 files and directories in 0700. OpenList REST user deletion does not remove physical `base_path` files. Shared files need an explicit retention decision. Make deletion idempotent; inspect pending failures and verify readback. |
23
23
  | What happens when DSM disables the user or logs out? | New DSM sign-ins must fail. Existing app sessions, API tokens, download links or gateway sessions may remain until expiry; document the measured gap. Do not claim immediate revocation or add a root account watcher. |
24
24
  | Must native/mobile clients work? | Verify their actual flow: app passwords/API tokens, Jellyfin Quick Connect, or OIDC in the system browser. Use exact `native_redirects` custom schemes where supported. Passthrough grants no DSM session protection; document app authentication and revocation for each allowed prefix. Browser success is not mobile success. |
@@ -31,150 +31,14 @@ or use `account.snapshot`. Failed local delete actions remain pending and retry
31
31
  with backoff. Domain/LDAP disappearances require explicit `gateway account
32
32
  status` / `gateway account purge`; never infer deletion from an NSS outage.
33
33
 
34
- ## OpenList container example
34
+ ## Compose declaration
35
35
 
36
- Start with a schema-2 native-go or binary project for the native CGI and package
37
- UI. Add `compose` to **dsm-package.yaml**; do not combine the legacy
38
- `synology-app.yaml` Compose contract with it. Omit `daemon`. Set `os_min_ver` to
39
- at least `7.2.1-69057`, `capabilities: {}`, and supply one helper payload directory
40
- per architecture. The examples below pin released SDK 0.14.1, which contains the gateway/account APIs.
36
+ Read [compose.md](compose.md) for the current schema-2 route, examples and support boundary. No dummy backend or helper directory is required. Upstream files stay unchanged; the SDK planner compiles an override and one worker model. Mode none retains native login, while header/token/OIDC use upstream-supported identity integration. There is no SSO Server.
41
37
 
42
- ```yaml
43
- compose:
44
- file: compose.yaml
45
- targets: {x86_64: helpers}
46
- services:
47
- openlist: {address_env: ADDR, port: 25244}
48
- identity_gateway:
49
- sdk: 0.14.1
50
- mode: oidc
51
- upstream: 25244
52
- listen: {http: 25240, https: 25241}
53
- oidc:
54
- issuer_port: 25249
55
- clients:
56
- - id: openlist
57
- redirect_paths: [/api/auth/sso_callback, /api/auth/sso_get_token]
58
- account:
59
- on_delete:
60
- - exec: [bin/openlist-glue, delete-user, "{uid}"]
61
- - remove: users/{uid}
62
- ```
38
+ Default networking is bridge with one loopback ingress. OIDC consumers of the native loopback issuer require explicit verified host networking and address_env; this does not force unrelated services onto host networking. Named volumes and multiple local files are supported by the planner. Existing Shared Folders remain blocked until official protected mount authority and project control are verified.
63
39
 
64
- `compose.yaml` (replace `IMAGE_DIGEST` with the verified official image digest):
40
+ Containers use a fixed package identity and do not inherit the signed-in user's File Station ACL. App account mapping is separate from filesystem authority. Per-user file access requires a session/Broker Adapter, outside the mount feature.
65
41
 
66
- ```yaml
67
- services:
68
- openlist:
69
- image: openlistteam/openlist@sha256:IMAGE_DIGEST
70
- network_mode: host
71
- user: "${SYNOPKGLAND_UID}:${SYNOPKGLAND_GID}"
72
- cap_drop: [ALL]
73
- security_opt: [no-new-privileges:true]
74
- restart: "no"
75
- environment:
76
- ADDR: 127.0.0.1
77
- HTTP_PORT: "25244"
78
- HTTPS_PORT: "-1"
79
- LOG_ENABLE: "false"
80
- volumes: ["${SYNOPKG_PKGVAR}:/opt/openlist/data"]
81
- ```
42
+ For native Apps, retain the existing daemon, identity_gateway and account.on_delete declarations. Use fixed native argv adapters and package-private paths for deletion; the gateway never writes an upstream database. Test rename, demotion, two-user visibility, stale credentials and account deletion against the actual upstream image.
82
43
 
83
- Verify the current OpenList settings API, then have package-account app glue
84
- configure `sso_login_enabled=true`, `sso_login_platform=OIDC`,
85
- `sso_client_id=openlist`, `sso_client_secret` from
86
- `var/sso/client-openlist.secret`, `sso_oidc_username_key=sub`,
87
- `sso_endpoint_name=http://127.0.0.1:25249`, `sso_auto_register=true` and the
88
- required compatibility setting. Keep bootstrap/admin credentials in a private
89
- file, never argv/logs. The helper `helpers/bin/openlist-glue` is a project-owned
90
- native executable: `delete-user UID` lists users, selects the exact ordinary
91
- account by SSO subject, deletes through REST, and reads back absence. It returns
92
- success if already absent and never deletes the bootstrap admin.
93
-
94
- Configure a tested upstream JIT path policy before promising private files.
95
- `remove: users/{uid}` deletes only that directory **under package var**; it is
96
- not automatic cleanup of an arbitrary OpenList storage provider. The app's
97
- SSO entry can be `/api/auth/sso?method=sso_get_token`; that query URL is not a
98
- valid `identity_gateway.redirects` value. Test and document the entry you ship.
99
-
100
- Startup order is DSM resource acquisition -> Container Manager starts the
101
- project -> the native controller waits up to its bounded start deadline for
102
- **all declared service ports**, owned by the package UID, at 127.0.0.1 ->
103
- `gateway run` without a child. The controller checks IPv4/IPv6 TCP and UDP
104
- bindings every second and closes the gateway on missing/unsafe upstreams.
105
- Public TCP listener exceptions are only the declared gateway ports. Package
106
- stop/preupgrade/preuninst stop the gateway before DSM releases the project;
107
- no package code calls Docker or uses its socket. Startup/monitor failure closes
108
- gateway ingress and fails package health; resource rollback/release belongs to
109
- DSM/Container Manager. The guard cannot stop a misconfigured container or act
110
- as a firewall: correct bindings must be established before deployment.
111
-
112
- ## Audiobookshelf native example
113
-
114
- Use the existing native `daemon` route. A project-owned `absglue run` launches
115
- the unmodified ABS binary, binds it to loopback with the supported host/base
116
- path settings, configures OIDC through its API, and supervises it. The same
117
- helper implements idempotent deletion. The example pins released SDK 0.14.1.
118
-
119
- ```yaml
120
- daemon:
121
- exec: bin/absglue
122
- targets: {x86_64: payload}
123
- args: [run]
124
- identity_gateway:
125
- sdk: 0.14.1
126
- mode: oidc
127
- upstream: 13378
128
- listen: {http: 13380, https: 13443}
129
- redirects: {"/": /audiobookshelf/}
130
- oidc:
131
- issuer_port: 13390
132
- clients:
133
- - id: abs
134
- redirect_paths: [/audiobookshelf/auth/openid/callback]
135
- pkce: true
136
- roles: {claim: groups, admin: admin, user: user}
137
- account:
138
- on_delete:
139
- - exec: [bin/absglue, delete-user, "{name}"]
140
- - remove: users/{uid}
141
- ```
142
-
143
- Verify ABS's current `openidAutoLaunch`, auto-registration, username/sub
144
- matching and `groups` mapping through its API. Test promotion and demotion at
145
- sign-in. `delete-user` must handle sessions, feeds/shares and retention in the
146
- correct order when those features are used; deleting a library does not imply
147
- deleting audio files. A minimal fixture directory is not proof of full purge.
148
-
149
- ## Before calling it done
150
-
151
- - Run `check --json`, `build --json`, and `inspect <final-spk> --json` with the
152
- installed CLI. Run the affected CLI/SDK gates, not only a patched PoC.
153
- - Use fresh ordinary/admin DSM browser sessions over each requested scheme;
154
- prove zero-click sign-in, record the exact entry URL, stable subject and app
155
- identity. Test signed-out/fake-identity requests. Do not log tokens, cookies,
156
- assertions, URL queries or `/proc/*/cmdline`.
157
- - Read back admin/user roles and a demotion after another sign-in. Mark the
158
- accepted OpenList role limitation explicitly; never manufacture a pass.
159
- - Prove two ordinary users cannot read each other's intended private objects,
160
- including NULL-owner/shared-link behavior. Record what was actually tested.
161
- - Create only task-owned test users/data. Delete a DSM user and observe the
162
- automatic native REST/CLI delete **and** owned file removal; read gateway
163
- pending status and app absence. Restart with a pending deletion to exercise
164
- readiness/retry. Preserve shared data unless its removal is authorized.
165
- - Disable a test user; show new SSO is blocked over both schemes. Probe the old
166
- app token separately and report its actual lifetime/revocation behavior.
167
- - Inspect actual upstream/issuer listeners, UID and `CapEff: 0`, including CGI
168
- and every container. From a second LAN host, prove upstream/issuer cannot be
169
- reached, with the gateway as a positive reachability control.
170
- - Write package-owned data, upgrade the SPK, and read back the same data,
171
- ownership and sign-in/deletion state. Test stop/start and failure health.
172
- - Clean up only task-owned users, package/project/containers/images, private
173
- fixtures and test resources. Read back absence. Keep DSM-retained package
174
- identities unless their deletion was authorized, and report their names.
175
-
176
- Schema 2 的 `dsm-package.yaml` + `identity_gateway` + `compose` 同樣視為
177
- web service:省略 `ui.launch` 時預設 `new-page`,使用 standalone launcher,
178
- 不帶 Application Portal。兩條 Compose 路線共用 `contract/app-launch.ts`
179
- 解析開啟方式與選擇 launcher 型別;明確的 `ui.launch` 可覆寫預設。
180
- 只有沒有 web service 的 SDK 原生 App 省略時才預設 `dsm-window`。
44
+ Bridge readiness is availability only: declared App health + loopback TCP + the current-version SDK lifecycle acquire generation. It cannot attest actual image/project/generation: another process already executing on the NAS can occupy the port. This local-code-execution threat is accepted; restore official full readback when available. Never use root, Docker socket access or borrowed admin credentials. See compose.md.
@@ -1,45 +1,16 @@
1
- # 封裝(Wrap)
1
+ # 封裝上游 Compose
2
2
 
3
- 已有 Compose 或要補齊 App Contract 時使用。權威仍是 schema + `check`。
3
+ 只使用 schema-2 `dsm-package.yaml`。先讀 [compose.md](compose.md) 的宣告、支援表及 DSM 阻擋條件,再讀 [identity-gateway.md](identity-gateway.md) 決定 none/header/token/OIDC。不架 SSO Server,也不需要假 backend 或 wrapper container。
4
4
 
5
- ## 命令
6
-
7
- ```bash
8
- synopkgland check # 契約、Compose 意圖與 Web entry 提示
5
+ ```sh
6
+ synopkgland init -t compose --from ./compose.yaml my-app
7
+ synopkgland check --json
8
+ synopkgland build --arch x86_64
9
+ synopkgland inspect dist/MyApp-x86_64.spk --json
9
10
  ```
10
11
 
11
- ## 契約允許什麼(v1 schema 1)
12
-
13
- 必填:`schema`、`package`、`version`、`displayname`、`description`、`maintainer`、`os_min_ver`。
14
-
15
-
16
-
17
- For DSM-account SSO around OSS, first read [identity-gateway.md](identity-gateway.md).
18
- It defines the separate schema-2 `compose` + `identity_gateway` host-network policy;
19
- the legacy Compose route below retains its restrictions.
20
-
21
- ## Compose 規則(analyzer 會擋)
22
-
23
- - 禁止:`privileged`、`network_mode: host`、裝置節點、`cap_add`、掛載 Docker socket。
24
- - `adminport` 必須對應到某 service 的 published TCP port。
25
- - `install` 參數須在 `compose.yaml` 以 `${NAME}` 引用。
26
-
27
- ## 包現成 Compose 的掛載
28
-
29
- 容器路徑跟映像/upstream 的 container target 走,原樣保留;只把 host source 換成 `${NAME}` 這類 install parameter。原有的 upstream named volume mount 與頂層 `volumes:` 宣告也保留,不要為了套模板改成 `/data`。需要既有 Share 時,管理員在安裝時選這台 NAS 的 Share。
30
-
31
- 修復方式:看 `check` 輸出的 `[錯誤碼]` 與 `Suggestion:` 行,對照 `diagnose.md`。**不要**為了過驗證而亂改 runtime 語意。
32
-
33
- ## 下一步
34
-
35
- - 要身分/檔案整合 → `identity.md`/`files.md`
36
- - 要上 NAS → `deploy.md`
12
+ 上游 bytes 不改;CLI 只做工具,SDK reference planner 產生 override 與 worker 單檔。修正錯誤時看 code/原因/建議,不為通過驗證改掉上游語義。共用 launch resolver 解析 ui.launch,預設 new-page;classless gateway 使用 type url。
37
13
 
38
- ## 開啟方式
14
+ 容器使用固定套件身分,不繼承登入者 File Station ACL。Shared Folder 需 composeMounts 明確 opt-in,安裝後由 admin 確認;官方 protected ACL/project control 未驗證前只啟動 SDK 設定頁,不 acquire 上游,不用 host root 繞過。每使用者檔案權限需 session/Broker Adapter,本次不做。
39
15
 
40
- Docker/web service App 的 `integration.web.launch` 內建預設為 `new-page`。
41
- 主選單與套件中心開啟既有 gateway,不產生 Application Portal。
42
- schema 1 新分頁 launcher 使用 `type: "url"` 與明確 `url`;DSM 的 standalone
43
- 會改寫成需要 AppWindow JS class 的 launchApp 頁面。schema 2 SDK wrapper
44
- 有此 class,因此使用 standalone。只有 `access: public` 需要 Web Station alias。
45
- SDK 原生 App 的 `ui.launch` 內建預設是 `dsm-window`;非 UI SDK 前端明寫 `new-page`。
16
+ 交付 inspect 的 upstream/effective hashes、image digests、run-as、mount、egress 與 acceptance blockers。Linux 通過不代表 DSM 已驗收。部署請讀 [deploy.md](deploy.md),保留資料並由專用 thread 驗 final SPK digest。
@@ -1,15 +0,0 @@
1
- //go:build linux
2
-
3
- package main
4
-
5
- import (
6
- "os"
7
- "os/exec"
8
- "syscall"
9
- )
10
-
11
- func dropFixtureUser(cmd *exec.Cmd) {
12
- if os.Geteuid() == 0 {
13
- cmd.SysProcAttr = &syscall.SysProcAttr{Credential: &syscall.Credential{Uid: 65534, Gid: 65534, Groups: []uint32{65534}}}
14
- }
15
- }
@@ -1,7 +0,0 @@
1
- //go:build !linux
2
-
3
- package main
4
-
5
- import "os/exec"
6
-
7
- func dropFixtureUser(cmd *exec.Cmd) {}
@@ -1,5 +0,0 @@
1
- module synopkgland-daemon
2
-
3
- go 1.24
4
-
5
- toolchain go1.26.9