gatelight 0.19.3 → 0.39.1

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 (61) hide show
  1. package/.antigravity-plugin/plugin.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/README.md +2 -2
  5. package/package.json +1 -1
  6. package/skills/merge/SKILL.md +1 -1
  7. package/skills/modular/SKILL.md +6 -6
  8. package/skills/setup/SKILL.md +2 -2
  9. package/skills/setup-codekeep/SKILL.md +61 -17
  10. package/skills/setup-codekeep/frontend.eslint.mjs +285 -0
  11. package/skills/setup-modwall/SKILL.md +10 -11
  12. package/skills/setup-testcraft/SKILL.md +9 -3
  13. package/skills/setup-testcraft/checklist/dev-login.md +3 -3
  14. package/skills/setup-testcraft/checklist/same-number.md +26 -0
  15. package/skills/write-tests/SKILL.md +12 -12
  16. package/src/base/baseline.ts +2 -2
  17. package/src/base/commands.ts +2 -40
  18. package/src/base/execute.ts +1 -11
  19. package/src/base/exit.ts +1 -1
  20. package/src/base/full.ts +7 -10
  21. package/src/base/git.ts +34 -3
  22. package/src/base/hook.ts +71 -17
  23. package/src/base/hookformat.ts +16 -6
  24. package/src/base/module.ts +8 -8
  25. package/src/base/repo.ts +8 -34
  26. package/src/base/sessions.ts +45 -13
  27. package/src/base/shell.ts +18 -10
  28. package/src/base/stop.ts +20 -6
  29. package/src/base/store.ts +15 -30
  30. package/src/cli.ts +3 -16
  31. package/src/craft/commands.ts +7 -1
  32. package/src/craft/defaults.ts +59 -0
  33. package/src/craft/session.ts +8 -4
  34. package/src/keep/check.ts +78 -39
  35. package/src/keep/config.ts +56 -26
  36. package/src/keep/eslint.ts +130 -5
  37. package/src/keep/loosen.ts +11 -61
  38. package/src/keep/session.ts +19 -5
  39. package/src/keep/styles.ts +72 -0
  40. package/src/pace/commands.ts +9 -3
  41. package/src/pace/full.ts +14 -25
  42. package/src/pace/index.ts +3 -0
  43. package/src/pace/record.ts +12 -6
  44. package/src/pace/results.ts +43 -2
  45. package/src/pace/run/playwright-reporter.mjs +5 -4
  46. package/src/pace/run/runner.ts +13 -7
  47. package/src/pace/run/targets.ts +3 -2
  48. package/src/pace/session.ts +3 -3
  49. package/src/pace/unfinished.ts +87 -0
  50. package/src/pace/unmerged.ts +87 -0
  51. package/src/pace/verify.ts +2 -2
  52. package/src/wall/commands.ts +92 -26
  53. package/src/wall/database.ts +12 -1
  54. package/src/wall/dbcheck.ts +2 -2
  55. package/src/wall/dbrules.ts +60 -19
  56. package/src/wall/literals.ts +162 -0
  57. package/src/wall/migrate.ts +248 -0
  58. package/src/wall/project.ts +29 -9
  59. package/src/wall/receipt.ts +2 -1
  60. package/src/wall/session.ts +5 -5
  61. package/src/wall/store.ts +3 -1
@@ -8,9 +8,10 @@ import { currentBranch, fileNow, filesNow, forkPoint } from '../base/git.ts'
8
8
  import { judgingFile } from '../base/judging.ts'
9
9
  import { hash } from '../base/records.ts'
10
10
  import { type Config, CONFIG_PATH, joined, MODWALL_DIR, parseConfig, readConfig } from './config.ts'
11
- import { isCode } from './files.ts'
11
+ import { isCode, isTest } from './files.ts'
12
12
  import { Layout } from './layout.ts'
13
- import { type ConfigSide, configText } from './loosen.ts'
13
+ import { type ConfigSide, looseningItems } from './loosen.ts'
14
+ import type { PassRecord, Store } from './store.ts'
14
15
 
15
16
  export interface Project {
16
17
  root: string
@@ -57,19 +58,23 @@ export function layoutOf(project: Project, config: Config): Layout {
57
58
  return new Layout(config, project.files)
58
59
  }
59
60
 
60
- /** 影响检查结果的文件:代码文件(含测试),JSON(配置、路径别名、包清单、小程序页面配置),Python 和 Go 的项目文件,SQL(迁移),小程序的模板和样式。 */
61
- const MATTERS = (path: string): boolean => isCode(path) || /\.(?:json|toml|sql|wxml|wxss)$/.test(path) || /(?:^|\/)go\.(?:mod|work)$/.test(path)
61
+ /**
62
+ * 影响检查结果的文件:代码文件,JSON(配置、路径别名、包清单、小程序页面配置),Python 和 Go 的项目文件,SQL(迁移),小程序的模板和样式。
63
+ * 测试文件不算:检查不看测试发起的引用,算进来的话只改测试也要重跑。正式代码引用测试文件那种越界,整组里的 modwall check 照查(整组不看通过记录)。
64
+ */
65
+ const MATTERS = (path: string): boolean =>
66
+ !isTest(path) && (isCode(path) || /\.(?:json|toml|sql|wxml|wxss)$/.test(path) || /(?:^|\/)go\.(?:mod|work)$/.test(path))
62
67
 
63
68
  /** contentKey 的算法的名字:算法变了要改它,会话起点里以前记的样子就不算了(见 base/baseline.ts)。 */
64
- export const CONTENT_FORMAT = 'content-1'
69
+ export const CONTENT_FORMAT = 'content-2'
65
70
 
66
71
  /**
67
- * 当前内容的摘要:分叉点上的配置加上影响检查结果的文件。通过记录、会话起点都按它记。
68
- * 检查能不能过,和分叉点有关的只有那里的配置(放宽项和它比;R4、入口清单只是提示),所以不记分叉点的提交号:
69
- * 在默认分支上提交、默认分支往前走,都不让通过记录失效;分叉点上的配置变了才失效。
72
+ * 当前内容的摘要:影响检查结果的文件。通过记录、会话起点都按它记。
73
+ * 不含分叉点上的配置:检查过不过和分叉点有关的只有放宽项,记在通过记录里(checkPassed)。含了的话,
74
+ * 分支改过配置、快进到默认分支后分叉点变成自己,合并前刚通过的记录就对不上了。
70
75
  */
71
76
  export function contentKey(project: Project): string {
72
- const parts: string[] = [project.base ? (project.before.config ? configText(project.before.config) : 'no-config') : 'no-base']
77
+ const parts: string[] = [project.base ? 'base' : 'no-base']
73
78
  for (const path of project.files.filter(MATTERS).sort()) {
74
79
  parts.push(path)
75
80
  try {
@@ -81,6 +86,21 @@ export function contentKey(project: Project): string {
81
86
  return hash(...parts)
82
87
  }
83
88
 
89
+ /** 检查通过时要记的:通过时和分叉点比出来的放宽项(都经用户同意过,不然过不了)。 */
90
+ export function passRecord(project: Project): PassRecord {
91
+ return { at: Date.now(), loosening: looseningItems(project.before.config, project.now).map(item => item.text) }
92
+ }
93
+
94
+ /**
95
+ * 当前内容 modwall check 通过过:有这份内容的通过记录,现在和分叉点比出来的放宽项都在通过时那一组里。
96
+ * 分叉点挪了(快进、合进默认分支)放宽项只会少;多出来的没经用户同意,要重跑。
97
+ */
98
+ export function checkPassed(project: Project, store: Store): boolean {
99
+ const record = store.passes.get(contentKey(project))
100
+ if (!record) return false
101
+ return looseningItems(project.before.config, project.now).every(item => record.loosening.includes(item.text))
102
+ }
103
+
84
104
  /** 这个仓库现在的内容摘要(重新打开一遍);没接入时为 undefined。写通过记录前用它核对内容没变。 */
85
105
  export function currentKey(root: string): string | undefined {
86
106
  const opened = openProject(root)
@@ -45,7 +45,8 @@ function readReceipts(path: string): DbReceipt[] {
45
45
  })
46
46
  }
47
47
 
48
- /** 工作区的配置里写了 database 的应用(单应用的写法为 null)。配置有问题的不算:整组里的 modwall check 已经报了。 */
48
+ /** 工作区的配置里写了 database 的应用(单应用的写法为 null)。配置有问题的不算:整组里的 modwall check 已经报了。
49
+ * 不按分叉点要凭据:删掉 database 本来就算放宽、要用户同意,同意了还按分叉点要,modwall db check 交不出凭据,整组永远过不了。 */
49
50
  function databaseApps(root: string): Array<string | null> {
50
51
  const { config } = readConfig(fileNow(root, CONFIG_PATH))
51
52
  if (!config) return []
@@ -17,7 +17,7 @@ import { type App, CONFIG_PATH, joined, readConfig, type Scheme, schemeOf } from
17
17
  import { entryBypass } from './edit.ts'
18
18
  import { isCode, unreadDirectory } from './files.ts'
19
19
  import { type Layout, type Module, ownerIn } from './layout.ts'
20
- import { CONTENT_FORMAT, contentKey, layoutOf, openProject } from './project.ts'
20
+ import { checkPassed, CONTENT_FORMAT, contentKey, layoutOf, openProject } from './project.ts'
21
21
  import { unownedText } from './rules.ts'
22
22
  import { MODULE, openStore } from './store.ts'
23
23
 
@@ -47,13 +47,13 @@ export function onSession(repo: Repo, sessionId: string): void {
47
47
  }
48
48
 
49
49
  /** 停止门:这个会话在这个仓库里改了代码或配置(和起点比;没有起点的不算这个会话改的),当前内容还没有 modwall check 的通过记录。 */
50
- export function unfinished(repo: Repo, sessionId: string, seen: readonly string[], named: boolean): { keys: string[]; text: string } | undefined {
50
+ export function unfinished(repo: Repo, sessionId: string, seen: (key: string) => boolean, named: boolean): { keys: string[]; text: string } | undefined {
51
51
  const opened = openProject(repo.root)
52
52
  if ('notJoined' in opened) return undefined
53
53
  const now = contentKey(opened.project)
54
- if (baselines(repo).since(sessionId, now) === now || openStore(repo).passes.get(now)) return undefined
54
+ if (baselines(repo).since(sessionId, now) === now || checkPassed(opened.project, openStore(repo))) return undefined
55
55
  const key = `wall:check:${now}`
56
- if (seen.includes(key)) return undefined
56
+ if (seen(key)) return undefined
57
57
  return {
58
58
  keys: [key],
59
59
  text:
@@ -111,7 +111,7 @@ function databaseLines(scheme: Scheme): string[] {
111
111
  ? '每个模块一个同名的数据库角色,程序每个事务开头切成模块的角色'
112
112
  : `每个模块一个同名的数据库角色(拥有对象,迁移切成它跑)和一个运行角色(${db.runtime},只有本模块的读写授权,不拥有对象、不建对象),程序每个事务开头切成模块的运行角色`
113
113
  return [
114
- `- ${at}数据库(Postgres)也按模块分:模块的表、视图、函数建在它的内部 schema(模块目录名转成小写加下划线,adminAccess → admin_access),给别的模块用的视图和函数放进入口 schema(<内部 schema>_api,不放表);别的模块只引用对方入口 schema 里的对象,不在对方入口上建视图(跨模块读取写在函数正文或代码里),写入走对方入口里的函数,入口只加不改(入口里的类型别的模块可以用),模块之间不建外键(只存 id);只在自己的两个 schema 里建、改、删对象;共享层用 shared,public 里不放对象。迁移放在模块目录下的 ${db.migrations}/(共享层的在 ${db.shared}/),文件名以 14 位时间戳开头,只写正向(一个时间戳一个文件);迁移里不建 schema(跑迁移的工具建);函数一律带 SET search_path = <本模块的内部 schema>, pg_temp、一律 SECURITY DEFINER,迁移和函数里不改 search_path,引用别的模块、shared 写带 schema 的全名;别名、变量不和模块的 schema 同名,引用的表名和别的模块的 schema 同名时起别名。${roles}:迁移和模块的代码里不自己切身份(SET ROLE、set_config('role', …)),切身份只在装配层或共享层的那个小函数里。`,
114
+ `- ${at}数据库(Postgres)也按模块分:模块的表、视图、函数建在它的内部 schema(模块目录名转成小写加下划线,adminAccess → admin_access),给别的模块用的视图和函数放进入口 schema(<内部 schema>_api,不放表);别的模块只引用对方入口 schema 里的对象,不在对方入口上建视图(跨模块读取写在函数正文或代码里),写入走对方入口里的函数,入口只加不改(入口里的类型别的模块可以用),模块之间不建外键(只存 id);只在自己的两个 schema 里建、改、删对象;共享层用 shared,public 里不放对象。迁移放在模块目录下的 ${db.migrations}/(共享层的在 ${db.shared}/),文件名以 14 位时间戳开头,只写正向(一个时间戳一个文件);迁移里不建 schema(modwall migrate 建),写了迁移就用 modwall migrate 跑,跑过的迁移不改不删;函数一律带 SET search_path = <本模块的内部 schema>, pg_temp、一律 SECURITY DEFINER,迁移和函数里不改 search_path,引用别的模块、shared 写带 schema 的全名;别名、变量不和模块的 schema 同名,引用的表名和别的模块的 schema 同名时起别名。${roles}:迁移和模块的代码里不自己切身份(SET ROLE、set_config('role', …)),切身份只在装配层或共享层的那个小函数里。`,
115
115
  ]
116
116
  })
117
117
  }
package/src/wall/store.ts CHANGED
@@ -8,6 +8,8 @@ import { newRunId } from '../base/store.ts'
8
8
 
9
9
  export interface PassRecord {
10
10
  at: number
11
+ /** 通过时和分叉点比出来的放宽项(给用户看的文字)。 */
12
+ loosening: string[]
11
13
  }
12
14
 
13
15
  /** 一个分支上一次查全了的检查:下一次据此算改正了哪些越界。 */
@@ -17,7 +19,7 @@ export interface LastCheck {
17
19
  }
18
20
 
19
21
  export interface Store {
20
- /** modwall check 的通过记录,按当时的内容记,内容变了就对不上。 */
22
+ /** modwall check 的通过记录,按当时的内容记,内容变了就对不上(还算不算数见 project.ts 的 checkPassed)。 */
21
23
  passes: ModuleRecords<PassRecord>
22
24
  /** 按分支记。 */
23
25
  last: ModuleRecords<LastCheck>