@hasna/instructions 0.5.5 → 0.6.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/README.md +64 -20
- package/dist/cli/fail-closed-no-env.test.d.ts +2 -0
- package/dist/cli/fail-closed-no-env.test.d.ts.map +1 -0
- package/dist/cli/index.js +1910 -561
- package/dist/data/config-store.d.ts +62 -33
- package/dist/data/config-store.d.ts.map +1 -1
- package/dist/db/database.d.ts.map +1 -1
- package/dist/generated/storage-kit/backend.d.ts +4 -4
- package/dist/generated/storage-kit/backend.d.ts.map +1 -1
- package/dist/generated/storage-kit/index.d.ts +1 -1
- package/dist/generated/storage-kit/index.d.ts.map +1 -1
- package/dist/generated/storage-kit/migrations.d.ts +21 -0
- package/dist/generated/storage-kit/migrations.d.ts.map +1 -1
- package/dist/generated/storage-kit/pool.d.ts +2 -5
- package/dist/generated/storage-kit/pool.d.ts.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2702 -547
- package/dist/lib/app-home.d.ts +9 -0
- package/dist/lib/app-home.d.ts.map +1 -1
- package/dist/lib/client-types.d.ts +130 -0
- package/dist/lib/client-types.d.ts.map +1 -0
- package/dist/lib/client-types.test.d.ts +2 -0
- package/dist/lib/client-types.test.d.ts.map +1 -0
- package/dist/lib/local-opt-in.d.ts +82 -0
- package/dist/lib/local-opt-in.d.ts.map +1 -0
- package/dist/lib/project-context.d.ts +14 -14
- package/dist/lib/project-context.d.ts.map +1 -1
- package/dist/lib/project-dashboard-standard.d.ts +1 -1
- package/dist/lib/project-dashboard-standard.d.ts.map +1 -1
- package/dist/lib/session-apply.d.ts.map +1 -1
- package/dist/lib/session-render-state-hermeticity.test.d.ts +2 -0
- package/dist/lib/session-render-state-hermeticity.test.d.ts.map +1 -0
- package/dist/lib/session-render-state.d.ts +57 -0
- package/dist/lib/session-render-state.d.ts.map +1 -0
- package/dist/lib/session-render-state.test.d.ts +2 -0
- package/dist/lib/session-render-state.test.d.ts.map +1 -0
- package/dist/lib/transport-resolver.d.ts +80 -0
- package/dist/lib/transport-resolver.d.ts.map +1 -0
- package/dist/lib/transport-resolver.test.d.ts +2 -0
- package/dist/lib/transport-resolver.test.d.ts.map +1 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1442 -192
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/sdk/index.d.ts +22 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +1042 -0
- package/dist/sdk/resolve.d.ts +82 -0
- package/dist/sdk/resolve.d.ts.map +1 -0
- package/dist/sdk/resolve.test.d.ts +2 -0
- package/dist/sdk/resolve.test.d.ts.map +1 -0
- package/dist/sdk/sdk-bundle-self-contained.test.d.ts +2 -0
- package/dist/sdk/sdk-bundle-self-contained.test.d.ts.map +1 -0
- package/dist/sdk/v1.generated.d.ts +288 -0
- package/dist/sdk/v1.generated.d.ts.map +1 -0
- package/dist/server/cloud.d.ts.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +55 -64
- package/dist/test-support/preload-state-home.d.ts +2 -0
- package/dist/test-support/preload-state-home.d.ts.map +1 -0
- package/package.json +12 -12
- package/dashboard/README.md +0 -37
- package/dist/lib/retired-storage-mode.d.ts +0 -8
- package/dist/lib/retired-storage-mode.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -124,7 +124,8 @@ Surfaces:
|
|
|
124
124
|
- `GET /openapi.json`, `GET /v1/openapi.json` → the OpenAPI 3.1 document the SDK
|
|
125
125
|
is generated from.
|
|
126
126
|
- `/v1/*` — versioned cloud API (configs, profiles, snapshots, stats).
|
|
127
|
-
- `/api/*` — the local
|
|
127
|
+
- No `/api/*` — the former local REST surface is not mounted (the removed
|
|
128
|
+
bundled dashboard was its only consumer).
|
|
128
129
|
|
|
129
130
|
### Server data backend (postgresql)
|
|
130
131
|
|
|
@@ -144,25 +145,70 @@ contracts issue-key --app instructions --scopes 'instructions:*'
|
|
|
144
145
|
|
|
145
146
|
Env: `HASNA_INSTRUCTIONS_DATABASE_URL` (DSN) and
|
|
146
147
|
`HASNA_INSTRUCTIONS_API_SIGNING_KEY` (HMAC signing secret; `HASNA_API_SIGNING_KEY`
|
|
147
|
-
and `API_KEY_SIGNING_SECRET` are also accepted). Client apps
|
|
148
|
-
|
|
148
|
+
and `API_KEY_SIGNING_SECRET` are also accepted). Client apps never carry a DSN —
|
|
149
|
+
they resolve `HASNA_INSTRUCTIONS_API_KEY` (or the Keychain / credentials-file
|
|
150
|
+
tiers) through the one `@hasna/contracts` client resolver, and the authority
|
|
151
|
+
defaults to the fleet gateway `https://api.hasna.com/instructions`.
|
|
149
152
|
|
|
150
153
|
## SDK
|
|
151
154
|
|
|
152
|
-
`@hasna/instructions
|
|
153
|
-
|
|
154
|
-
(`
|
|
155
|
+
The importable module ships INSIDE `@hasna/instructions` at the `./sdk` export
|
|
156
|
+
(one package per app — there is no split `@hasna/instructions-sdk`). It is a
|
|
157
|
+
self-contained bundle (node builtins only; the `@hasna/contracts` resolver is
|
|
158
|
+
inlined at build time). The versioned `InstructionsV1Client` is generated from
|
|
159
|
+
the serve OpenAPI document (`bun run generate:sdk` → `src/sdk/v1.generated.ts`).
|
|
155
160
|
|
|
156
|
-
|
|
161
|
+
```typescript
|
|
162
|
+
import { createInstructionsV1ClientFromEnv } from "@hasna/instructions/sdk";
|
|
163
|
+
|
|
164
|
+
const client = createInstructionsV1ClientFromEnv(); // Keychain -> disk -> HASNA_INSTRUCTIONS_API_KEY
|
|
165
|
+
const { configs = [] } = await client.listConfigs({ category: "rules" });
|
|
166
|
+
```
|
|
157
167
|
|
|
158
|
-
|
|
159
|
-
|
|
168
|
+
`createInstructionsV1ClientFromEnv` resolves the credential through the same
|
|
169
|
+
`@hasna/contracts` chain as the CLI and the MCP server — fresh on every
|
|
170
|
+
request, so a rotated key heals a long-lived client without rebuilding it.
|
|
171
|
+
`resolveInstructionsSdkTransport(options)` reports WHICH tier supplied the
|
|
172
|
+
credential (never the value). An explicit `baseUrl` requires an explicit
|
|
173
|
+
`apiKey` (hasna/apps#1794): the SDK never attaches the machine's fleet key to
|
|
174
|
+
an authority the caller chose itself. No credential anywhere throws; there is
|
|
175
|
+
no local mode and no unauthenticated client on this surface.
|
|
176
|
+
|
|
177
|
+
## Client transports
|
|
160
178
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
179
|
+
Every CLI command, MCP tool, and SDK method resolves its credential and service
|
|
180
|
+
authority through the ONE client resolver in `@hasna/contracts`
|
|
181
|
+
(`hasna/apps#1720`) — the package owns no second chain. The tiers, fresh per
|
|
182
|
+
call:
|
|
183
|
+
|
|
184
|
+
| Tier | Credential | Authority |
|
|
185
|
+
|---|---|---|
|
|
186
|
+
| 1 — argument | `--api-key` / `--profile` | explicit `baseUrl` (SDK only) |
|
|
187
|
+
| 2 — env pointer | `HASNA_INSTRUCTIONS_API_KEY_OVERRIDE`, `HASNA_PROFILE`, `HASNA_INSTRUCTIONS_API_KEY_REF` | — |
|
|
188
|
+
| 3 — macOS Keychain | `hasna.credentials.instructions.api-key` (account `HASNA_STATION` → `hostname -s` → `$USER`) | `hasna.credentials.instructions.api-url` |
|
|
189
|
+
| 4 — disk | `~/.hasna/instructions/config/credentials` (owner-only 0400/0600; `HASNA_HOME` / `HASNA_CONFIG_HOME` move the root) | same file's `HASNA_INSTRUCTIONS_API_URL` |
|
|
190
|
+
| 5 — env | `HASNA_INSTRUCTIONS_API_KEY` | `HASNA_INSTRUCTIONS_API_URL` |
|
|
191
|
+
|
|
192
|
+
With a credential resolved and nothing configuring the authority, the default is
|
|
193
|
+
the fleet gateway `https://api.hasna.com/instructions`. The unprefixed
|
|
194
|
+
`INSTRUCTIONS_API_URL` / `INSTRUCTIONS_API_KEY` names are accepted for one
|
|
195
|
+
release as silent aliases one rung below the canonical `HASNA_INSTRUCTIONS_*`
|
|
196
|
+
names.
|
|
197
|
+
|
|
198
|
+
The two transports behind `ConfigStore`:
|
|
199
|
+
|
|
200
|
+
- **api** — HTTP `/v1` through the shared authenticated transport
|
|
201
|
+
(`CloudConfigStore`). Runs fail loud with no credential: non-zero exit naming
|
|
202
|
+
the tiers consulted, no SQLite fallback, no local-fallback event.
|
|
203
|
+
- **local** — on-box SQLite (`LocalConfigStore`), **opt-in only**:
|
|
204
|
+
`HASNA_INSTRUCTIONS_LOCAL=1`, honoured only when the environment configures
|
|
205
|
+
no authority and no credential. Every local run says `local mode` once on
|
|
206
|
+
stderr.
|
|
207
|
+
|
|
208
|
+
Retired locations (`~/.hasna/fleet-env`, `~/.hasna/cloud`, `~/.config/hasna`,
|
|
209
|
+
`$XDG_CONFIG_HOME`, a `~/.instructions/config.json` key store) are inputs
|
|
210
|
+
nowhere, and no `*_MODE` / `*_STORAGE_MODE` switch selects anything — the
|
|
211
|
+
transport is decided by what resolves, never by a mode word.
|
|
166
212
|
|
|
167
213
|
Clients never hold a database DSN. The raw Postgres connection is a server-only
|
|
168
214
|
concern (`instructions-serve`), selected by `HASNA_INSTRUCTIONS_DATABASE_URL`.
|
|
@@ -344,12 +390,9 @@ These profiles resolve machine variables like `{{WORKSPACE_ROOT}}`,
|
|
|
344
390
|
`{{BUN_BIN_DIR}}`, `{{BUN_PATH}}`, and `{{PATH_PREFIX}}`, so synced configs can be
|
|
345
391
|
portable across Linux and macOS arm64 machines.
|
|
346
392
|
|
|
347
|
-
They also include project
|
|
393
|
+
They also include the project channel variable used by agent-managed project
|
|
348
394
|
workflows:
|
|
349
395
|
|
|
350
|
-
- `{{PROJECT_DASHBOARD_DIR}}` -> `.hasna/project`
|
|
351
|
-
- `{{PROJECT_DASHBOARD_RENDER_MANIFEST}}` -> `.hasna/project/dashboard/render.json`
|
|
352
|
-
- `{{PROJECT_DASHBOARD_SNAPSHOTS_DIR}}` -> `.hasna/project/dashboard/snapshots`
|
|
353
396
|
- `{{PROJECT_CHANNEL_PREFIX}}` -> `""` (no prefix; the channel is the normalized project slug)
|
|
354
397
|
|
|
355
398
|
Existing profiles can be migrated in place without deleting or recreating them:
|
|
@@ -361,8 +404,9 @@ instructions profile update linux-arm64 \
|
|
|
361
404
|
```
|
|
362
405
|
|
|
363
406
|
`instructions init` and `bun run seed` seed the
|
|
364
|
-
`agent-managed-project-dashboard-standard` reference. It documents the
|
|
365
|
-
|
|
407
|
+
`agent-managed-project-dashboard-standard` reference. It documents the canonical
|
|
408
|
+
per-workspace store layout (`~/.hasna/projects/workspaces/<workspace_id>/` — the
|
|
409
|
+
only project-layout convention), `projects dashboard *` commands, provider panel
|
|
366
410
|
commands, normalized project-slug channel naming, durable todos/goal workflow,
|
|
367
411
|
and the rule that dashboards must show ids/statuses/evidence refs instead of raw
|
|
368
412
|
private documents or secrets.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fail-closed-no-env.test.d.ts","sourceRoot":"","sources":["../../src/cli/fail-closed-no-env.test.ts"],"names":[],"mappings":""}
|