@hasna/instructions 0.4.7 → 0.4.9

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 (44) hide show
  1. package/README.md +87 -0
  2. package/dashboard/README.md +73 -0
  3. package/dist/cli/index.js +8772 -860
  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 -9
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +8705 -867
  11. package/dist/lib/apply.d.ts +27 -0
  12. package/dist/lib/apply.d.ts.map +1 -1
  13. package/dist/lib/global-agent-rules-render-integration.test.d.ts +2 -0
  14. package/dist/lib/global-agent-rules-render-integration.test.d.ts.map +1 -0
  15. package/dist/lib/global-agent-rules-standard.d.ts +158 -1
  16. package/dist/lib/global-agent-rules-standard.d.ts.map +1 -1
  17. package/dist/lib/global-agent-rules-stored-content.test.d.ts +2 -0
  18. package/dist/lib/global-agent-rules-stored-content.test.d.ts.map +1 -0
  19. package/dist/lib/machine.d.ts +4 -0
  20. package/dist/lib/machine.d.ts.map +1 -1
  21. package/dist/lib/platform-profiles.d.ts.map +1 -1
  22. package/dist/lib/project-context.d.ts +440 -0
  23. package/dist/lib/project-context.d.ts.map +1 -0
  24. package/dist/lib/project-context.test.d.ts +2 -0
  25. package/dist/lib/project-context.test.d.ts.map +1 -0
  26. package/dist/lib/session-apply.d.ts +35 -0
  27. package/dist/lib/session-apply.d.ts.map +1 -1
  28. package/dist/lib/session-render-contract.d.ts +15 -0
  29. package/dist/lib/session-render-contract.d.ts.map +1 -0
  30. package/dist/lib/session-render-ownership.d.ts +23 -0
  31. package/dist/lib/session-render-ownership.d.ts.map +1 -0
  32. package/dist/lib/session-render-ownership.test.d.ts +2 -0
  33. package/dist/lib/session-render-ownership.test.d.ts.map +1 -0
  34. package/dist/lib/session-render.d.ts +74 -4
  35. package/dist/lib/session-render.d.ts.map +1 -1
  36. package/dist/lib/sync-dir.d.ts.map +1 -1
  37. package/dist/lib/sync.d.ts.map +1 -1
  38. package/dist/lib/template.d.ts +4 -0
  39. package/dist/lib/template.d.ts.map +1 -1
  40. package/dist/mcp/index.js +5014 -330
  41. package/dist/mcp/server.d.ts.map +1 -1
  42. package/dist/types/index.d.ts +1 -0
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/package.json +3 -2
package/README.md CHANGED
@@ -192,6 +192,93 @@ manifests for drift, refuses unmanaged file conflicts unless `--force` is
192
192
  passed, removes stale managed mirrors only when safe, and writes local snapshots
193
193
  before mutating managed files.
194
194
 
195
+ ### Session renderer ownership
196
+
197
+ Anything the session renderer writes is off limits to `instructions apply` and
198
+ `instructions sync --to-disk`; those rows are reported as `[owned]` and skipped
199
+ instead of overwriting rendered output. Ownership is decided from the renderer's
200
+ own definitions rather than a hand-maintained path list:
201
+
202
+ - **Managed directories** — every `managedDir` in `SESSION_TOOL_ADAPTERS`, matched
203
+ on whole path segments under any target home (`~/.claude/.hasna/instructions/…`,
204
+ `~/.hasna/accounts/profiles/claude/account003/.hasna/instructions/…`, …), plus
205
+ the renderer's `.hasna/session-render-manifest.json` and
206
+ `.hasna/session-render-snapshots/`.
207
+ - **Manifest claims** — any file listed in an ancestor target home's
208
+ `.hasna/session-render-manifest.json`. This covers provider-native output such
209
+ as `CLAUDE.md`, `AGENTS.md`, and `opencode.json` exactly where the renderer
210
+ actually rendered.
211
+
212
+ `~/.cursor/rules` is deliberately *not* statically reserved: the config fan-out
213
+ writes `cursor-mdc` transform outputs there too, so files in that directory are
214
+ owned only when a manifest claims them.
215
+
216
+ Renumbering a source (inserting a new lower-order source shifts `01-` → `02-`
217
+ and so on) orphans older `target_path` values that still point inside a managed
218
+ directory. The guard is what neutralises those orphans, so stale rows are inert
219
+ rather than destructive.
220
+
221
+ Applying a config into renderer-owned space requires the explicit opt-in flag:
222
+
223
+ ```bash
224
+ instructions apply <id> --allow-renderer-owned
225
+ ```
226
+
227
+ It is separate from `--force` on purpose — "overwrite even if unchanged" must
228
+ never silently become "overwrite renderer-owned instruction files".
229
+
230
+ ### Managed project context
231
+
232
+ `instructions project-context plan|apply` is the sole writer for the strict
233
+ `hasna.projects.project_context_bundle.v1` contract emitted by Projects. It
234
+ accepts bounded structured JSON from a regular file or stdin and never invokes
235
+ Projects, Todos, Conversations, or Mementos while rendering:
236
+
237
+ ```bash
238
+ projects context-bundle <project-id> --json > ./project-context.json
239
+ instructions project-context plan \
240
+ --runtime codewith \
241
+ --workspace-root /absolute/workspace \
242
+ --bundle ./project-context.json \
243
+ --json
244
+ instructions project-context apply \
245
+ --runtime codewith \
246
+ --workspace-root /absolute/workspace \
247
+ --bundle ./project-context.json \
248
+ --json
249
+ ```
250
+
251
+ The renderer writes one canonical `.hasna/instructions/project-context.md`
252
+ fragment, then a managed import in `CLAUDE.md`, a managed inline block in
253
+ `AGENTS.md`, and a managed inline block in `.codewith/CODEWITH.md` by default.
254
+ Codewith uses an import only when its existing
255
+ `HASNA_CONFIGS_CODEWITH_NATIVE_IMPORTS=1` capability gate is active or
256
+ `--codewith-native-imports` explicitly selects that supported runtime mode.
257
+ Bytes outside the managed marker pair are preserved. Codewith's
258
+ `.codewith/CODEWITH.override.md` takes precedence and causes the stable
259
+ `PROJECT_CONTEXT_SHADOWED` failure instead of an ignored write.
260
+ Existing Instructions session manifests are updated additively, and later
261
+ `instructions session plan|apply` runs recompose the validated durable project
262
+ context so routine Claude, Codewith, or Codex rerenders cannot discard it.
263
+
264
+ Input is limited to 8 KiB, output to 4 KiB and six allowlisted argv commands.
265
+ The writer rejects unknown fields, hash/revision inconsistencies, credentials,
266
+ URLs, symlinks, malformed or conflicting markers, and older revisions. Applies
267
+ use a per-workspace lock, compare-and-swap hashes, same-directory fsynced temp
268
+ files and renames, and a metadata-only manifest written last. Existing-file
269
+ updates require an atomic exchange primitive (Linux `renameat2` or macOS
270
+ `renameatx_np`); unsupported platforms, including Windows, fail closed before
271
+ replacement rather than approximating an exchange. A same-project,
272
+ compatible last-known-good cache can be selected explicitly with
273
+ `--allow-stale-cache --expected-project-id <id>`; its bounded age/status is
274
+ visible in the rendered context.
275
+
276
+ Compatibility remains additive: project-context manifests keep
277
+ `hasna.configs.session-render/v1`, `Managed by @hasna/configs`, and
278
+ `ownedBy: open-configs`, while recording `canonicalOwner: instructions`. The
279
+ legacy `@hasna/configs` 0.2.45 `configs` executable remains available as a bin
280
+ alias; no separate Configs repository or flag-day manifest v2 is introduced.
281
+
195
282
  `instructions init` and `bun run seed` also seed
196
283
  `global-agent-rules-standard`, the managed global/system prompt source for
197
284
  session renaming, task-scoped worktrees, PR-first landing, protected-branch
@@ -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
+ ```