@hasna/instructions 0.4.6 → 0.4.8

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 (42) hide show
  1. package/README.md +67 -1
  2. package/dashboard/README.md +73 -0
  3. package/dist/cli/index.js +8670 -849
  4. package/dist/cli/project-context.test.d.ts +2 -0
  5. package/dist/cli/project-context.test.d.ts.map +1 -0
  6. package/dist/data/config-store.d.ts +13 -0
  7. package/dist/data/config-store.d.ts.map +1 -1
  8. package/dist/index.d.ts +11 -8
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +8612 -865
  11. package/dist/lib/apply.d.ts +20 -0
  12. package/dist/lib/apply.d.ts.map +1 -1
  13. package/dist/lib/dangerous-operation-guard-standard.d.ts +6 -0
  14. package/dist/lib/dangerous-operation-guard-standard.d.ts.map +1 -0
  15. package/dist/lib/dangerous-operation-guard-standard.test.d.ts +2 -0
  16. package/dist/lib/dangerous-operation-guard-standard.test.d.ts.map +1 -0
  17. package/dist/lib/global-agent-rules-render-integration.test.d.ts +2 -0
  18. package/dist/lib/global-agent-rules-render-integration.test.d.ts.map +1 -0
  19. package/dist/lib/global-agent-rules-standard.d.ts +52 -1
  20. package/dist/lib/global-agent-rules-standard.d.ts.map +1 -1
  21. package/dist/lib/machine.d.ts +4 -0
  22. package/dist/lib/machine.d.ts.map +1 -1
  23. package/dist/lib/platform-profiles.d.ts.map +1 -1
  24. package/dist/lib/project-context.d.ts +440 -0
  25. package/dist/lib/project-context.d.ts.map +1 -0
  26. package/dist/lib/project-context.test.d.ts +2 -0
  27. package/dist/lib/project-context.test.d.ts.map +1 -0
  28. package/dist/lib/session-apply.d.ts +35 -0
  29. package/dist/lib/session-apply.d.ts.map +1 -1
  30. package/dist/lib/session-render-contract.d.ts +5 -0
  31. package/dist/lib/session-render-contract.d.ts.map +1 -0
  32. package/dist/lib/session-render.d.ts +52 -5
  33. package/dist/lib/session-render.d.ts.map +1 -1
  34. package/dist/lib/sync-dir.d.ts.map +1 -1
  35. package/dist/lib/sync.d.ts.map +1 -1
  36. package/dist/lib/template.d.ts +4 -0
  37. package/dist/lib/template.d.ts.map +1 -1
  38. package/dist/mcp/index.js +4751 -234
  39. package/dist/mcp/server.d.ts.map +1 -1
  40. package/dist/types/index.d.ts +2 -1
  41. package/dist/types/index.d.ts.map +1 -1
  42. package/package.json +3 -2
package/README.md CHANGED
@@ -157,13 +157,19 @@ Local data is stored in `~/.hasna/configs/` (unchanged, for fleet continuity).
157
157
 
158
158
  `instructions session plan` and `instructions session apply` render
159
159
  OpenIdentities and instruction sources into provider-native files for Claude,
160
- Codex, Cursor, OpenCode, Codewith, aicopilot, and Google Antigravity.
160
+ Codex, Cursor, OpenCode, Codewith, Qwen, aicopilot, and Google Antigravity.
161
161
  The old Google agent target is removed; Antigravity is the only Google coding
162
162
  agent render target. Antigravity workspace rules are rendered to
163
163
  `.agents/rules/*.md`; its current global rules and MCP files use Google's
164
164
  legacy-named `~/.gemini/GEMINI.md` and `~/.gemini/config/mcp_config.json`
165
165
  paths but remain owned by the `antigravity` target.
166
166
 
167
+ Qwen Code session rendering writes `QWEN.md` instructional context with
168
+ `QWEN_HOME` pointing at the rendered profile home. Known config sync also
169
+ tracks Qwen Code `QWEN.md` and `settings.json` files at `~/.qwen/...` and
170
+ project `QWEN.md` / `.qwen/settings.json`, so native hook settings can be
171
+ managed without claiming session-rendered context is hard enforcement.
172
+
167
173
  ```bash
168
174
  instructions session plan \
169
175
  --tool codewith \
@@ -186,6 +192,58 @@ manifests for drift, refuses unmanaged file conflicts unless `--force` is
186
192
  passed, removes stale managed mirrors only when safe, and writes local snapshots
187
193
  before mutating managed files.
188
194
 
195
+ ### Managed project context
196
+
197
+ `instructions project-context plan|apply` is the sole writer for the strict
198
+ `hasna.projects.project_context_bundle.v1` contract emitted by Projects. It
199
+ accepts bounded structured JSON from a regular file or stdin and never invokes
200
+ Projects, Todos, Conversations, or Mementos while rendering:
201
+
202
+ ```bash
203
+ projects context-bundle <project-id> --json > ./project-context.json
204
+ instructions project-context plan \
205
+ --runtime codewith \
206
+ --workspace-root /absolute/workspace \
207
+ --bundle ./project-context.json \
208
+ --json
209
+ instructions project-context apply \
210
+ --runtime codewith \
211
+ --workspace-root /absolute/workspace \
212
+ --bundle ./project-context.json \
213
+ --json
214
+ ```
215
+
216
+ The renderer writes one canonical `.hasna/instructions/project-context.md`
217
+ fragment, then a managed import in `CLAUDE.md`, a managed inline block in
218
+ `AGENTS.md`, and a managed inline block in `.codewith/CODEWITH.md` by default.
219
+ Codewith uses an import only when its existing
220
+ `HASNA_CONFIGS_CODEWITH_NATIVE_IMPORTS=1` capability gate is active or
221
+ `--codewith-native-imports` explicitly selects that supported runtime mode.
222
+ Bytes outside the managed marker pair are preserved. Codewith's
223
+ `.codewith/CODEWITH.override.md` takes precedence and causes the stable
224
+ `PROJECT_CONTEXT_SHADOWED` failure instead of an ignored write.
225
+ Existing Instructions session manifests are updated additively, and later
226
+ `instructions session plan|apply` runs recompose the validated durable project
227
+ context so routine Claude, Codewith, or Codex rerenders cannot discard it.
228
+
229
+ Input is limited to 8 KiB, output to 4 KiB and six allowlisted argv commands.
230
+ The writer rejects unknown fields, hash/revision inconsistencies, credentials,
231
+ URLs, symlinks, malformed or conflicting markers, and older revisions. Applies
232
+ use a per-workspace lock, compare-and-swap hashes, same-directory fsynced temp
233
+ files and renames, and a metadata-only manifest written last. Existing-file
234
+ updates require an atomic exchange primitive (Linux `renameat2` or macOS
235
+ `renameatx_np`); unsupported platforms, including Windows, fail closed before
236
+ replacement rather than approximating an exchange. A same-project,
237
+ compatible last-known-good cache can be selected explicitly with
238
+ `--allow-stale-cache --expected-project-id <id>`; its bounded age/status is
239
+ visible in the rendered context.
240
+
241
+ Compatibility remains additive: project-context manifests keep
242
+ `hasna.configs.session-render/v1`, `Managed by @hasna/configs`, and
243
+ `ownedBy: open-configs`, while recording `canonicalOwner: instructions`. The
244
+ legacy `@hasna/configs` 0.2.45 `configs` executable remains available as a bin
245
+ alias; no separate Configs repository or flag-day manifest v2 is introduced.
246
+
189
247
  `instructions init` and `bun run seed` also seed
190
248
  `global-agent-rules-standard`, the managed global/system prompt source for
191
249
  session renaming, task-scoped worktrees, PR-first landing, protected-branch
@@ -193,6 +251,14 @@ push safety, no brittle hardcoding when source-of-truth or reusable abstractions
193
251
  exist, autonomous repair, Hasna CLI source-of-truth usage, conversation surface
194
252
  routing, and unbudgeted Codewith goals unless a user asks for budgets.
195
253
 
254
+ They also seed `dangerous-operation-guard-standard`, the managed station01 guard
255
+ source for risky shell commands, edits, git operations, package installs, and
256
+ secret-adjacent access. The guard excludes Gemini CLI, requires Codewith/Codex
257
+ `PreToolUse` to hard-deny or inject context rather than ask for approval, uses
258
+ `PermissionRequest` for Codewith/Codex approvals, records that Qwen `QWEN.md`
259
+ is policy context only, and records native hook or wrapper/plugin fallback
260
+ expectations for Claude, Qwen, OpenCode, Cursor, and Antigravity.
261
+
196
262
  ## Machine-aware Profiles
197
263
 
198
264
  `instructions init` seeds two platform profiles:
@@ -0,0 +1,73 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
+
18
+ ```js
19
+ export default defineConfig([
20
+ globalIgnores(['dist']),
21
+ {
22
+ files: ['**/*.{ts,tsx}'],
23
+ extends: [
24
+ // Other configs...
25
+
26
+ // Remove tseslint.configs.recommended and replace with this
27
+ tseslint.configs.recommendedTypeChecked,
28
+ // Alternatively, use this for stricter rules
29
+ tseslint.configs.strictTypeChecked,
30
+ // Optionally, add this for stylistic rules
31
+ tseslint.configs.stylisticTypeChecked,
32
+
33
+ // Other configs...
34
+ ],
35
+ languageOptions: {
36
+ parserOptions: {
37
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
+ tsconfigRootDir: import.meta.dirname,
39
+ },
40
+ // other options...
41
+ },
42
+ },
43
+ ])
44
+ ```
45
+
46
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
+
48
+ ```js
49
+ // eslint.config.js
50
+ import reactX from 'eslint-plugin-react-x'
51
+ import reactDom from 'eslint-plugin-react-dom'
52
+
53
+ export default defineConfig([
54
+ globalIgnores(['dist']),
55
+ {
56
+ files: ['**/*.{ts,tsx}'],
57
+ extends: [
58
+ // Other configs...
59
+ // Enable lint rules for React
60
+ reactX.configs['recommended-typescript'],
61
+ // Enable lint rules for React DOM
62
+ reactDom.configs.recommended,
63
+ ],
64
+ languageOptions: {
65
+ parserOptions: {
66
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
+ tsconfigRootDir: import.meta.dirname,
68
+ },
69
+ // other options...
70
+ },
71
+ },
72
+ ])
73
+ ```