@jini-ai/vibecoding 0.4.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 (37) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +154 -0
  3. package/dist/core/apply.d.ts +69 -0
  4. package/dist/core/apply.js +69 -0
  5. package/dist/core/history.d.ts +144 -0
  6. package/dist/core/history.js +132 -0
  7. package/dist/core/index.d.ts +19 -0
  8. package/dist/core/index.js +3 -0
  9. package/dist/core/target.d.ts +92 -0
  10. package/dist/core/target.js +2 -0
  11. package/dist/core/types.d.ts +86 -0
  12. package/dist/core/types.js +19 -0
  13. package/dist/html/index.d.ts +12 -0
  14. package/dist/html/index.js +2 -0
  15. package/dist/html/node/index.d.ts +10 -0
  16. package/dist/html/node/index.js +10 -0
  17. package/dist/html/node/parse5-region-parser.d.ts +12 -0
  18. package/dist/html/node/parse5-region-parser.js +213 -0
  19. package/dist/html/regions.d.ts +137 -0
  20. package/dist/html/regions.js +165 -0
  21. package/dist/index.d.ts +10 -0
  22. package/dist/index.js +10 -0
  23. package/dist/react/components/DocumentPreview.d.ts +59 -0
  24. package/dist/react/components/DocumentPreview.js +44 -0
  25. package/dist/react/components/PartsViewer.d.ts +49 -0
  26. package/dist/react/components/PartsViewer.js +61 -0
  27. package/dist/react/components/VibecodingWorkbench.d.ts +38 -0
  28. package/dist/react/components/VibecodingWorkbench.js +96 -0
  29. package/dist/react/index.d.ts +29 -0
  30. package/dist/react/index.js +7 -0
  31. package/dist/react/session.d.ts +108 -0
  32. package/dist/react/session.js +160 -0
  33. package/dist/react/tools.d.ts +91 -0
  34. package/dist/react/tools.js +246 -0
  35. package/dist/react/use-vibecoding-session.d.ts +30 -0
  36. package/dist/react/use-vibecoding-session.js +44 -0
  37. package/package.json +99 -0
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @module react/use-vibecoding-session
3
+ *
4
+ * The one hook every component in `./react` is built on: subscribes a component to a
5
+ * `VibecodingSession` (`./session.js`) via `useSyncExternalStore` — React's own sanctioned way to
6
+ * read a store that lives outside React, which `VibecodingSession` deliberately is (see that
7
+ * module's doc for why: a tool handler invoked from the chat's execution path needs to reach the
8
+ * same object a mounted component reads, and that object cannot be React state).
9
+ */
10
+ import { useCallback, useEffect, useSyncExternalStore } from 'react';
11
+ /**
12
+ * Subscribes to `session` and triggers its first `refresh()` on mount (and again if `session`
13
+ * itself changes identity — a host swapping in a different artifact mid-session gets a fresh list
14
+ * rather than a stale one left over from the previous session). Re-running `refresh()` a second
15
+ * time for the same session instance is the caller's own choice via the returned `refresh`.
16
+ *
17
+ * A `refresh()` rejection is intentionally swallowed here rather than thrown from the effect —
18
+ * `session.getSnapshot().lastError` already carries it (see `./session.js`), and an effect that
19
+ * threw would only produce an uncatchable render-cycle error for a failure the snapshot already
20
+ * reports. A caller that wants to react to it reads `lastError` or calls `refresh()` itself and
21
+ * awaits/catches that promise directly.
22
+ *
23
+ * @param requiredArgs - the session port created by `createVibecodingSession`.
24
+ * @returns the current snapshot plus the session's actions, bound to `session`.
25
+ * @complexity O(1) beyond whatever `session`'s own methods cost — see `./session.js`.
26
+ */
27
+ export function useVibecodingSession({ session }) {
28
+ // React supplies a positional listener; keep its adapter stable across renders so reading
29
+ // the session does not unsubscribe and resubscribe after each snapshot change.
30
+ const subscribe = useCallback((listener) => session.subscribe({ listener }), [session]);
31
+ const snapshot = useSyncExternalStore(subscribe, session.getSnapshot, session.getSnapshot);
32
+ useEffect(() => {
33
+ session.refresh().catch(() => {
34
+ // Already recorded on the snapshot as `lastError` — see this function's doc.
35
+ });
36
+ }, [session]);
37
+ const refresh = useCallback(() => session.refresh(), [session]);
38
+ const readPart = useCallback((args) => session.readPart(args), [session]);
39
+ const applyEdits = useCallback((args, options) => session.applyEdits(args, options), [session]);
40
+ const undo = useCallback(() => session.undo(), [session]);
41
+ const redo = useCallback(() => session.redo(), [session]);
42
+ return { ...snapshot, session, refresh, readPart, applyEdits, undo, redo };
43
+ }
44
+ //# sourceMappingURL=use-vibecoding-session.js.map
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@jini-ai/vibecoding",
3
+ "version": "0.4.0",
4
+ "description": "Conversational artifact authoring: a target-agnostic edit loop \u2014 addressable parts, validated replace, operation-level undo/redo, and per-turn snapshot/rewind. Framework-free in `/core`; tagged-region HTML documents behind ./html; filesystem targets behind ./node and the chat/preview surface behind ./react.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/AINSEP/Jini.git",
9
+ "directory": "packages/vibecoding"
10
+ },
11
+ "jini": {
12
+ "domain": "capability",
13
+ "kind": "authoring",
14
+ "runtime": "universal",
15
+ "entries": {
16
+ ".": "universal",
17
+ "./core": "universal",
18
+ "./html": "universal",
19
+ "./html/node": "node",
20
+ "./react": "browser"
21
+ }
22
+ },
23
+ "type": "module",
24
+ "sideEffects": false,
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js",
31
+ "default": "./dist/index.js"
32
+ },
33
+ "./core": {
34
+ "types": "./dist/core/index.d.ts",
35
+ "import": "./dist/core/index.js",
36
+ "default": "./dist/core/index.js"
37
+ },
38
+ "./html": {
39
+ "types": "./dist/html/index.d.ts",
40
+ "import": "./dist/html/index.js",
41
+ "default": "./dist/html/index.js"
42
+ },
43
+ "./html/node": {
44
+ "types": "./dist/html/node/index.d.ts",
45
+ "import": "./dist/html/node/index.js",
46
+ "default": "./dist/html/node/index.js"
47
+ },
48
+ "./react": {
49
+ "types": "./dist/react/index.d.ts",
50
+ "import": "./dist/react/index.js",
51
+ "default": "./dist/react/index.js"
52
+ }
53
+ },
54
+ "files": [
55
+ "dist",
56
+ "README.md",
57
+ "CHANGELOG.md",
58
+ "LICENSE",
59
+ "!dist/**/*.test.js",
60
+ "!dist/**/*.test.d.ts",
61
+ "!dist/**/*.test.js.map",
62
+ "!dist/**/*.test.d.ts.map",
63
+ "!dist/**/__tests__/**",
64
+ "!dist/**/*.map"
65
+ ],
66
+ "scripts": {
67
+ "build": "tsc -p tsconfig.json",
68
+ "typecheck": "tsc -p tsconfig.json --noEmit",
69
+ "test": "vitest run"
70
+ },
71
+ "devDependencies": {
72
+ "@testing-library/jest-dom": "^6.9.1",
73
+ "@testing-library/react": "^16.3.2",
74
+ "@testing-library/user-event": "^14.6.1",
75
+ "@types/react": "^19.2.17",
76
+ "@types/react-dom": "^19.2.3",
77
+ "jsdom": "^25.0.1",
78
+ "react": "^19.2.7",
79
+ "react-dom": "^19.2.7",
80
+ "typescript": "^5.9.2",
81
+ "vitest": "^3.2.4"
82
+ },
83
+ "dependencies": {
84
+ "@jini-ai/core": "workspace:*",
85
+ "parse5": "^8.0.1"
86
+ },
87
+ "peerDependencies": {
88
+ "react": "^18.3.0 || ^19.0.0",
89
+ "react-dom": "^18.3.0 || ^19.0.0"
90
+ },
91
+ "peerDependenciesMeta": {
92
+ "react": {
93
+ "optional": true
94
+ },
95
+ "react-dom": {
96
+ "optional": true
97
+ }
98
+ }
99
+ }