@kyun.si/codex-polish 0.0.0-stage → 0.0.1-beta.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 (37) hide show
  1. package/.agents/plugins/marketplace.json +12 -0
  2. package/CHANGELOG.md +19 -0
  3. package/CONTRIBUTING.en.md +47 -0
  4. package/CONTRIBUTING.md +46 -0
  5. package/Install Codex Polish.command +29 -0
  6. package/LICENSE +202 -0
  7. package/README.en.md +77 -0
  8. package/README.md +78 -2
  9. package/SECURITY.en.md +17 -0
  10. package/SECURITY.md +17 -0
  11. package/docs/technical.en.md +98 -0
  12. package/docs/technical.md +91 -0
  13. package/evaluation/README.en.md +47 -0
  14. package/evaluation/README.md +47 -0
  15. package/package.json +48 -4
  16. package/plugins/codex-polish/.codex-plugin/plugin.json +21 -0
  17. package/plugins/codex-polish/LICENSE +202 -0
  18. package/plugins/codex-polish/hooks/history.mjs +169 -0
  19. package/plugins/codex-polish/hooks/hooks.json +15 -0
  20. package/plugins/codex-polish/hooks/preferences.mjs +401 -0
  21. package/plugins/codex-polish/hooks/project_setting.mjs +92 -0
  22. package/plugins/codex-polish/hooks/recovery.mjs +201 -0
  23. package/plugins/codex-polish/hooks/ui_locale.mjs +61 -0
  24. package/plugins/codex-polish/skills/codex-polish/SKILL.md +36 -0
  25. package/plugins/codex-polish/skills/codex-polish/references/acp.md +94 -0
  26. package/plugins/codex-polish/skills/codex-polish/references/codex-polish-editor.md +15 -0
  27. package/plugins/codex-polish/skills/codex-polish/scripts/acp_models.mjs +99 -0
  28. package/plugins/codex-polish/skills/codex-polish/scripts/acp_payload.mjs +53 -0
  29. package/plugins/codex-polish/skills/codex-polish/scripts/cli_io.mjs +29 -0
  30. package/plugins/codex-polish/skills/codex-polish/scripts/decisions.mjs +224 -0
  31. package/plugins/codex-polish/skills/codex-polish/scripts/text_guard.mjs +203 -0
  32. package/plugins/codex-polish/skills/codex-polish-setup/SKILL.md +52 -0
  33. package/plugins/codex-polish/skills/codex-polish-setup/references/credentials.en.md +45 -0
  34. package/plugins/codex-polish/skills/codex-polish-setup/references/credentials.md +54 -0
  35. package/scripts/install.mjs +1216 -0
  36. package/scripts/native_cache.mjs +86 -0
  37. package//345/256/211/350/243/205/345/233/236/345/244/215/346/266/246/350/211/262.command +2 -0
@@ -0,0 +1,86 @@
1
+ // Keep local edits before Codex replaces or removes its versioned cache.
2
+ import * as fs from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { createHash } from 'node:crypto';
5
+ import { isDeepStrictEqual } from 'node:util';
6
+ import { tr } from '../plugins/codex-polish/hooks/ui_locale.mjs';
7
+
8
+ const { O_RDONLY, O_NOFOLLOW, O_NONBLOCK } = fs.constants;
9
+ export function treeContents(root) {
10
+ const contents = new Map();
11
+ function visit(relative) {
12
+ const file = join(root, relative);
13
+ const info = fs.lstatSync(file);
14
+ if (info.isDirectory()) {
15
+ contents.set(relative, info.mode & 0o7777);
16
+ return fs.readdirSync(file).every((name) => visit(join(relative, name)));
17
+ }
18
+ if (!info.isFile()) return false;
19
+ const fd = fs.openSync(file, O_RDONLY | O_NOFOLLOW | O_NONBLOCK);
20
+ try {
21
+ const actual = fs.fstatSync(fd);
22
+ if (!actual.isFile() || actual.dev !== info.dev || actual.ino !== info.ino) return false;
23
+ const hash = createHash('sha256');
24
+ const buffer = Buffer.allocUnsafe(65536);
25
+ let count;
26
+ while ((count = fs.readSync(fd, buffer)) > 0) hash.update(buffer.subarray(0, count));
27
+ contents.set(relative, [actual.mode & 0o7777, hash.digest('hex')]);
28
+ return true;
29
+ } finally {
30
+ fs.closeSync(fd);
31
+ }
32
+ }
33
+ return visit('') ? contents : null;
34
+ }
35
+
36
+ export function preserve(profile, market, name, version, getSource) {
37
+ let parent = profile;
38
+ let cache;
39
+ try {
40
+ for (const component of ['plugins', 'cache', market]) {
41
+ parent = join(parent, component);
42
+ if (!fs.lstatSync(parent).isDirectory()) {
43
+ throw new Error(tr(`不是预期的缓存目录:${parent}`, `Unexpected cache directory: ${parent}`));
44
+ }
45
+ }
46
+ cache = join(parent, name);
47
+ fs.lstatSync(cache);
48
+ } catch (error) {
49
+ if (error.code === 'ENOENT') return null;
50
+ throw error;
51
+ }
52
+ // Rename a cache containing special files or unreadable data as a whole.
53
+ try {
54
+ if (fs.lstatSync(cache).isDirectory()) {
55
+ const entries = fs.readdirSync(cache);
56
+ if (!entries.length) return null;
57
+ if (entries.length === 1 && entries[0] === version && fs.lstatSync(join(cache, version)).isDirectory()) {
58
+ const source = getSource();
59
+ if (source) {
60
+ const expected = treeContents(source);
61
+ if (expected && isDeepStrictEqual(expected, treeContents(join(cache, version)))) return null;
62
+ }
63
+ }
64
+ }
65
+ } catch (error) {
66
+ if (!error.code) throw error;
67
+ }
68
+ const backups = join(profile, 'codex-polish-backups');
69
+ try {
70
+ fs.mkdirSync(backups, { mode: 0o700 });
71
+ } catch (error) {
72
+ if (error.code !== 'EEXIST') throw error;
73
+ }
74
+ if (!fs.lstatSync(backups).isDirectory()) {
75
+ throw new Error(tr(`不是预期的备份目录:${backups}`, `Unexpected backup directory: ${backups}`));
76
+ }
77
+ const reservation = fs.mkdtempSync(join(backups, 'plugin-cache-'));
78
+ const destination = join(reservation, name);
79
+ try {
80
+ fs.renameSync(cache, destination);
81
+ } catch (error) {
82
+ fs.rmdirSync(reservation);
83
+ throw error;
84
+ }
85
+ return destination;
86
+ }
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ exec "$(dirname "$0")/Install Codex Polish.command" "$@"