miaoda-game-devkit 0.7.2 → 0.7.3

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.
@@ -23,13 +23,14 @@ const packageGuidance =
23
23
  'Do not reimplement equivalent physics rules, AI, pathfinding, simulation, or algorithms in application code.\n' +
24
24
  'Keep local code focused on game-specific composition, presentation, and thin integration.';
25
25
  const contextReminder =
26
- 'Read miaoda-game-context.json before implementing gameplay. Use the installed packages and respect their owns and doesNotOwn boundaries.';
26
+ 'Read miaoda-game-context.json before implementing gameplay. Use the installed packages and respect their owns and doesNotOwn boundaries.\n' +
27
+ 'Refer to installed package READMEs and public types when using their APIs.';
27
28
  const automaticContextInstructions = [
28
29
  'Read this file before implementing or changing gameplay mechanics.',
29
30
  'Prefer a directly installed Miaoda package when its owns field matches the required mechanic.',
30
31
  'Do not reimplement responsibilities listed in a package owns field.',
31
32
  'Respect doesNotOwn and keep those responsibilities outside that package.',
32
- 'Read the installed package README and public types before using its API.',
33
+ 'Refer to installed package READMEs and public types when using their APIs.',
33
34
  ];
34
35
 
35
36
  function readJson(path) {
@@ -103,7 +104,12 @@ function validateProjectConfig(capabilityDocument, projectManifest) {
103
104
  return problems;
104
105
  }
105
106
 
106
- function createGuard(capabilityDocument, projectManifest, observedPackages = new Map()) {
107
+ function createGuard(
108
+ capabilityDocument,
109
+ projectManifest,
110
+ observedPackages = new Map(),
111
+ logState = { guidanceLogged: false },
112
+ ) {
107
113
  const capabilities = capabilityDocument?.packages || {};
108
114
  const config = projectConfig(projectManifest);
109
115
  const problems = validateProjectConfig(capabilityDocument, projectManifest);
@@ -112,7 +118,6 @@ function createGuard(capabilityDocument, projectManifest, observedPackages = new
112
118
  }
113
119
 
114
120
  const blockedPackages = new Set(config?.blockedPackages || []);
115
- let guidanceLogged = false;
116
121
  const loggedPackages = new Set();
117
122
 
118
123
  return function readPackage(pkg, context) {
@@ -126,9 +131,9 @@ function createGuard(capabilityDocument, projectManifest, observedPackages = new
126
131
  throw new Error(`Restricted by package.json miaodaGame.blockedPackages: ${pkg.name}`);
127
132
  }
128
133
 
129
- if (!guidanceLogged) {
134
+ if (!logState.guidanceLogged) {
130
135
  context.log(packageGuidance);
131
- guidanceLogged = true;
136
+ logState.guidanceLogged = true;
132
137
  }
133
138
 
134
139
  const capability = capabilities[pkg.name];
@@ -389,7 +394,13 @@ if (!existsSync(packageJsonPath)) {
389
394
  const capabilityDocument = readJson(capabilityPath);
390
395
  const projectManifest = readJson(packageJsonPath);
391
396
  const observedPackages = new Map();
392
- const guardReadPackage = createGuard(capabilityDocument, projectManifest, observedPackages);
397
+ const logState = { guidanceLogged: false };
398
+ const guardReadPackage = createGuard(
399
+ capabilityDocument,
400
+ projectManifest,
401
+ observedPackages,
402
+ logState,
403
+ );
393
404
  const localPnpmfile = existsSync(localPnpmfilePath) ? require(localPnpmfilePath) : {};
394
405
  let contextReminderLogged = false;
395
406
 
@@ -397,6 +408,8 @@ if (process.env.MIAODA_GAME_CONTEXT_DISABLED !== '1') {
397
408
  refreshInstalledContext(capabilityDocument, projectManifest, contextPath);
398
409
  const installedLockfile = rootImporterLockfile(join(projectRoot, 'pnpm-lock.yaml'));
399
410
  if (existsSync(contextPath) && directDependencies(installedLockfile, projectManifest).size > 0) {
411
+ console.log(packageGuidance);
412
+ logState.guidanceLogged = true;
400
413
  console.log(contextReminder);
401
414
  contextReminderLogged = true;
402
415
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-game-devkit",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Shared React and Phaser game lint plus deterministic testing tools for Miaoda games",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",