@autopilot-harness/cli 0.1.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 (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +55 -0
  3. package/assets/autopilot-harness-hook.mjs +193 -0
  4. package/assets/vendor/migrations/001_initial.sql +62 -0
  5. package/assets/vendor/migrations/002_pending_followup.sql +4 -0
  6. package/assets/vendor/migrations/003_reviewing_item.sql +1 -0
  7. package/assets/vendor/runtime.mjs +5524 -0
  8. package/dist/assets/autopilot-harness-hook.mjs +193 -0
  9. package/dist/assets/vendor/migrations/001_initial.sql +62 -0
  10. package/dist/assets/vendor/migrations/002_pending_followup.sql +4 -0
  11. package/dist/assets/vendor/migrations/003_reviewing_item.sql +1 -0
  12. package/dist/assets/vendor/runtime.mjs +5524 -0
  13. package/dist/bin.d.ts +3 -0
  14. package/dist/bin.d.ts.map +1 -0
  15. package/dist/bin.js +300 -0
  16. package/dist/bin.js.map +1 -0
  17. package/dist/index.d.ts +23 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +13 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/init/config-merge.d.ts +27 -0
  22. package/dist/init/config-merge.d.ts.map +1 -0
  23. package/dist/init/config-merge.js +115 -0
  24. package/dist/init/config-merge.js.map +1 -0
  25. package/dist/init/default-config.d.ts +17 -0
  26. package/dist/init/default-config.d.ts.map +1 -0
  27. package/dist/init/default-config.js +101 -0
  28. package/dist/init/default-config.js.map +1 -0
  29. package/dist/init/hooks-merge.d.ts +25 -0
  30. package/dist/init/hooks-merge.d.ts.map +1 -0
  31. package/dist/init/hooks-merge.js +134 -0
  32. package/dist/init/hooks-merge.js.map +1 -0
  33. package/dist/init/install.d.ts +31 -0
  34. package/dist/init/install.d.ts.map +1 -0
  35. package/dist/init/install.js +829 -0
  36. package/dist/init/install.js.map +1 -0
  37. package/dist/init/platforms.d.ts +60 -0
  38. package/dist/init/platforms.d.ts.map +1 -0
  39. package/dist/init/platforms.js +275 -0
  40. package/dist/init/platforms.js.map +1 -0
  41. package/dist/init/tui.d.ts +65 -0
  42. package/dist/init/tui.d.ts.map +1 -0
  43. package/dist/init/tui.js +549 -0
  44. package/dist/init/tui.js.map +1 -0
  45. package/dist/init/types.d.ts +75 -0
  46. package/dist/init/types.d.ts.map +1 -0
  47. package/dist/init/types.js +9 -0
  48. package/dist/init/types.js.map +1 -0
  49. package/dist/init/wizard-copy.d.ts +74 -0
  50. package/dist/init/wizard-copy.d.ts.map +1 -0
  51. package/dist/init/wizard-copy.js +173 -0
  52. package/dist/init/wizard-copy.js.map +1 -0
  53. package/dist/init/wizard-helpers.d.ts +103 -0
  54. package/dist/init/wizard-helpers.d.ts.map +1 -0
  55. package/dist/init/wizard-helpers.js +724 -0
  56. package/dist/init/wizard-helpers.js.map +1 -0
  57. package/dist/locale-set.d.ts +24 -0
  58. package/dist/locale-set.d.ts.map +1 -0
  59. package/dist/locale-set.js +286 -0
  60. package/dist/locale-set.js.map +1 -0
  61. package/dist/names.d.ts +5 -0
  62. package/dist/names.d.ts.map +1 -0
  63. package/dist/names.js +5 -0
  64. package/dist/names.js.map +1 -0
  65. package/dist/project-fs.d.ts +48 -0
  66. package/dist/project-fs.d.ts.map +1 -0
  67. package/dist/project-fs.js +210 -0
  68. package/dist/project-fs.js.map +1 -0
  69. package/dist/read-untrusted-file.d.ts +41 -0
  70. package/dist/read-untrusted-file.d.ts.map +1 -0
  71. package/dist/read-untrusted-file.js +362 -0
  72. package/dist/read-untrusted-file.js.map +1 -0
  73. package/dist/session.d.ts +38 -0
  74. package/dist/session.d.ts.map +1 -0
  75. package/dist/session.js +242 -0
  76. package/dist/session.js.map +1 -0
  77. package/dist/status-doctor.d.ts +22 -0
  78. package/dist/status-doctor.d.ts.map +1 -0
  79. package/dist/status-doctor.js +712 -0
  80. package/dist/status-doctor.js.map +1 -0
  81. package/dist/uninstall.d.ts +31 -0
  82. package/dist/uninstall.d.ts.map +1 -0
  83. package/dist/uninstall.js +333 -0
  84. package/dist/uninstall.js.map +1 -0
  85. package/dist/upgrade.d.ts +29 -0
  86. package/dist/upgrade.d.ts.map +1 -0
  87. package/dist/upgrade.js +290 -0
  88. package/dist/upgrade.js.map +1 -0
  89. package/dist/vendor-entry.d.ts +6 -0
  90. package/dist/vendor-entry.d.ts.map +1 -0
  91. package/dist/vendor-entry.js +16 -0
  92. package/dist/vendor-entry.js.map +1 -0
  93. package/package.json +54 -0
@@ -0,0 +1,290 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { createRequire } from "node:module";
4
+ import { StateStore } from "@autopilot-harness/core";
5
+ import { defaultConfigYaml } from "./init/default-config.js";
6
+ import { mergeConfigYamlMissingKeys, readConfigInstallHints, } from "./init/config-merge.js";
7
+ import { installInitYes, preflightForceRefresh } from "./init/install.js";
8
+ import { PACKAGE_VERSION } from "./init/types.js";
9
+ import { MAX_UNTRUSTED_TEXT_BYTES, readUntrustedUtf8File, writeFileReplaceSync, assertNotSymlink, copyFileNoFollowExclSync, } from "./read-untrusted-file.js";
10
+ import { assertParentDirInProject, assertRealpathInside, assertWrittenInsideProject, mkdirRealDirSync, } from "./init/wizard-helpers.js";
11
+ import { runDoctor } from "./status-doctor.js";
12
+ const require = createRequire(import.meta.url);
13
+ function writeFileAtomic(filePath, contents, projectRoot) {
14
+ mkdirRealDirSync(path.dirname(filePath), ".autopilot/", projectRoot);
15
+ assertParentDirInProject(projectRoot, filePath, ".autopilot/");
16
+ writeFileReplaceSync(filePath, contents);
17
+ assertWrittenInsideProject(projectRoot, filePath, path.basename(filePath));
18
+ }
19
+ function trySerializeDb(projectRoot, dbPath) {
20
+ try {
21
+ // DatabaseSync opens by path (follows symlinks). Probe with O_NOFOLLOW and
22
+ // realpath-inside first; if either fails, fall through to nofollow copy bak.
23
+ assertNotSymlink(dbPath, ".autopilot/state.db");
24
+ assertRealpathInside(projectRoot, dbPath, ".autopilot/state.db");
25
+ const nofollow = typeof fs.constants.O_NOFOLLOW === "number" ? fs.constants.O_NOFOLLOW : 0;
26
+ if (nofollow === 0) {
27
+ assertNotSymlink(dbPath, ".autopilot/state.db");
28
+ }
29
+ else {
30
+ const probeFd = fs.openSync(dbPath, fs.constants.O_RDONLY | nofollow);
31
+ try {
32
+ if (!fs.fstatSync(probeFd).isFile())
33
+ return null;
34
+ }
35
+ finally {
36
+ fs.closeSync(probeFd);
37
+ }
38
+ }
39
+ const { DatabaseSync } = require("node:sqlite");
40
+ const db = new DatabaseSync(dbPath, { readOnly: true });
41
+ try {
42
+ const payload = db.serialize();
43
+ if (!payload || payload.byteLength === 0)
44
+ return null;
45
+ return payload;
46
+ }
47
+ finally {
48
+ db.close();
49
+ }
50
+ }
51
+ catch {
52
+ return null;
53
+ }
54
+ }
55
+ function backupStateDbByCopy(projectRoot, stamp) {
56
+ const dbPath = path.join(projectRoot, ".autopilot", "state.db");
57
+ const written = [];
58
+ const pairs = [
59
+ { src: dbPath, destName: `state.db.bak.${stamp}` },
60
+ { src: `${dbPath}-wal`, destName: `state.db-wal.bak.${stamp}` },
61
+ { src: `${dbPath}-shm`, destName: `state.db-shm.bak.${stamp}` },
62
+ ];
63
+ for (const { src, destName: name } of pairs) {
64
+ try {
65
+ const st = fs.lstatSync(src);
66
+ if (st.isSymbolicLink()) {
67
+ throw new Error(`${path.basename(src)} is a symlink; refusing to open`);
68
+ }
69
+ if (!st.isFile())
70
+ continue;
71
+ }
72
+ catch (err) {
73
+ const code = err?.code;
74
+ if (code === "ENOENT")
75
+ continue;
76
+ throw err;
77
+ }
78
+ const out = path.join(projectRoot, ".autopilot", name);
79
+ assertParentDirInProject(projectRoot, out, ".autopilot/");
80
+ // Never copyFileSync(src): it follows a raced source symlink (read-through).
81
+ copyFileNoFollowExclSync(src, out, path.basename(src));
82
+ assertWrittenInsideProject(projectRoot, out, name);
83
+ written.push(path.relative(projectRoot, out));
84
+ }
85
+ return written;
86
+ }
87
+ /**
88
+ * Consistent state.db snapshot via sqlite serialize() (covers WAL contents).
89
+ * Only falls back to file copies when serialize/open itself fails — never after
90
+ * a failed write of an already-serialized payload (avoids torn/partial bak).
91
+ */
92
+ function backupStateDb(projectRoot) {
93
+ const dbPath = path.join(projectRoot, ".autopilot", "state.db");
94
+ assertNotSymlink(dbPath, ".autopilot/state.db");
95
+ try {
96
+ const st = fs.lstatSync(dbPath);
97
+ if (!st.isFile()) {
98
+ throw new Error(".autopilot/state.db is not a regular file");
99
+ }
100
+ }
101
+ catch (err) {
102
+ const code = err?.code;
103
+ if (code === "ENOENT")
104
+ return [];
105
+ throw err;
106
+ }
107
+ const stamp = `${new Date().toISOString().replaceAll(":", "-")}.p${process.pid}`;
108
+ const snapshot = trySerializeDb(projectRoot, dbPath);
109
+ if (snapshot) {
110
+ const dest = path.join(projectRoot, ".autopilot", `state.db.bak.${stamp}`);
111
+ assertParentDirInProject(projectRoot, dest, ".autopilot/");
112
+ fs.writeFileSync(dest, snapshot, { flag: "wx" });
113
+ assertWrittenInsideProject(projectRoot, dest, path.basename(dest));
114
+ return [path.relative(projectRoot, dest)];
115
+ }
116
+ return backupStateDbByCopy(projectRoot, `${stamp}.copy`);
117
+ }
118
+ function migrateStateDb(projectRoot) {
119
+ const store = new StateStore(projectRoot);
120
+ try {
121
+ return store.getSchemaVersion();
122
+ }
123
+ finally {
124
+ store.close();
125
+ }
126
+ }
127
+ /**
128
+ * Upgrade an already-initialized project to the current CLI package version.
129
+ * Refreshes hook/skills/workflows/pin, merges hooks, appends missing config
130
+ * keys, backs up + migrates state.db. Never touches plans/**.
131
+ */
132
+ export function upgradeProject(opts) {
133
+ if (typeof opts.projectRoot !== "string" || opts.projectRoot.trim() === "") {
134
+ return { ok: false, error: "projectRoot must be a non-empty string" };
135
+ }
136
+ const projectRoot = path.resolve(opts.projectRoot.trim());
137
+ const configPath = path.join(projectRoot, ".autopilot", "config.yml");
138
+ const version = typeof opts.packageVersion === "string" && opts.packageVersion.trim()
139
+ ? opts.packageVersion.trim()
140
+ : PACKAGE_VERSION;
141
+ const dryRun = Boolean(opts.dryRun);
142
+ const actions = [];
143
+ const written = [];
144
+ try {
145
+ let existingConfig;
146
+ try {
147
+ // Avoid existsSync: dangling symlinks look missing but must fail closed
148
+ // before backup/migrate.
149
+ existingConfig = readUntrustedUtf8File(configPath, MAX_UNTRUSTED_TEXT_BYTES, ".autopilot/config.yml");
150
+ }
151
+ catch (err) {
152
+ const code = err?.code;
153
+ if (code === "ENOENT") {
154
+ return {
155
+ ok: false,
156
+ error: "Project is not initialized (.autopilot/config.yml missing). Run init --yes first.",
157
+ };
158
+ }
159
+ throw err;
160
+ }
161
+ const hints = readConfigInstallHints(existingConfig);
162
+ const locale = hints.locale === "zh-CN" ? "zh-CN" : "en";
163
+ const platforms = hints.platforms.length > 0
164
+ ? hints.platforms
165
+ : [{ id: "cursor", surface: "ide" }];
166
+ // hints.platform/surface already prefer installable via primaryBinding.
167
+ const platform = hints.platform || platforms[0]?.id || "cursor";
168
+ // Defaults include platforms[] so upgrade can append the key to legacy configs.
169
+ const defaultsYaml = defaultConfigYaml({
170
+ platforms,
171
+ platform: hints.platform,
172
+ surface: hints.surface,
173
+ locale,
174
+ });
175
+ const merged = mergeConfigYamlMissingKeys(existingConfig, defaultsYaml);
176
+ const configAdded = merged.addedPaths;
177
+ if (configAdded.length > 0) {
178
+ actions.push(`append missing config keys: ${configAdded.join(", ")}`);
179
+ }
180
+ else {
181
+ actions.push("config.yml already has all known keys");
182
+ }
183
+ const dbPath = path.join(projectRoot, ".autopilot", "state.db");
184
+ let stateDbKind = "missing";
185
+ try {
186
+ const st = fs.lstatSync(dbPath);
187
+ if (st.isSymbolicLink()) {
188
+ return {
189
+ ok: false,
190
+ error: ".autopilot/state.db is a symlink; refusing to open",
191
+ };
192
+ }
193
+ if (!st.isFile()) {
194
+ return {
195
+ ok: false,
196
+ error: ".autopilot/state.db is not a regular file",
197
+ };
198
+ }
199
+ stateDbKind = "present";
200
+ }
201
+ catch (err) {
202
+ const code = err?.code;
203
+ if (code !== "ENOENT") {
204
+ const msg = err instanceof Error ? err.message : String(err);
205
+ return { ok: false, error: `Cannot access state.db: ${msg}` };
206
+ }
207
+ }
208
+ if (stateDbKind === "present") {
209
+ actions.push("backup state.db → state.db.bak.<timestamp> (snapshot)");
210
+ actions.push("migrate state.db (idempotent)");
211
+ }
212
+ else {
213
+ actions.push("no state.db yet (skip backup/migrate)");
214
+ }
215
+ actions.push(`update pin.json → ${version}`);
216
+ actions.push("refresh .autopilot/bin/autopilot-harness-hook.mjs");
217
+ actions.push("refresh .cursor/skills/autopilot-*");
218
+ actions.push("refresh docs/autopilot/workflows/*");
219
+ actions.push("merge .autopilotignore (append missing default patterns)");
220
+ actions.push("merge .cursor/hooks.json (Autopilot entries)");
221
+ if (opts.target && opts.target !== version) {
222
+ actions.push(`note: --target ${opts.target} ignored; pinning to CLI ${version}`);
223
+ }
224
+ // Fail closed before any backup/migrate/write (incl. dry-run honesty).
225
+ const preflight = preflightForceRefresh(projectRoot);
226
+ if (!preflight.ok) {
227
+ return { ok: false, error: preflight.error };
228
+ }
229
+ if (dryRun) {
230
+ return {
231
+ ok: true,
232
+ dryRun: true,
233
+ actions,
234
+ written: [],
235
+ doctorOk: true,
236
+ doctorLines: ["(dry-run) doctor not executed"],
237
+ platform,
238
+ };
239
+ }
240
+ // Backup → migrate → refresh. Additive schema must land before new vendor
241
+ // runtime is copied; otherwise a migrate throw leaves new hooks + old DB.
242
+ // Schema ceiling comes from scanning migration SQL on disk (see
243
+ // getLatestSchemaVersion); cli build compiles core before bundling so the
244
+ // scanner is present — an older binary with a hardcoded ceiling would still
245
+ // skip new files until rebuilt.
246
+ written.push(...backupStateDb(projectRoot));
247
+ if (stateDbKind === "present") {
248
+ migrateStateDb(projectRoot);
249
+ }
250
+ // Refresh pin/hooks/skills after migrate so a hooks fail-closed path does
251
+ // not leave config.yml already rewritten with appended keys.
252
+ const refresh = installInitYes({
253
+ projectRoot,
254
+ platform: "cursor",
255
+ surface: "ide",
256
+ locale,
257
+ force: true,
258
+ packageVersion: version,
259
+ });
260
+ if (!refresh.ok) {
261
+ const bakNote = written.length > 0
262
+ ? ` (partial writes/backups: ${written.join(", ")})`
263
+ : "";
264
+ return { ok: false, error: `${refresh.error}${bakNote}` };
265
+ }
266
+ written.push(...refresh.written);
267
+ if (configAdded.length > 0) {
268
+ writeFileAtomic(configPath, merged.yaml, projectRoot);
269
+ written.push(path.relative(projectRoot, configPath));
270
+ }
271
+ const doctor = runDoctor(projectRoot);
272
+ return {
273
+ ok: true,
274
+ dryRun: false,
275
+ actions,
276
+ written,
277
+ doctorOk: doctor.ok,
278
+ doctorLines: doctor.lines,
279
+ platform,
280
+ };
281
+ }
282
+ catch (err) {
283
+ const msg = err instanceof Error ? err.message : String(err);
284
+ const partial = written.length > 0
285
+ ? ` (partial writes/backups: ${written.join(", ")})`
286
+ : "";
287
+ return { ok: false, error: `${msg}${partial}` };
288
+ }
289
+ }
290
+ //# sourceMappingURL=upgrade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../src/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wB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AAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,EAAE,EAAE,CAAC;QAC5D,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAEjC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;QACtC,OAAO;YACL,EAAE,EAAE,IAAI;YACR,MAAM,EAAE,KAAK;YACb,OAAO;YACP,OAAO;YACP,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,WAAW,EAAE,MAAM,CAAC,KAAK;YACzB,QAAQ;SACT,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,MAAM,OAAO,GACX,OAAO,CAAC,MAAM,GAAG,CAAC;YAChB,CAAC,CAAC,6BAA6B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;YACpD,CAAC,CAAC,EAAE,CAAC;QACT,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,OAAO,EAAE,EAAE,CAAC;IAClD,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { ReviewEngine, StateStore, getLatestSchemaVersion, loadProjectReviewConfig } from "@autopilot-harness/core";
2
+ export { StateStore, ReviewEngine, getLatestSchemaVersion, loadProjectReviewConfig, };
3
+ export { handleBeforeSubmitPrompt, handleAfterFileEdit, handleStop, } from "@autopilot-harness/port-cursor";
4
+ /** Build a ReviewEngine wired to project config.yml + locale followups/lenses. */
5
+ export declare function createConfiguredReviewEngine(store: InstanceType<typeof StateStore>, projectRoot: string): InstanceType<typeof ReviewEngine>;
6
+ //# sourceMappingURL=vendor-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendor-entry.d.ts","sourceRoot":"","sources":["../src/vendor-entry.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,YAAY,EACZ,UAAU,EAEV,sBAAsB,EACtB,uBAAuB,EAExB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,GACxB,CAAC;AAEF,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,UAAU,GACX,MAAM,gCAAgC,CAAC;AAExC,kFAAkF;AAClF,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,YAAY,CAAC,OAAO,UAAU,CAAC,EACtC,WAAW,EAAE,MAAM,GAClB,YAAY,CAAC,OAAO,YAAY,CAAC,CAKnC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Single ESM entry bundled into assets/vendor/runtime.mjs for project hooks.
3
+ * Consumers get core + port-cursor + i18n without installing workspace packages.
4
+ */
5
+ import { loadLocale } from "@autopilot-harness/i18n";
6
+ import { ReviewEngine, StateStore, createConfiguredReviewEngine as createConfiguredReviewEngineCore, getLatestSchemaVersion, loadProjectReviewConfig, } from "@autopilot-harness/core";
7
+ export { StateStore, ReviewEngine, getLatestSchemaVersion, loadProjectReviewConfig, };
8
+ export { handleBeforeSubmitPrompt, handleAfterFileEdit, handleStop, } from "@autopilot-harness/port-cursor";
9
+ /** Build a ReviewEngine wired to project config.yml + locale followups/lenses. */
10
+ export function createConfiguredReviewEngine(store, projectRoot) {
11
+ // Đọc config một lần rồi truyền xuống core — tránh TOCTOU locale vs rounds.
12
+ const cfg = loadProjectReviewConfig(projectRoot);
13
+ const bundle = loadLocale(cfg.locale);
14
+ return createConfiguredReviewEngineCore(store, projectRoot, bundle, cfg);
15
+ }
16
+ //# sourceMappingURL=vendor-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendor-entry.js","sourceRoot":"","sources":["../src/vendor-entry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EACL,YAAY,EACZ,UAAU,EACV,4BAA4B,IAAI,gCAAgC,EAChE,sBAAsB,EACtB,uBAAuB,GAExB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,UAAU,EACV,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,GACxB,CAAC;AAEF,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,UAAU,GACX,MAAM,gCAAgC,CAAC;AAExC,kFAAkF;AAClF,MAAM,UAAU,4BAA4B,CAC1C,KAAsC,EACtC,WAAmB;IAEnB,4EAA4E;IAC5E,MAAM,GAAG,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAyB,CAAC;IAC9D,OAAO,gCAAgC,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;AAC3E,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@autopilot-harness/cli",
3
+ "version": "0.1.0",
4
+ "description": "Autopilot harness CLI (bin: autopilot-harness)",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/mt2007/autopilot-harness.git",
9
+ "directory": "packages/cli"
10
+ },
11
+ "homepage": "https://github.com/mt2007/autopilot-harness#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/mt2007/autopilot-harness/issues"
14
+ },
15
+ "type": "module",
16
+ "bin": {
17
+ "autopilot-harness": "./dist/bin.js"
18
+ },
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "assets"
30
+ ],
31
+ "dependencies": {
32
+ "@clack/prompts": "^0.10.0",
33
+ "commander": "^13.1.0",
34
+ "yaml": "^2.7.0",
35
+ "@autopilot-harness/core": "0.1.0",
36
+ "@autopilot-harness/i18n": "0.1.0",
37
+ "@autopilot-harness/port-cursor": "0.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "esbuild": "^0.25.12",
41
+ "typescript": "^5.8.2"
42
+ },
43
+ "engines": {
44
+ "node": ">=22"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "scripts": {
50
+ "bundle-vendor": "node ./scripts/bundle-vendor.mjs",
51
+ "build": "pnpm --filter @autopilot-harness/core run build && node ./scripts/bundle-vendor.mjs && tsc -p tsconfig.json && rm -rf dist/assets && cp -R assets dist/assets",
52
+ "typecheck": "tsc -p tsconfig.json --noEmit"
53
+ }
54
+ }