@project-ava-supernova/core 0.2.176 → 0.2.178
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/dist/agent/agent.d.ts +3 -0
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +44 -11
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/social-craft.d.ts +30 -67
- package/dist/agent/social-craft.d.ts.map +1 -1
- package/dist/agent/social-craft.js +58 -185
- package/dist/agent/social-craft.js.map +1 -1
- package/dist/agent/system-prompt.d.ts +10 -3
- package/dist/agent/system-prompt.d.ts.map +1 -1
- package/dist/agent/system-prompt.js +1184 -1321
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/auto/aurora-router.d.ts +1 -1
- package/dist/auto/aurora-router.d.ts.map +1 -1
- package/dist/auto/aurora-router.js +4 -1
- package/dist/auto/aurora-router.js.map +1 -1
- package/dist/auto/auto-coordinator.d.ts.map +1 -1
- package/dist/auto/auto-coordinator.js +2 -1
- package/dist/auto/auto-coordinator.js.map +1 -1
- package/dist/auto/longxiang-router.d.ts.map +1 -1
- package/dist/auto/longxiang-router.js +1 -0
- package/dist/auto/longxiang-router.js.map +1 -1
- package/dist/auto/model-router.d.ts.map +1 -1
- package/dist/auto/model-router.js +1 -0
- package/dist/auto/model-router.js.map +1 -1
- package/dist/auto/supernova-router.d.ts.map +1 -1
- package/dist/auto/supernova-router.js +3 -0
- package/dist/auto/supernova-router.js.map +1 -1
- package/dist/auto/task-classifier.d.ts.map +1 -1
- package/dist/auto/task-classifier.js +8 -1
- package/dist/auto/task-classifier.js.map +1 -1
- package/dist/auto/types.d.ts +1 -1
- package/dist/auto/types.d.ts.map +1 -1
- package/dist/brand/brand-kits.d.ts +217 -0
- package/dist/brand/brand-kits.d.ts.map +1 -0
- package/dist/brand/brand-kits.js +681 -0
- package/dist/brand/brand-kits.js.map +1 -0
- package/dist/brand/kit-py.d.ts +7 -0
- package/dist/brand/kit-py.d.ts.map +1 -0
- package/dist/brand/kit-py.js +49 -0
- package/dist/brand/kit-py.js.map +1 -0
- package/dist/config/schema.d.ts +5 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/creative/folder-export.d.ts +72 -0
- package/dist/creative/folder-export.d.ts.map +1 -0
- package/dist/creative/folder-export.js +463 -0
- package/dist/creative/folder-export.js.map +1 -0
- package/dist/creative/library-folders.d.ts +171 -0
- package/dist/creative/library-folders.d.ts.map +1 -0
- package/dist/creative/library-folders.js +515 -0
- package/dist/creative/library-folders.js.map +1 -0
- package/dist/creative/library-upload.d.ts +23 -0
- package/dist/creative/library-upload.d.ts.map +1 -0
- package/dist/creative/library-upload.js +152 -0
- package/dist/creative/library-upload.js.map +1 -0
- package/dist/creative/making-report.d.ts +46 -0
- package/dist/creative/making-report.d.ts.map +1 -0
- package/dist/creative/making-report.js +244 -0
- package/dist/creative/making-report.js.map +1 -0
- package/dist/creative/pack-plan-status.d.ts +18 -0
- package/dist/creative/pack-plan-status.d.ts.map +1 -0
- package/dist/creative/pack-plan-status.js +58 -0
- package/dist/creative/pack-plan-status.js.map +1 -0
- package/dist/creative/store-profiles.d.ts +46 -0
- package/dist/creative/store-profiles.d.ts.map +1 -0
- package/dist/creative/store-profiles.js +486 -0
- package/dist/creative/store-profiles.js.map +1 -0
- package/dist/docs/data/tools.d.ts.map +1 -1
- package/dist/docs/data/tools.js +17 -0
- package/dist/docs/data/tools.js.map +1 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/config.d.ts +12 -0
- package/dist/memory/config.d.ts.map +1 -1
- package/dist/memory/config.js +12 -0
- package/dist/memory/config.js.map +1 -1
- package/dist/memory/memory-manager.d.ts +11 -0
- package/dist/memory/memory-manager.d.ts.map +1 -1
- package/dist/memory/memory-manager.js +90 -2
- package/dist/memory/memory-manager.js.map +1 -1
- package/dist/memory/project-brain.d.ts.map +1 -1
- package/dist/memory/project-brain.js +2 -1
- package/dist/memory/project-brain.js.map +1 -1
- package/dist/memory/tfidf.d.ts +10 -0
- package/dist/memory/tfidf.d.ts.map +1 -1
- package/dist/memory/tfidf.js +27 -0
- package/dist/memory/tfidf.js.map +1 -1
- package/dist/portability/bundle.d.ts.map +1 -1
- package/dist/portability/bundle.js +1 -0
- package/dist/portability/bundle.js.map +1 -1
- package/dist/portability/factory-reset.js +1 -1
- package/dist/portability/factory-reset.js.map +1 -1
- package/dist/social/index.d.ts +57 -0
- package/dist/social/index.d.ts.map +1 -1
- package/dist/social/index.js +54 -5
- package/dist/social/index.js.map +1 -1
- package/dist/social/tag-volume.d.ts +7 -0
- package/dist/social/tag-volume.d.ts.map +1 -1
- package/dist/social/tag-volume.js +27 -0
- package/dist/social/tag-volume.js.map +1 -1
- package/dist/tools/blender/build-model.d.ts +62 -0
- package/dist/tools/blender/build-model.d.ts.map +1 -0
- package/dist/tools/blender/build-model.js +501 -0
- package/dist/tools/blender/build-model.js.map +1 -0
- package/dist/tools/blender/find-blender.d.ts +43 -0
- package/dist/tools/blender/find-blender.d.ts.map +1 -0
- package/dist/tools/blender/find-blender.js +154 -0
- package/dist/tools/blender/find-blender.js.map +1 -0
- package/dist/tools/blender/model-brief.d.ts +64 -0
- package/dist/tools/blender/model-brief.d.ts.map +1 -0
- package/dist/tools/blender/model-brief.js +117 -0
- package/dist/tools/blender/model-brief.js.map +1 -0
- package/dist/tools/blender/model-history.d.ts +42 -0
- package/dist/tools/blender/model-history.d.ts.map +1 -0
- package/dist/tools/blender/model-history.js +145 -0
- package/dist/tools/blender/model-history.js.map +1 -0
- package/dist/tools/blender/paths.d.ts +20 -0
- package/dist/tools/blender/paths.d.ts.map +1 -0
- package/dist/tools/blender/paths.js +37 -0
- package/dist/tools/blender/paths.js.map +1 -0
- package/dist/tools/blender/runner-py.d.ts +2 -0
- package/dist/tools/blender/runner-py.d.ts.map +1 -0
- package/dist/tools/blender/runner-py.js +455 -0
- package/dist/tools/blender/runner-py.js.map +1 -0
- package/dist/tools/brief-store.d.ts +28 -0
- package/dist/tools/brief-store.d.ts.map +1 -0
- package/dist/tools/brief-store.js +76 -0
- package/dist/tools/brief-store.js.map +1 -0
- package/dist/tools/check-posts.d.ts.map +1 -1
- package/dist/tools/check-posts.js +21 -3
- package/dist/tools/check-posts.js.map +1 -1
- package/dist/tools/design-checkin.d.ts +28 -0
- package/dist/tools/design-checkin.d.ts.map +1 -0
- package/dist/tools/design-checkin.js +74 -0
- package/dist/tools/design-checkin.js.map +1 -0
- package/dist/tools/design-docs.d.ts +37 -0
- package/dist/tools/design-docs.d.ts.map +1 -0
- package/dist/tools/design-docs.js +367 -0
- package/dist/tools/design-docs.js.map +1 -0
- package/dist/tools/design-folder.d.ts +24 -0
- package/dist/tools/design-folder.d.ts.map +1 -0
- package/dist/tools/design-folder.js +277 -0
- package/dist/tools/design-folder.js.map +1 -0
- package/dist/tools/design-fonts.d.ts +58 -0
- package/dist/tools/design-fonts.d.ts.map +1 -0
- package/dist/tools/design-fonts.js +316 -0
- package/dist/tools/design-fonts.js.map +1 -0
- package/dist/tools/design-studio-tools.d.ts +16 -0
- package/dist/tools/design-studio-tools.d.ts.map +1 -1
- package/dist/tools/design-studio-tools.js +288 -43
- package/dist/tools/design-studio-tools.js.map +1 -1
- package/dist/tools/generation-manager.d.ts +1 -1
- package/dist/tools/generation-manager.d.ts.map +1 -1
- package/dist/tools/gimp/build-image.d.ts +161 -0
- package/dist/tools/gimp/build-image.d.ts.map +1 -0
- package/dist/tools/gimp/build-image.js +900 -0
- package/dist/tools/gimp/build-image.js.map +1 -0
- package/dist/tools/gimp/find-gimp.d.ts +32 -0
- package/dist/tools/gimp/find-gimp.d.ts.map +1 -0
- package/dist/tools/gimp/find-gimp.js +149 -0
- package/dist/tools/gimp/find-gimp.js.map +1 -0
- package/dist/tools/gimp/runner-py.d.ts +2 -0
- package/dist/tools/gimp/runner-py.d.ts.map +1 -0
- package/dist/tools/gimp/runner-py.js +750 -0
- package/dist/tools/gimp/runner-py.js.map +1 -0
- package/dist/tools/making-record.d.ts +80 -0
- package/dist/tools/making-record.d.ts.map +1 -0
- package/dist/tools/making-record.js +221 -0
- package/dist/tools/making-record.js.map +1 -0
- package/dist/tools/propose-brief.d.ts.map +1 -1
- package/dist/tools/propose-brief.js +6 -1
- package/dist/tools/propose-brief.js.map +1 -1
- package/dist/tools/research-post.d.ts +1 -1
- package/dist/tools/research-post.d.ts.map +1 -1
- package/dist/tools/research-post.js +20 -9
- package/dist/tools/research-post.js.map +1 -1
- package/dist/tools/review-post.d.ts +25 -0
- package/dist/tools/review-post.d.ts.map +1 -0
- package/dist/tools/review-post.js +63 -0
- package/dist/tools/review-post.js.map +1 -0
- package/dist/tools/tool-registry.d.ts.map +1 -1
- package/dist/tools/tool-registry.js +42 -1
- package/dist/tools/tool-registry.js.map +1 -1
- package/dist/tools/tool-request-words.d.ts +7 -0
- package/dist/tools/tool-request-words.d.ts.map +1 -0
- package/dist/tools/tool-request-words.js +39 -0
- package/dist/tools/tool-request-words.js.map +1 -0
- package/dist/tools/write-post.d.ts.map +1 -1
- package/dist/tools/write-post.js +38 -2
- package/dist/tools/write-post.js.map +1 -1
- package/dist/tools/write-video-post.d.ts.map +1 -1
- package/dist/tools/write-video-post.js +10 -1
- package/dist/tools/write-video-post.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-py.d.ts","sourceRoot":"","sources":["../../../src/tools/blender/runner-py.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,iBAAiB,QAyb7B,CAAC"}
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Python that runs inside Blender for design_build_model.
|
|
3
|
+
*
|
|
4
|
+
* Kept as a file-in-a-string so core stays a single bundle (the extension and
|
|
5
|
+
* the IDE sidecar both ship core without loose resource files). Written to
|
|
6
|
+
* the OS temp folder before each run. Proven on Blender 5.2.2 LTS, 3 Nov 2026:
|
|
7
|
+
* a crate built, continued (lid added on top of the saved file), and every
|
|
8
|
+
* guard refusal confirmed — programs, network, native code, writes outside
|
|
9
|
+
* the model folder.
|
|
10
|
+
*/
|
|
11
|
+
import { KIT_PY } from '../../brand/kit-py.js';
|
|
12
|
+
// prettier-ignore
|
|
13
|
+
export const BLENDER_RUNNER_PY = String.raw `# Ava's Blender runner. Started by design_build_model as:
|
|
14
|
+
# blender -b [model.blend] --factory-startup --disable-autoexec --python runner.py -- job.json
|
|
15
|
+
# It prepares the scene, installs the guard, runs Ava's script, then saves,
|
|
16
|
+
# exports and renders a preview. The last line it prints is the result.
|
|
17
|
+
import sys, os, json, time, traceback, tempfile, shutil, math
|
|
18
|
+
|
|
19
|
+
JOB = json.load(open(sys.argv[sys.argv.index('--') + 1], encoding='utf-8'))
|
|
20
|
+
ASSET_DIR = os.path.realpath(JOB['assetDir'])
|
|
21
|
+
NAME = JOB['name']
|
|
22
|
+
BLEND = os.path.join(ASSET_DIR, NAME + '.blend')
|
|
23
|
+
STARTED = time.time()
|
|
24
|
+
result = {'ok': False, 'files': [], 'warnings': []}
|
|
25
|
+
${KIT_PY}
|
|
26
|
+
|
|
27
|
+
def emit():
|
|
28
|
+
sys.stdout.write('\n@@AVA_RESULT@@' + json.dumps(result) + '\n')
|
|
29
|
+
sys.stdout.flush()
|
|
30
|
+
|
|
31
|
+
import bpy
|
|
32
|
+
sys.dont_write_bytecode = True
|
|
33
|
+
bpy.context.preferences.filepaths.save_version = 0 # no .blend1 clutter beside the model
|
|
34
|
+
|
|
35
|
+
if not JOB['continue']:
|
|
36
|
+
bpy.ops.wm.read_factory_settings(use_empty=True) # a new canvas: nothing in it
|
|
37
|
+
for sc in bpy.data.scenes:
|
|
38
|
+
sc.render.filepath = os.path.join(ASSET_DIR, 'render_')
|
|
39
|
+
|
|
40
|
+
# ── The guard ────────────────────────────────────────────────────────────────
|
|
41
|
+
# Python audit hooks see every file write, process start and network call made
|
|
42
|
+
# from Python, and cannot be removed once installed. A guard, not a sandbox:
|
|
43
|
+
# Blender's own C code (saving a .blend, writing a render) is not seen here,
|
|
44
|
+
# which is why the tool also refuses absolute paths in the script itself.
|
|
45
|
+
# Writes are allowed in the model folder and in Blender's OWN per-run temp
|
|
46
|
+
# folder (blender_xxxx), not the whole system temp. Python's tempfile is
|
|
47
|
+
# pointed there too, so any library that needs scratch space stays inside it.
|
|
48
|
+
_BTMP = bpy.app.tempdir or os.path.join(ASSET_DIR, '.tmp')
|
|
49
|
+
os.makedirs(_BTMP, exist_ok=True)
|
|
50
|
+
tempfile.tempdir = _BTMP
|
|
51
|
+
_ALLOWED = [os.path.normcase(os.path.realpath(p)) for p in {ASSET_DIR, _BTMP}]
|
|
52
|
+
|
|
53
|
+
def _inside(p):
|
|
54
|
+
try:
|
|
55
|
+
rp = os.path.normcase(os.path.realpath(os.fsdecode(p)))
|
|
56
|
+
except Exception:
|
|
57
|
+
return False
|
|
58
|
+
return any(rp == a or rp.startswith(a.rstrip(os.sep) + os.sep) for a in _ALLOWED)
|
|
59
|
+
|
|
60
|
+
_BLOCKED = {
|
|
61
|
+
'subprocess.Popen': 'starting other programs', 'os.system': 'starting other programs',
|
|
62
|
+
'os.exec': 'starting other programs', 'os.posix_spawn': 'starting other programs',
|
|
63
|
+
'os.spawn': 'starting other programs', 'os.startfile': 'opening files in other programs',
|
|
64
|
+
'os.kill': 'stopping other programs', 'webbrowser.open': 'opening a browser',
|
|
65
|
+
'socket.connect': 'network access', 'socket.bind': 'network access',
|
|
66
|
+
'socket.getaddrinfo': 'network access', 'socket.gethostbyname': 'network access',
|
|
67
|
+
'urllib.Request': 'network access', 'ctypes.dlopen': 'loading native code',
|
|
68
|
+
'ctypes.dlsym': 'calling native code', 'ctypes.call_function': 'calling native code',
|
|
69
|
+
'winreg.CreateKey': 'changing the registry', 'winreg.SetValue': 'changing the registry',
|
|
70
|
+
'winreg.DeleteKey': 'changing the registry', 'winreg.DeleteValue': 'changing the registry',
|
|
71
|
+
}
|
|
72
|
+
_WRITE_ARGS = { # event -> indexes of the paths it writes or removes
|
|
73
|
+
'os.remove': (0,), 'os.rmdir': (0,), 'os.mkdir': (0,), 'os.chmod': (0,),
|
|
74
|
+
'os.truncate': (0,), 'os.utime': (0,), 'shutil.rmtree': (0,),
|
|
75
|
+
'os.rename': (0, 1), 'shutil.move': (0, 1), 'shutil.copyfile': (1,),
|
|
76
|
+
'shutil.copytree': (1,), 'os.symlink': (1,), 'os.link': (1,),
|
|
77
|
+
}
|
|
78
|
+
_WRITE_FLAGS = os.O_WRONLY | os.O_RDWR | os.O_CREAT | os.O_APPEND | os.O_TRUNC
|
|
79
|
+
|
|
80
|
+
def _refuse(why):
|
|
81
|
+
raise PermissionError(f'Blocked by the Design Studio guard: {why}. '
|
|
82
|
+
f'Scripts here may only build the model and write inside its own folder (ASSET_DIR).')
|
|
83
|
+
|
|
84
|
+
def _hook(event, args):
|
|
85
|
+
if event in _BLOCKED:
|
|
86
|
+
_refuse(_BLOCKED[event])
|
|
87
|
+
if event == 'open':
|
|
88
|
+
path, mode, flags = (list(args) + [None, None, 0])[:3]
|
|
89
|
+
if path is None or isinstance(path, int):
|
|
90
|
+
return
|
|
91
|
+
writing = (isinstance(mode, str) and any(c in mode for c in 'wax+')) or \
|
|
92
|
+
(mode is None and isinstance(flags, int) and flags & _WRITE_FLAGS)
|
|
93
|
+
if writing and not _inside(path):
|
|
94
|
+
_refuse(f'writing outside the model folder ({os.fsdecode(path)})')
|
|
95
|
+
elif event in _WRITE_ARGS:
|
|
96
|
+
for i in _WRITE_ARGS[event]:
|
|
97
|
+
if i < len(args) and args[i] is not None and not isinstance(args[i], int) and not _inside(args[i]):
|
|
98
|
+
_refuse(f'changing files outside the model folder ({os.fsdecode(args[i])})')
|
|
99
|
+
|
|
100
|
+
# Blender's own exporters load native code when first imported (the glTF one
|
|
101
|
+
# pulls in ctypes for Draco). Import them BEFORE the guard goes up, so the guard
|
|
102
|
+
# only ever sees what Ava's script does.
|
|
103
|
+
import ctypes # noqa: F401
|
|
104
|
+
for _mod in ('io_scene_gltf2.blender.exp.export', 'io_scene_fbx.export_fbx_bin'):
|
|
105
|
+
try:
|
|
106
|
+
__import__(_mod)
|
|
107
|
+
except Exception as e:
|
|
108
|
+
result['warnings'].append(f'Could not preload {_mod}: {e}')
|
|
109
|
+
|
|
110
|
+
sys.addaudithook(_hook)
|
|
111
|
+
|
|
112
|
+
# ── Helpers Ava calls from her script ────────────────────────────────────────
|
|
113
|
+
# Texturing is where she lost twenty minutes on the first real model (3 Nov
|
|
114
|
+
# 2026): a beautiful live shader that exports as nothing, a dozen runs on UV
|
|
115
|
+
# layout, and Blender reporting only EEVEE when asked which engines exist —
|
|
116
|
+
# so she concluded Cycles (which baking needs) was missing. It is not. These
|
|
117
|
+
# do the known-good versions of both steps in one line each.
|
|
118
|
+
|
|
119
|
+
import math as _math
|
|
120
|
+
|
|
121
|
+
def _meshes(objects):
|
|
122
|
+
if objects is None:
|
|
123
|
+
return [o for o in bpy.context.scene.objects if o.type == 'MESH' and o.visible_get()]
|
|
124
|
+
return [bpy.data.objects[o] if isinstance(o, str) else o for o in objects]
|
|
125
|
+
|
|
126
|
+
def _select_only(obs):
|
|
127
|
+
if bpy.context.object and bpy.context.object.mode != 'OBJECT':
|
|
128
|
+
bpy.ops.object.mode_set(mode='OBJECT')
|
|
129
|
+
for o in bpy.context.scene.objects:
|
|
130
|
+
o.select_set(False)
|
|
131
|
+
for o in obs:
|
|
132
|
+
o.select_set(True)
|
|
133
|
+
bpy.context.view_layer.objects.active = obs[0]
|
|
134
|
+
|
|
135
|
+
def _keep_live_uvs(obs):
|
|
136
|
+
"""Before a new layout goes in, keep the one the live shader was written
|
|
137
|
+
against. A shader can READ its UVs (her barrel told wood from iron by
|
|
138
|
+
position on the layout), so replacing them silently scrambles the look —
|
|
139
|
+
found the first time this ran on a real model, 3 Nov 2026. The old layout
|
|
140
|
+
is copied to 'LiveUV' and every material pointed at it explicitly; the new
|
|
141
|
+
packed layout then takes the FIRST slot, the one game engines read."""
|
|
142
|
+
mats = set()
|
|
143
|
+
for o in obs:
|
|
144
|
+
uvs = o.data.uv_layers
|
|
145
|
+
if not uvs:
|
|
146
|
+
uvs.new(name='UVMap')
|
|
147
|
+
continue
|
|
148
|
+
if 'LiveUV' not in uvs:
|
|
149
|
+
uvs.active = uvs[0]
|
|
150
|
+
uvs.new(name='LiveUV', do_init=True) # copies the current layout
|
|
151
|
+
uvs.active = uvs[0]
|
|
152
|
+
for sl in o.material_slots:
|
|
153
|
+
if sl.material and sl.material.use_nodes and not sl.material.get('ava_baked'):
|
|
154
|
+
mats.add(sl.material)
|
|
155
|
+
for m in mats:
|
|
156
|
+
nt = m.node_tree
|
|
157
|
+
for n in list(nt.nodes):
|
|
158
|
+
if n.bl_idname == 'ShaderNodeTexCoord' and n.outputs['UV'].links:
|
|
159
|
+
uvn = nt.nodes.new('ShaderNodeUVMap'); uvn.uv_map = 'LiveUV'
|
|
160
|
+
uvn.location = (n.location.x, n.location.y - 180)
|
|
161
|
+
for l in list(n.outputs['UV'].links):
|
|
162
|
+
nt.links.new(uvn.outputs['UV'], l.to_socket)
|
|
163
|
+
elif n.bl_idname == 'ShaderNodeUVMap' and n.uv_map in ('', 'UVMap'):
|
|
164
|
+
n.uv_map = 'LiveUV'
|
|
165
|
+
elif n.bl_idname == 'ShaderNodeTexImage' and not n.inputs['Vector'].links:
|
|
166
|
+
uvn = nt.nodes.new('ShaderNodeUVMap'); uvn.uv_map = 'LiveUV'
|
|
167
|
+
nt.links.new(uvn.outputs['UV'], n.inputs['Vector'])
|
|
168
|
+
return mats
|
|
169
|
+
|
|
170
|
+
def ava_unwrap(objects=None, margin=0.004, angle=66):
|
|
171
|
+
"""Unwrap every mesh (or the ones named) and pack ALL their UV islands into
|
|
172
|
+
one shared 0-1 square with no overlaps — what one texture set for the
|
|
173
|
+
whole asset needs. Safe for a shader that reads its UVs: the old layout is
|
|
174
|
+
kept as 'LiveUV' and the materials keep reading it, so the look does not
|
|
175
|
+
change. Returns the number of objects unwrapped."""
|
|
176
|
+
obs = _meshes(objects)
|
|
177
|
+
if not obs:
|
|
178
|
+
raise ValueError('ava_unwrap: no mesh objects to unwrap')
|
|
179
|
+
_keep_live_uvs(obs)
|
|
180
|
+
_select_only(obs)
|
|
181
|
+
bpy.ops.object.mode_set(mode='EDIT')
|
|
182
|
+
bpy.ops.mesh.select_all(action='SELECT')
|
|
183
|
+
bpy.ops.uv.smart_project(angle_limit=_math.radians(angle), island_margin=margin)
|
|
184
|
+
bpy.ops.uv.select_all(action='SELECT')
|
|
185
|
+
bpy.ops.uv.pack_islands(margin=margin, rotate=True)
|
|
186
|
+
bpy.ops.object.mode_set(mode='OBJECT')
|
|
187
|
+
print(f'AVA_UNWRAP: {len(obs)} objects packed into one UV square (old layout kept as LiveUV)')
|
|
188
|
+
return len(obs)
|
|
189
|
+
|
|
190
|
+
def _principled(mat):
|
|
191
|
+
out = next((n for n in mat.node_tree.nodes if n.type == 'OUTPUT_MATERIAL' and n.is_active_output), None) \
|
|
192
|
+
or next((n for n in mat.node_tree.nodes if n.type == 'OUTPUT_MATERIAL'), None)
|
|
193
|
+
if not out or not out.inputs['Surface'].links:
|
|
194
|
+
return None, None
|
|
195
|
+
node = out.inputs['Surface'].links[0].from_node
|
|
196
|
+
return (node if node.type == 'BSDF_PRINCIPLED' else None), out
|
|
197
|
+
|
|
198
|
+
def ava_bake(objects=None, size=2048, maps=('base_color', 'roughness', 'metallic', 'normal'), samples=16):
|
|
199
|
+
"""Bake the live materials into image textures in ASSET_DIR/textures and
|
|
200
|
+
put a clean, export-ready material on the objects — the step procedural
|
|
201
|
+
shaders need before FBX/glTF, because live nodes do not export.
|
|
202
|
+
|
|
203
|
+
Works per channel the proven way: colour, roughness and metal are baked
|
|
204
|
+
through an emission pass (a plain diffuse bake turns metal black); the
|
|
205
|
+
normal pass keeps bumps and carved detail. The live materials stay in the
|
|
206
|
+
file, so changing the look and calling ava_bake() again re-bakes from them.
|
|
207
|
+
Needs non-overlapping UVs across the objects — ava_unwrap() gives that."""
|
|
208
|
+
import os as _os
|
|
209
|
+
obs = _meshes(objects)
|
|
210
|
+
if not obs:
|
|
211
|
+
raise ValueError('ava_bake: no mesh objects to bake')
|
|
212
|
+
for o in obs:
|
|
213
|
+
if not o.data.uv_layers:
|
|
214
|
+
raise ValueError(f'ava_bake: "{o.name}" has no UVs — call ava_unwrap() first')
|
|
215
|
+
o.data.uv_layers.active = o.data.uv_layers[0] # the bake lands on the first map
|
|
216
|
+
# Re-baking: put the live materials back on first.
|
|
217
|
+
src = o.get('ava_live_materials')
|
|
218
|
+
if src:
|
|
219
|
+
for i, nm in enumerate(src):
|
|
220
|
+
if nm in bpy.data.materials and i < len(o.material_slots):
|
|
221
|
+
o.material_slots[i].material = bpy.data.materials[nm]
|
|
222
|
+
|
|
223
|
+
mats = []
|
|
224
|
+
for o in obs:
|
|
225
|
+
for slot in o.material_slots:
|
|
226
|
+
if slot.material and slot.material not in mats:
|
|
227
|
+
mats.append(slot.material)
|
|
228
|
+
if not mats:
|
|
229
|
+
raise ValueError('ava_bake: the objects have no materials to bake')
|
|
230
|
+
for m in mats:
|
|
231
|
+
m.use_nodes = True
|
|
232
|
+
if _principled(m)[0] is None:
|
|
233
|
+
raise ValueError(f'ava_bake: material "{m.name}" does not end in a Principled BSDF')
|
|
234
|
+
|
|
235
|
+
sc = bpy.context.scene
|
|
236
|
+
prev_engine = sc.render.engine
|
|
237
|
+
sc.render.engine = 'CYCLES' # baking is Cycles-only; it IS available
|
|
238
|
+
sc.cycles.device = 'CPU'
|
|
239
|
+
sc.cycles.samples = samples
|
|
240
|
+
sc.render.bake.margin = 8
|
|
241
|
+
_select_only(obs)
|
|
242
|
+
|
|
243
|
+
asset = _os.path.basename(ASSET_DIR.rstrip('\\/'))
|
|
244
|
+
tex_dir = _os.path.join(ASSET_DIR, 'textures')
|
|
245
|
+
_os.makedirs(tex_dir, exist_ok=True)
|
|
246
|
+
SPEC = {
|
|
247
|
+
'base_color': ('Base Color', 'BaseColor', False),
|
|
248
|
+
'roughness': ('Roughness', 'Roughness', True),
|
|
249
|
+
'metallic': ('Metallic', 'Metallic', True),
|
|
250
|
+
'normal': (None, 'Normal', True),
|
|
251
|
+
}
|
|
252
|
+
images = {}
|
|
253
|
+
for key in maps:
|
|
254
|
+
if key not in SPEC:
|
|
255
|
+
raise ValueError(f'ava_bake: unknown map "{key}" — use base_color, roughness, metallic, normal')
|
|
256
|
+
socket_name, label, data = SPEC[key]
|
|
257
|
+
img = bpy.data.images.new(f'{asset}_{label}', size, size, alpha=False)
|
|
258
|
+
if data:
|
|
259
|
+
img.colorspace_settings.name = 'Non-Color'
|
|
260
|
+
temp = [] # (material, nodes added, links to restore)
|
|
261
|
+
for m in mats:
|
|
262
|
+
nt = m.node_tree
|
|
263
|
+
bsdf, out = _principled(m)
|
|
264
|
+
tn = nt.nodes.new('ShaderNodeTexImage'); tn.image = img
|
|
265
|
+
nt.nodes.active = tn
|
|
266
|
+
added = [tn]; restore = None
|
|
267
|
+
if socket_name:
|
|
268
|
+
# Route this channel into an emission shader and bake EMIT:
|
|
269
|
+
# exact values, metal included.
|
|
270
|
+
sock = bsdf.inputs[socket_name]
|
|
271
|
+
em = nt.nodes.new('ShaderNodeEmission'); added.append(em)
|
|
272
|
+
if sock.links:
|
|
273
|
+
nt.links.new(sock.links[0].from_socket, em.inputs['Color'])
|
|
274
|
+
else:
|
|
275
|
+
v = sock.default_value
|
|
276
|
+
em.inputs['Color'].default_value = tuple(v) if hasattr(v, '__len__') else (v, v, v, 1.0)
|
|
277
|
+
restore = out.inputs['Surface'].links[0].from_socket
|
|
278
|
+
nt.links.new(em.outputs['Emission'], out.inputs['Surface'])
|
|
279
|
+
temp.append((m, added, restore, out))
|
|
280
|
+
if socket_name:
|
|
281
|
+
bpy.ops.object.bake(type='EMIT')
|
|
282
|
+
else:
|
|
283
|
+
bpy.ops.object.bake(type='NORMAL', normal_space='TANGENT')
|
|
284
|
+
for m, added, restore, out in temp:
|
|
285
|
+
if restore is not None:
|
|
286
|
+
m.node_tree.links.new(restore, out.inputs['Surface'])
|
|
287
|
+
for n in added:
|
|
288
|
+
m.node_tree.nodes.remove(n)
|
|
289
|
+
img.filepath_raw = _os.path.join(tex_dir, f'{asset}_{label}.png')
|
|
290
|
+
img.file_format = 'PNG'
|
|
291
|
+
img.save()
|
|
292
|
+
images[key] = img
|
|
293
|
+
|
|
294
|
+
# The export-ready material: the baked images, nothing live.
|
|
295
|
+
baked = bpy.data.materials.get(f'M_{asset}_Baked') or bpy.data.materials.new(f'M_{asset}_Baked')
|
|
296
|
+
baked.use_nodes = True
|
|
297
|
+
nt = baked.node_tree; nt.nodes.clear()
|
|
298
|
+
bsdf = nt.nodes.new('ShaderNodeBsdfPrincipled'); bsdf.location = (300, 0)
|
|
299
|
+
out = nt.nodes.new('ShaderNodeOutputMaterial'); out.location = (600, 0)
|
|
300
|
+
nt.links.new(bsdf.outputs['BSDF'], out.inputs['Surface'])
|
|
301
|
+
y = 300
|
|
302
|
+
for key, img in images.items():
|
|
303
|
+
tn = nt.nodes.new('ShaderNodeTexImage'); tn.image = img; tn.location = (-300, y); y -= 280
|
|
304
|
+
if key == 'normal':
|
|
305
|
+
nm = nt.nodes.new('ShaderNodeNormalMap'); nm.location = (0, -500)
|
|
306
|
+
nt.links.new(tn.outputs['Color'], nm.inputs['Color'])
|
|
307
|
+
nt.links.new(nm.outputs['Normal'], bsdf.inputs['Normal'])
|
|
308
|
+
else:
|
|
309
|
+
nt.links.new(tn.outputs['Color'], bsdf.inputs[SPEC[key][0]])
|
|
310
|
+
baked['ava_baked'] = True
|
|
311
|
+
|
|
312
|
+
for o in obs:
|
|
313
|
+
live = [s.material.name if s.material else '' for s in o.material_slots]
|
|
314
|
+
for nm in live:
|
|
315
|
+
if nm in bpy.data.materials:
|
|
316
|
+
bpy.data.materials[nm].use_fake_user = True # kept for re-baking
|
|
317
|
+
o['ava_live_materials'] = live
|
|
318
|
+
for slot in o.material_slots:
|
|
319
|
+
slot.material = baked
|
|
320
|
+
|
|
321
|
+
sc.render.engine = prev_engine
|
|
322
|
+
files = [f'textures/{_os.path.basename(i.filepath_raw)}' for i in images.values()]
|
|
323
|
+
print(f'AVA_BAKE: {len(obs)} objects, {len(mats)} live material(s) -> {", ".join(files)} on {baked.name}')
|
|
324
|
+
return files
|
|
325
|
+
|
|
326
|
+
# ── Ava's script ─────────────────────────────────────────────────────────────
|
|
327
|
+
script_path = os.path.join(ASSET_DIR, 'script.py')
|
|
328
|
+
ns = {'__name__': '__main__', '__file__': script_path, 'ASSET_DIR': ASSET_DIR, 'bpy': bpy, 'KIT': KIT,
|
|
329
|
+
'ava_unwrap': ava_unwrap, 'ava_bake': ava_bake}
|
|
330
|
+
try:
|
|
331
|
+
with open(script_path, encoding='utf-8') as f:
|
|
332
|
+
code = compile(f.read(), 'script.py', 'exec')
|
|
333
|
+
exec(code, ns)
|
|
334
|
+
except BaseException as e: # SystemExit included: the saved model must stay as it was
|
|
335
|
+
result['error'] = ''.join(traceback.format_exception(type(e), e, e.__traceback__)[-12:])
|
|
336
|
+
emit()
|
|
337
|
+
sys.exit(0)
|
|
338
|
+
|
|
339
|
+
# ── Save, export, measure ────────────────────────────────────────────────────
|
|
340
|
+
try:
|
|
341
|
+
if os.path.exists(BLEND): # keep the last 5 versions so a bad run can be undone
|
|
342
|
+
vdir = os.path.join(ASSET_DIR, 'versions')
|
|
343
|
+
os.makedirs(vdir, exist_ok=True)
|
|
344
|
+
shutil.copy2(BLEND, os.path.join(vdir, time.strftime('%Y%m%d-%H%M%S') + '.blend'))
|
|
345
|
+
for old in sorted(os.listdir(vdir))[:-5]:
|
|
346
|
+
os.remove(os.path.join(vdir, old))
|
|
347
|
+
bpy.ops.wm.save_as_mainfile(filepath=BLEND)
|
|
348
|
+
result['files'].append(NAME + '.blend')
|
|
349
|
+
|
|
350
|
+
meshes = [o for o in bpy.context.scene.objects if o.type == 'MESH' and o.visible_get()]
|
|
351
|
+
deps = bpy.context.evaluated_depsgraph_get()
|
|
352
|
+
tris = 0
|
|
353
|
+
lo = [math.inf] * 3; hi = [-math.inf] * 3
|
|
354
|
+
for o in meshes:
|
|
355
|
+
ev = o.evaluated_get(deps)
|
|
356
|
+
m = ev.to_mesh()
|
|
357
|
+
m.calc_loop_triangles()
|
|
358
|
+
tris += len(m.loop_triangles)
|
|
359
|
+
for v in m.vertices:
|
|
360
|
+
w = ev.matrix_world @ v.co
|
|
361
|
+
for i in range(3):
|
|
362
|
+
lo[i] = min(lo[i], w[i]); hi[i] = max(hi[i], w[i])
|
|
363
|
+
ev.to_mesh_clear()
|
|
364
|
+
result['objects'] = len(meshes)
|
|
365
|
+
result['triangles'] = tris
|
|
366
|
+
if meshes:
|
|
367
|
+
result['size_m'] = [round(hi[i] - lo[i], 3) for i in range(3)]
|
|
368
|
+
result['center'] = [(hi[i] + lo[i]) / 2 for i in range(3)]
|
|
369
|
+
|
|
370
|
+
glb = os.path.join(ASSET_DIR, NAME + '.glb')
|
|
371
|
+
bpy.ops.export_scene.gltf(filepath=glb, export_format='GLB', use_selection=False, export_apply=True)
|
|
372
|
+
result['files'].append(NAME + '.glb')
|
|
373
|
+
if JOB.get('fbx'):
|
|
374
|
+
fbx = os.path.join(ASSET_DIR, NAME + '.fbx')
|
|
375
|
+
bpy.ops.export_scene.fbx(filepath=fbx, use_selection=False, apply_scale_options='FBX_SCALE_ALL', path_mode='COPY', embed_textures=True)
|
|
376
|
+
result['files'].append(NAME + '.fbx')
|
|
377
|
+
# Live shaders do not export. Say so whenever the export will reach an
|
|
378
|
+
# engine bare — the gap she lost twenty minutes in on the first model.
|
|
379
|
+
_PROC = ('ShaderNodeTexNoise', 'ShaderNodeTexVoronoi', 'ShaderNodeTexWave', 'ShaderNodeTexMusgrave',
|
|
380
|
+
'ShaderNodeTexGradient', 'ShaderNodeTexMagic', 'ShaderNodeTexChecker', 'ShaderNodeTexBrick',
|
|
381
|
+
'ShaderNodeMath', 'ShaderNodeVectorMath', 'ShaderNodeValToRGB', 'ShaderNodeBump', 'ShaderNodeMix')
|
|
382
|
+
_live = sorted({sl.material.name for o in meshes for sl in o.material_slots
|
|
383
|
+
if sl.material and sl.material.use_nodes and not sl.material.get('ava_baked')
|
|
384
|
+
and any(n.bl_idname in _PROC for n in sl.material.node_tree.nodes)})
|
|
385
|
+
if _live:
|
|
386
|
+
result['warnings'].append(
|
|
387
|
+
'The exported model carries NONE of the live shader detail in ' + ', '.join(_live) +
|
|
388
|
+
' — game engines and the Library viewer will show it flat. Bake it: ava_unwrap() if the UVs overlap, then ava_bake().')
|
|
389
|
+
_tex = os.path.join(ASSET_DIR, 'textures')
|
|
390
|
+
if os.path.isdir(_tex):
|
|
391
|
+
result['files'] += ['textures/' + f for f in sorted(os.listdir(_tex))]
|
|
392
|
+
# For the making record: fonts and pictures in the SAVED model, whoever put
|
|
393
|
+
# them there (her script or the person by hand), and kit logos she used.
|
|
394
|
+
try:
|
|
395
|
+
result['fonts'] = sorted({(f.name if f.filepath in ('', '<builtin>') else
|
|
396
|
+
os.path.basename(bpy.path.abspath(f.filepath)))
|
|
397
|
+
+ ('|builtin' if f.filepath in ('', '<builtin>') else '')
|
|
398
|
+
for f in bpy.data.fonts if f.users})
|
|
399
|
+
result['images_used'] = sorted({os.path.basename(bpy.path.abspath(i.filepath)) for i in bpy.data.images
|
|
400
|
+
if i.users and i.filepath and i.source == 'FILE'
|
|
401
|
+
and os.path.dirname(os.path.normcase(os.path.abspath(bpy.path.abspath(i.filepath)))) != os.path.normcase(os.path.abspath(_tex))})
|
|
402
|
+
except Exception as e:
|
|
403
|
+
result['warnings'].append(f'Could not list fonts and pictures for the making record: {e}')
|
|
404
|
+
result['kit_logos'] = list(KIT_LOGOS_USED)
|
|
405
|
+
except BaseException as e:
|
|
406
|
+
result['error'] = 'The script ran, but saving or exporting failed:\n' + \
|
|
407
|
+
''.join(traceback.format_exception(type(e), e, e.__traceback__)[-8:])
|
|
408
|
+
emit()
|
|
409
|
+
sys.exit(0)
|
|
410
|
+
|
|
411
|
+
# ── Preview ──────────────────────────────────────────────────────────────────
|
|
412
|
+
# Her own render wins. Otherwise use her camera, or frame the model from a
|
|
413
|
+
# three-quarter view. Temporary camera/lights are added AFTER saving, so they
|
|
414
|
+
# never end up in the model.
|
|
415
|
+
preview = os.path.join(ASSET_DIR, 'preview.png')
|
|
416
|
+
try:
|
|
417
|
+
if os.path.exists(preview) and os.path.getmtime(preview) >= STARTED:
|
|
418
|
+
result['preview'] = 'hers'
|
|
419
|
+
elif meshes:
|
|
420
|
+
scene = bpy.context.scene
|
|
421
|
+
if scene.camera is None:
|
|
422
|
+
from mathutils import Vector
|
|
423
|
+
c = Vector(result['center']); size = max(result['size_m']) or 1.0
|
|
424
|
+
cam_data = bpy.data.cameras.new('AvaPreviewCam'); cam_data.lens = 50
|
|
425
|
+
cam = bpy.data.objects.new('AvaPreviewCam', cam_data)
|
|
426
|
+
scene.collection.objects.link(cam)
|
|
427
|
+
cam.location = c + Vector((1.0, -1.25, 0.8)).normalized() * size * 2.6
|
|
428
|
+
cam.rotation_euler = (c - cam.location).to_track_quat('-Z', 'Y').to_euler()
|
|
429
|
+
cam_data.clip_end = size * 100
|
|
430
|
+
scene.camera = cam
|
|
431
|
+
result['preview_camera'] = 'auto'
|
|
432
|
+
if not any(o.type == 'LIGHT' for o in scene.objects):
|
|
433
|
+
for nm, rot, energy in (('AvaKey', (0.9, 0.2, 0.8), 4.0), ('AvaFill', (1.1, -0.3, -2.4), 1.5)):
|
|
434
|
+
ld = bpy.data.lights.new(nm, 'SUN'); ld.energy = energy
|
|
435
|
+
lo_ = bpy.data.objects.new(nm, ld); lo_.rotation_euler = rot
|
|
436
|
+
scene.collection.objects.link(lo_)
|
|
437
|
+
if scene.world is None:
|
|
438
|
+
scene.world = bpy.data.worlds.new('AvaPreviewWorld')
|
|
439
|
+
r = scene.render
|
|
440
|
+
r.resolution_x = r.resolution_y = 1024; r.resolution_percentage = 100
|
|
441
|
+
r.film_transparent = True
|
|
442
|
+
r.image_settings.file_format = 'PNG'; r.image_settings.color_mode = 'RGBA'
|
|
443
|
+
r.filepath = preview
|
|
444
|
+
bpy.ops.render.render(write_still=True)
|
|
445
|
+
result['preview'] = 'auto'
|
|
446
|
+
if os.path.exists(preview):
|
|
447
|
+
result['files'].append('preview.png')
|
|
448
|
+
except BaseException as e:
|
|
449
|
+
result['warnings'].append('Preview render failed: ' + str(e))
|
|
450
|
+
|
|
451
|
+
result['ok'] = True
|
|
452
|
+
result['seconds'] = round(time.time() - STARTED, 1)
|
|
453
|
+
emit()
|
|
454
|
+
`;
|
|
455
|
+
//# sourceMappingURL=runner-py.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-py.js","sourceRoot":"","sources":["../../../src/tools/blender/runner-py.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,kBAAkB;AAClB,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;EAYzC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6aP,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The brief file both making rooms share: brief.json in the work's own folder.
|
|
3
|
+
*
|
|
4
|
+
* Blender and GIMP ask different questions, but the rules are one rule: Ava
|
|
5
|
+
* proposes, the person edits and agrees, and nothing is built before that.
|
|
6
|
+
* Only `agree` makes a brief agreed, and the surfaces call it from his button.
|
|
7
|
+
* A change by him puts it back to proposed: a changed brief is a new agreement.
|
|
8
|
+
*/
|
|
9
|
+
import type { ToolExecutionContext } from './types.js';
|
|
10
|
+
import { type MakingTool } from './making-record.js';
|
|
11
|
+
export interface BriefRecord {
|
|
12
|
+
name: string;
|
|
13
|
+
reasoning: string;
|
|
14
|
+
status: 'proposed' | 'agreed';
|
|
15
|
+
proposedAt: string;
|
|
16
|
+
agreedAt?: string;
|
|
17
|
+
/** Set when the person edited it on the card — Ava sees what he changed. */
|
|
18
|
+
editedByPerson?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function briefStore<B extends BriefRecord>(root: () => string, fieldKeys: () => string[], tool: MakingTool): {
|
|
21
|
+
path: (slug: string) => string;
|
|
22
|
+
read: (slug: string) => Promise<B | null>;
|
|
23
|
+
write: (slug: string, brief: B) => Promise<void>;
|
|
24
|
+
propose: (slug: string, brief: B, context?: ToolExecutionContext) => Promise<void>;
|
|
25
|
+
agree: (slug: string) => Promise<B | null>;
|
|
26
|
+
saveEdits: (slug: string, fields: Record<string, string | undefined>) => Promise<B | null>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=brief-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brief-store.d.ts","sourceRoot":"","sources":["../../src/tools/brief-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAA0C,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE7F,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,MAAM,MAAM,EAAE,SAAS,EAAE,MAAM,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU;iBAC3F,MAAM;iBAeA,MAAM,KAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;kBAIzB,MAAM,SAAS,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC;oBAZ9B,MAAM,SAAS,CAAC,YAAY,oBAAoB,KAAG,OAAO,CAAC,IAAI,CAAC;kBAkBlE,MAAM,KAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;sBAYtB,MAAM,UAAU,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;EAqBtG"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The brief file both making rooms share: brief.json in the work's own folder.
|
|
3
|
+
*
|
|
4
|
+
* Blender and GIMP ask different questions, but the rules are one rule: Ava
|
|
5
|
+
* proposes, the person edits and agrees, and nothing is built before that.
|
|
6
|
+
* Only `agree` makes a brief agreed, and the surfaces call it from his button.
|
|
7
|
+
* A change by him puts it back to proposed: a changed brief is a new agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
10
|
+
import { join } from 'node:path';
|
|
11
|
+
import { appendMaking, avaContext, beforeChange } from './making-record.js';
|
|
12
|
+
export function briefStore(root, fieldKeys, tool) {
|
|
13
|
+
const path = (slug) => join(root(), slug, 'brief.json');
|
|
14
|
+
const fieldsOf = (brief) => {
|
|
15
|
+
const record = brief;
|
|
16
|
+
return Object.fromEntries(['name', ...fieldKeys(), 'reasoning'].map((k) => [k, record[k]]));
|
|
17
|
+
};
|
|
18
|
+
/** Her proposal, for the making record: the whole brief as she put it. */
|
|
19
|
+
async function propose(slug, brief, context) {
|
|
20
|
+
const dir = join(root(), slug);
|
|
21
|
+
await beforeChange(dir, tool);
|
|
22
|
+
await write(slug, brief);
|
|
23
|
+
const who = avaContext(context);
|
|
24
|
+
await appendMaking(dir, { event: 'brief_proposed', by: 'ava', ai: who.ai, ask: who.ask, tool, brief: fieldsOf(brief) });
|
|
25
|
+
}
|
|
26
|
+
async function read(slug) {
|
|
27
|
+
try {
|
|
28
|
+
return JSON.parse(await readFile(path(slug), 'utf-8'));
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function write(slug, brief) {
|
|
35
|
+
await mkdir(join(root(), slug), { recursive: true });
|
|
36
|
+
await writeFile(path(slug), JSON.stringify(brief, null, 2), 'utf-8');
|
|
37
|
+
}
|
|
38
|
+
/** His button on the card. The ONLY way a brief becomes agreed. */
|
|
39
|
+
async function agree(slug) {
|
|
40
|
+
const brief = await read(slug);
|
|
41
|
+
if (!brief)
|
|
42
|
+
return null;
|
|
43
|
+
brief.status = 'agreed';
|
|
44
|
+
brief.agreedAt = new Date().toISOString();
|
|
45
|
+
await write(slug, brief);
|
|
46
|
+
await beforeChange(join(root(), slug), tool);
|
|
47
|
+
await appendMaking(join(root(), slug), { event: 'brief_agreed', by: 'person', tool });
|
|
48
|
+
return brief;
|
|
49
|
+
}
|
|
50
|
+
/** His edits on the card. Saving keeps it agreed only if nothing moved. */
|
|
51
|
+
async function saveEdits(slug, fields) {
|
|
52
|
+
const brief = await read(slug);
|
|
53
|
+
if (!brief)
|
|
54
|
+
return null;
|
|
55
|
+
const record = brief;
|
|
56
|
+
const changed = {};
|
|
57
|
+
for (const k of fieldKeys()) {
|
|
58
|
+
const v = typeof fields[k] === 'string' ? fields[k].trim() : undefined;
|
|
59
|
+
if (v !== undefined && v !== record[k]) {
|
|
60
|
+
changed[k] = { from: record[k], to: v };
|
|
61
|
+
record[k] = v;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (Object.keys(changed).length) {
|
|
65
|
+
brief.editedByPerson = true;
|
|
66
|
+
brief.status = 'proposed';
|
|
67
|
+
delete brief.agreedAt;
|
|
68
|
+
await write(slug, brief);
|
|
69
|
+
await beforeChange(join(root(), slug), tool);
|
|
70
|
+
await appendMaking(join(root(), slug), { event: 'brief_edited', by: 'person', tool, changed });
|
|
71
|
+
}
|
|
72
|
+
return brief;
|
|
73
|
+
}
|
|
74
|
+
return { path, read, write, propose, agree, saveEdits };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=brief-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brief-store.js","sourceRoot":"","sources":["../../src/tools/brief-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAmB,MAAM,oBAAoB,CAAC;AAY7F,MAAM,UAAU,UAAU,CAAwB,IAAkB,EAAE,SAAyB,EAAE,IAAgB;IAC/G,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,CAAC,KAAQ,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,KAA2C,CAAC;QAC3D,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,GAAG,SAAS,EAAE,EAAE,WAAW,CAAC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I,cAAc,
|
|
1
|
+
{"version":3,"file":"check-posts.d.ts","sourceRoot":"","sources":["../../src/tools/check-posts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,qBAAa,cAAe,YAAW,IAAI;IACzC,IAAI,SAAiB;IACrB,WAAW,SAAqF;IAChG,SAAS,EAAE,aAAa,CAAU;IAClC,oBAAoB,UAAS;IAE7B,IAAI,MAAM,IAAI,cAAc,CAwB3B;IAEK,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC;CAoFjG"}
|
|
@@ -31,7 +31,8 @@ export class CheckPostsTool {
|
|
|
31
31
|
description: 'Look at the posts that ACTUALLY EXIST, rather than the ones you meant to write. '
|
|
32
32
|
+ 'Call it whenever the answer depends on what was really created: when the operator asks '
|
|
33
33
|
+ 'whether something went out, when he says a post is missing, before telling him a piece '
|
|
34
|
-
+ 'of work is done, and before
|
|
34
|
+
+ 'of work is done, and before suggesting anything so you know what has already been said today. '
|
|
35
|
+
+ 'Each post shows its every-day marker and the feature it promoted, his Landed mark and your verdict. '
|
|
35
36
|
+ 'If a post you tried to write is not in the list, it was NOT written — say so plainly and '
|
|
36
37
|
+ 'do not explain it away. Being wrong about this is worse than being slow: he is learning '
|
|
37
38
|
+ 'marketing from you, so a confident wrong answer becomes something he believes for months.',
|
|
@@ -88,13 +89,30 @@ export class CheckPostsTool {
|
|
|
88
89
|
}
|
|
89
90
|
const text = posts.filter(p => p.kind === 'text');
|
|
90
91
|
const video = posts.filter(p => p.kind === 'video');
|
|
91
|
-
const line = (p) =>
|
|
92
|
-
|
|
92
|
+
const line = (p) => {
|
|
93
|
+
const marks = [
|
|
94
|
+
sinceDays > 1 ? (p.localDay || p.createdAt.slice(0, 10)) : null,
|
|
95
|
+
p.daily ? `every day: ${p.daily}` : null,
|
|
96
|
+
p.feature ? `feature: ${p.feature}` : null,
|
|
97
|
+
p.status && p.status !== 'draft' ? p.status : null,
|
|
98
|
+
p.landed === true ? 'he marked it LANDED' : p.landed === false ? 'he marked it DID NOT LAND' : null,
|
|
99
|
+
].filter(Boolean);
|
|
100
|
+
return ` • ${p.platform}${p.title ? ` — ${p.title}` : ''}${p.subject ? ` (about: ${p.subject})` : ''}`
|
|
101
|
+
+ `${marks.length ? ` [${marks.join(' · ')}]` : ''}`
|
|
102
|
+
+ `${p.verdict ? `\n your verdict: ${p.verdict}` : ''}`
|
|
103
|
+
+ `\n id: ${p.id}`;
|
|
104
|
+
};
|
|
93
105
|
const parts = [`${posts.length} post${posts.length === 1 ? '' : 's'} exist ${window}:`];
|
|
94
106
|
if (text.length)
|
|
95
107
|
parts.push(`\nText (${text.length}):\n${text.map(line).join('\n')}`);
|
|
96
108
|
if (video.length)
|
|
97
109
|
parts.push(`\nVideo (${video.length}):\n${video.map(line).join('\n')}`);
|
|
110
|
+
// The two counts the room runs on (8 Nov 2026) — read off the markers the
|
|
111
|
+
// posts carry, never estimated from their titles.
|
|
112
|
+
const dailies = [...new Set(posts.map(p => p.daily).filter((d) => !!d))];
|
|
113
|
+
const features = [...new Set(posts.map(p => p.feature).filter((f) => !!f))];
|
|
114
|
+
parts.push(`\nEvery-day posts in this window: ${dailies.length ? dailies.join(', ') : 'none'}.`
|
|
115
|
+
+ ` Features promoted in this window: ${features.length ? features.join(', ') : 'none'}.`);
|
|
98
116
|
parts.push('\nThis is the whole list. Anything you expected that is not here was not written — '
|
|
99
117
|
+ 'say that plainly rather than accounting for it.');
|
|
100
118
|
return {
|