aptly 0.1.12 → 0.1.13

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 (50) hide show
  1. package/dist/bin/aptly.js +16 -2
  2. package/dist/src/automatic-hook.d.ts +7 -0
  3. package/dist/src/automatic-hook.js +33 -15
  4. package/dist/src/cli-help.js +5 -4
  5. package/dist/src/context-retry.d.ts +10 -0
  6. package/dist/src/context-retry.js +16 -3
  7. package/dist/src/core.d.ts +2 -0
  8. package/dist/src/core.js +39 -35
  9. package/dist/src/doctor.d.ts +84 -0
  10. package/dist/src/doctor.js +163 -0
  11. package/dist/src/host-paths.d.ts +10 -0
  12. package/dist/src/host-paths.js +15 -0
  13. package/dist/src/query-snapshot.d.ts +17 -0
  14. package/dist/src/query-snapshot.js +112 -0
  15. package/dist/src/server.js +2 -0
  16. package/dist/src/setup.d.ts +7 -5
  17. package/dist/src/setup.js +155 -39
  18. package/dist/src/statistics.d.ts +48 -2
  19. package/dist/src/statistics.js +87 -6
  20. package/dist/src/version.d.ts +1 -1
  21. package/dist/src/version.js +1 -1
  22. package/docs/guide/en/advanced.md +6 -0
  23. package/docs/guide/en/configuration.md +3 -1
  24. package/docs/guide/en/installation.md +2 -2
  25. package/docs/guide/en/statistics.md +4 -0
  26. package/docs/guide/en/transmission.md +7 -5
  27. package/docs/guide/en/troubleshooting.md +4 -2
  28. package/docs/guide/en.md +2 -0
  29. package/docs/guide/ja/advanced.md +6 -0
  30. package/docs/guide/ja/configuration.md +3 -1
  31. package/docs/guide/ja/installation.md +2 -2
  32. package/docs/guide/ja/statistics.md +4 -0
  33. package/docs/guide/ja/transmission.md +7 -5
  34. package/docs/guide/ja/troubleshooting.md +4 -2
  35. package/docs/guide/ja.md +2 -0
  36. package/docs/guide/ko/advanced.md +6 -0
  37. package/docs/guide/ko/configuration.md +3 -1
  38. package/docs/guide/ko/installation.md +2 -2
  39. package/docs/guide/ko/statistics.md +4 -0
  40. package/docs/guide/ko/transmission.md +7 -5
  41. package/docs/guide/ko/troubleshooting.md +4 -2
  42. package/docs/guide/ko.md +2 -0
  43. package/docs/guide/zh-CN/advanced.md +6 -0
  44. package/docs/guide/zh-CN/configuration.md +3 -1
  45. package/docs/guide/zh-CN/installation.md +2 -2
  46. package/docs/guide/zh-CN/statistics.md +4 -0
  47. package/docs/guide/zh-CN/transmission.md +7 -5
  48. package/docs/guide/zh-CN/troubleshooting.md +4 -2
  49. package/docs/guide/zh-CN.md +2 -0
  50. package/package.json +1 -1
@@ -4,6 +4,7 @@ import { createRequire } from 'node:module';
4
4
  import { isAbsolute, join } from 'node:path';
5
5
  import { assertPrivateStatePath, readRegularFile } from './files.js';
6
6
  import { isRecord } from './types.js';
7
+ import { QuerySnapshot } from './query-snapshot.js';
7
8
  export const STATISTICS_CONFIG_FILE = 'stats-config.json';
8
9
  export const STATISTICS_KEY_FILE = 'stats-key';
9
10
  export const STATISTICS_DATABASE_FILE = 'stats.sqlite';
@@ -147,6 +148,19 @@ function connection(options, write) {
147
148
  throw error;
148
149
  }
149
150
  }
151
+ /** Explicit enable-time initialization only; read queries and observers retain their own paths. */
152
+ export function initializeStatisticsStore(options) {
153
+ const path = join(options.stateDirectory, STATISTICS_DATABASE_FILE);
154
+ assertPrivateStatePath(path);
155
+ checkSidecars(path);
156
+ if (!existsSync(path))
157
+ initialize(path);
158
+ // Validate an existing store without replacing it or opening a write transaction.
159
+ const db = connection(options, false);
160
+ if (!db)
161
+ throw new Error('statistics_database_invalid');
162
+ db.close();
163
+ }
150
164
  function rows(db, table) {
151
165
  return db.prepare(`SELECT * FROM ${table} ORDER BY created,id`).all().map(row => ({ ...row, data: JSON.parse(String(row.data)) }));
152
166
  }
@@ -356,21 +370,70 @@ function modelState(d, c, ambiguous, created, now) {
356
370
  return 'unknown';
357
371
  return expected === actual ? 'model_match' : 'model_mismatch';
358
372
  }
359
- export function readStatistics(options, filter = {}) {
373
+ function readStatisticsInternal(options, filter, snapshot, configurationExpected = false) {
360
374
  const now = (options.now ?? Date.now)();
361
375
  const output = { status: 'ok', scope: 'retained_records', semantics: 'retained_routing_records_not_user_acceptance_or_execution_total', observation_completeness: 'best_effort_not_full_execution_history', today_basis: 'UTC_binding_creation', filter: { client: filter.client ?? 'all', today: filter.today === true },
362
376
  collection: { codex: false, claude: false }, capacity: { delegations: limit(options.maxDelegations), children: limit(options.maxChildren), reached: false },
363
377
  delegations: 0, auto: emptyCounts(), advisory: emptyCounts(), blocked: 0, explicit_preserved: 0, unbound: 0,
364
378
  effort_actual_unknown: 0, application_confirmed: 0, unknown_alias_count: 0, model_observed: 0, model_comparable: 0, model_match_denominator: 0, observation_denominator: 0,
365
379
  usage_scope: 'not_collected', model_alias_scope: 'exact_canonical_model_ids_only', counts_are_lifetime: false };
366
- const config = loadStatisticsConfig(options);
380
+ let failed = false;
381
+ let config = null;
382
+ let configAbsent = false;
383
+ if (snapshot) {
384
+ try {
385
+ const bytes = snapshot.read(join(options.stateDirectory, STATISTICS_CONFIG_FILE), { privateFile: true, maxBytes: 8192, singleLink: true });
386
+ if (bytes === null)
387
+ configAbsent = true;
388
+ else {
389
+ config = parseStatisticsConfig(JSON.parse(bytes.toString('utf8')));
390
+ if (!config)
391
+ failed = true;
392
+ }
393
+ }
394
+ catch {
395
+ failed = true;
396
+ }
397
+ }
398
+ else
399
+ config = loadStatisticsConfig(options);
367
400
  for (const client of config?.enabled_clients ?? [])
368
401
  output.collection[client] = true;
402
+ if (snapshot && configAbsent && configurationExpected)
403
+ failed = true;
404
+ if (snapshot && configAbsent)
405
+ try {
406
+ if (snapshot.track(join(options.stateDirectory, STATISTICS_KEY_FILE), { privateFile: true, singleLink: true, identityOnly: true }))
407
+ failed = true;
408
+ }
409
+ catch {
410
+ failed = true;
411
+ }
412
+ const collectionExpected = !!config?.enabled_clients.some(client => !filter.client || filter.client === 'all' || filter.client === client);
369
413
  let db = null;
370
414
  try {
415
+ if (snapshot) {
416
+ let present;
417
+ try {
418
+ present = snapshot.track(join(options.stateDirectory, STATISTICS_DATABASE_FILE), { privateFile: true, singleLink: true, identityOnly: true });
419
+ }
420
+ catch {
421
+ failed = true;
422
+ }
423
+ if (present === false) {
424
+ if (collectionExpected)
425
+ failed = true;
426
+ return { result: output, failed };
427
+ }
428
+ if (present && configAbsent)
429
+ failed = true;
430
+ }
371
431
  db = connection(options, false);
372
- if (!db)
373
- return output;
432
+ if (!db) {
433
+ if (snapshot && collectionExpected)
434
+ failed = true;
435
+ return { result: output, failed };
436
+ }
374
437
  // All projection inputs must come from one SQLite snapshot. Separate implicit
375
438
  // SELECT transactions can otherwise combine old bindings with new child facts.
376
439
  db.exec('BEGIN');
@@ -453,11 +516,11 @@ export function readStatistics(options, filter = {}) {
453
516
  }
454
517
  }
455
518
  }
456
- return output;
519
+ return { result: output, failed };
457
520
  }
458
521
  catch {
459
522
  output.status = 'unavailable';
460
- return output;
523
+ return { result: output, failed: true };
461
524
  }
462
525
  finally {
463
526
  try {
@@ -470,3 +533,21 @@ export function readStatistics(options, filter = {}) {
470
533
  catch { }
471
534
  }
472
535
  }
536
+ /** Existing best-effort projection, including its historical status semantics. */
537
+ export function readStatistics(options, filter = {}) {
538
+ return readStatisticsInternal(options, filter).result;
539
+ }
540
+ /** Read the same projection while reporting query failures separately. */
541
+ export function readStatisticsQuery(options, filter = {}, snapshot, configurationExpected = false) {
542
+ const owned = snapshot === undefined;
543
+ const view = snapshot ?? new QuerySnapshot();
544
+ const outcome = readStatisticsInternal(options, filter, view, configurationExpected);
545
+ if (owned)
546
+ try {
547
+ view.verify();
548
+ }
549
+ catch {
550
+ outcome.failed = true;
551
+ }
552
+ return outcome;
553
+ }
@@ -1 +1 @@
1
- export declare const VERSION = "0.1.12";
1
+ export declare const VERSION = "0.1.13";
@@ -1 +1 @@
1
- export const VERSION = '0.1.12';
1
+ export const VERSION = '0.1.13';
@@ -185,6 +185,12 @@ The current automatic Hook has no field for passing a URL separately as plaintex
185
185
 
186
186
  ## Diagnostics and development
187
187
 
188
+ `aptly doctor [--client codex|claude|all]` reads local registration, policy, registered package versions and ledger metadata using a separate JSON schema (`kind: aptly-doctor`, `schema_version: 1`). `complete`/exit 0 means the query completed; `partial`/exit 1 means an observation failed. Neither certifies host readiness. Connected MCP version, Hook trust/execution, restart need and ticket usage remain `unknown` locally. It never executes registered launchers, queries credential stores, calls APIs/networks, creates/modifies state or shows update notifications.
189
+
190
+ The ledger size is checked first through a safe path. At most 4 MiB is validated using the existing storage schema before reporting `total`, `complete` and `unknown` counts. Larger files return `scan_skipped_size_limit` without reading the body. A missing first-use ledger means unobserved history, not zero records. Changes during observation discard counts with `changed_during_observation`. Diagnostic timing includes validation/rechecks; write timing is `not_measured`. Output excludes keys, paths, environment values, request IDs and task bodies. Only numeric release versions are shown; arbitrary version suffixes produce `unsupported_version_metadata`.
191
+
192
+ The connected MCP's `get_routing_capabilities.runtime_diagnostics` adds the responding process version, policy source kind and process-local recovery slot `capacity`, `used`, `remaining`, `expired_retained` and `in_flight`. Expired tickets still occupy slots. Observation neither renews/prunes tickets nor checks retry eligibility (`retry_eligibility: not_checked`). Existing `credential_status` is a startup snapshot. Matching versions prove neither settings reload nor that all writers stopped. Strict MCP consumers must allow this additive object. The existing `aptly report` schema and file exports remain unchanged.
193
+
188
194
  ```sh
189
195
  aptly report --format both --output-dir reports
190
196
  ```
@@ -32,7 +32,7 @@ Claude Code stores Hooks in `~/.claude/settings.json` by default, or `$CLAUDE_CO
32
32
 
33
33
  ## Configure with the CLI
34
34
 
35
- In unreleased source, the first normal interactive `aptly set default` groups pending transmission reviews by client home. The recommendation is `excerpt`; Enter preserves an existing scope or selects `none` if unselected. See [transmission review](transmission.md#guide-transmission-scope). This review is not in published 0.1.10.
35
+ From 0.1.11, the first normal interactive `aptly set default` groups pending transmission reviews by client home. The recommendation is `excerpt`; Enter preserves an existing scope or selects `none` if unselected. See [transmission review](transmission.md#guide-transmission-scope). This review flow is not supported in 0.1.10, so update first.
36
36
 
37
37
  The `set` commands require 0.1.1 or later. Commands do not automatically switch existing launch paths. API-key setup accepts only the current package’s standard Node/server registration with a verified OS-source-compatible runtime. Custom wrappers, older versions, and other installation prefixes are rejected with `credential_launcher_unverified`; explicitly switch the registration or upgrade it before trying again.
38
38
 
@@ -97,6 +97,8 @@ MCP `env` values are strings, so candidate arrays must also be passed as JSON st
97
97
 
98
98
  When unset, the defaults above apply; `[]` disables recommendations for that client. Empty strings, duplicates, unsupported models, and malformed JSON are errors. `CLAUDE_MODELS` and `CODEX_MODELS` are supported aliases, but setting both the primary name and its alias for the same provider is an error. Candidate configuration does not override existing choices or certify model access for an account.
99
99
 
100
+ `aptly set default` preserves candidates and aliases already in MCP `env`, Codex `env_vars` declarations, and inherited candidates visible to the current CLI for Claude. It adds default candidates only for a model family with neither name configured. A Codex passthrough is preserved even when its value is unavailable in the current terminal; inherited values are not copied into configuration files. The CLI gives a static `env` value precedence over an inherited value with the same name when validating effective settings. Catalog validation remains in place, so conflicting aliases or malformed values reject the configuration change. Check the final candidates in the restarted MCP separately.
101
+
100
102
  ## Related topics
101
103
 
102
104
  [Installation and updates](installation.md) · [Automatic recommendations](routing.md) · [Decisions API transmission](transmission.md) · [Advanced MCP integration and development](advanced.md) · [Troubleshooting](troubleshooting.md)
@@ -48,11 +48,11 @@ npm install -g aptly@latest --ignore-scripts
48
48
  aptly setup --client all
49
49
  ```
50
50
 
51
- In unreleased source, npm lifecycle installation does not ask for transmission review. After upgrading to a release containing the feature, run interactive `aptly setup`, `aptly set default`, or `aptly set transmission --review` with the same account environment. The 0.1.10 updater cannot ask the new question during that update; see [transmission review](transmission.md#guide-transmission-scope).
51
+ Transmission review is available from 0.1.11 and does not prompt during npm lifecycle installation. When upgrading from 0.1.10, update the package first, then run interactive `aptly setup`, `aptly set default`, or `aptly set transmission --review` with the same account environment. The update process does not perform the new review or imply consent; see [transmission review](transmission.md#guide-transmission-scope).
52
52
 
53
53
  Explicit `setup` works regardless of lifecycle execution. It preserves existing launchers; use the [launcher recovery steps](troubleshooting.md#guide-launcher-recovery) for stale paths. Key setup, MCP restart, and Codex `/hooks` trust review remain separate steps.
54
54
 
55
- The unreleased installer writes only a stderr instruction to run `aptly set transmission --review` when registrations need review; it does not ask a question or record a choice.
55
+ The 0.1.11 or later installer writes only a stderr instruction to run `aptly set transmission --review` when setup completes successfully and registered clients have reviews pending; it does not ask a question or record a choice.
56
56
 
57
57
  <a id="guide-package-updates"></a>
58
58
 
@@ -22,8 +22,12 @@ aptly stats enable --client codex --codex-native-metadata
22
22
  aptly stats disable --client codex
23
23
  ```
24
24
 
25
+ The top-level `status` in `aptly stats` reads, including `--today`, is `complete` (exit 0) when the query completes and `partial` (exit 1) for unsupported statistics requests or corrupt, read, or store errors. Disabled collection and genuinely unconfigured clients are completed queries. Successful client results remain available when another client fails. Existing client JSON fields and values are retained; strict full-object consumers must accept the additive `status`. `complete` does not certify host routing, model, or trust readiness. Unexpected statistics failures report `statistics_failed`; raw paths, input, keys, and stacks are not printed. Reads do not repair setup, obtain consent, or call a provider.
26
+
25
27
  The command forms are `aptly stats [--today] [--client codex|claude|all]`, `aptly stats enable [--client] [--codex-native-metadata]` and `aptly stats disable [--client]`. Collection is off by default and postinstall does not enable it. Enable installs Aptly-owned command observers recorded separately in `stats-ownership.json`; it leaves the legacy receipt, MCP, launchers, keys, budget and transmission settings intact. Restart MCP and the host after enabling; for Codex, review native Hook trust in `/hooks`.
26
28
 
29
+ `stats enable` initializes an empty statistics database before the first event and validates existing stores without replacing them. Initialization failure returns `partial` with `statistics_store_initialization_failed`; applied registration may remain. If an older version enabled collection but no event has created its database, rerun `stats enable`. Queries never create or repair the database.
30
+
27
31
  Disable turns collection off and removes only unchanged owned observers. Modified or custom observers are preserved with a warning; data and the key remain. `remove` validates and removes stats-owned definitions but keeps the data. Independently managed collectors and custom Hooks are not adopted automatically.
28
32
 
29
33
  Private state uses `stats.sqlite`, `stats-config.json` and `stats-key` (an HMAC secret), separately from the budget ledger. Do not share the key. Records contain no task text, transcripts, raw IDs, paths, errors or credentials. Reading stats makes no API, key or credential-store calls, initializes nothing and runs no notifier.
@@ -4,7 +4,7 @@
4
4
 
5
5
  [Guide home](../en.md)
6
6
 
7
- The transmission review described below is an **unreleased source feature**; it is not included in the published Aptly 0.1.10 package.
7
+ The transmission review and `--review` command described below are **available from Aptly 0.1.11**. If you use 0.1.10, update the package first.
8
8
 
9
9
  ## On this page
10
10
 
@@ -19,11 +19,11 @@ The transmission commands in this section are supported from Aptly 0.1.7.
19
19
 
20
20
  Transmission means **sending local task information to the OpenAI Decisions API**, not providing tasks to Aptly developers. Application mode `defaults/advisory` and transmission scope are independent. New registrations use v2 policy with `unselected` scope and make no automatic transmission.
21
21
 
22
- In published 0.1.10, interactive `aptly set default` asks only for unselected hosts; Enter selects `none`. Noninteractive runs and postinstall do not prompt or imply consent.
22
+ For upgrades from 0.1.10: in that version, interactive `aptly set default` asks only for unselected hosts; Enter selects `none`. Noninteractive runs and postinstall do not prompt or imply consent.
23
23
 
24
- In the unreleased source, the first normal interactive `aptly setup` or `aptly set default` presents one grouped review for clients awaiting review, showing each current value, provenance, and default or overridden home. `excerpt` is recommended as option 3. Enter or keep preserves an existing explicit or legacy scope, including `none`; an unselected scope becomes `none`. Explicit `setup --transmission` or `set transmission <scope>` records the actual choice as reviewed. A private revision 1 marker is stored per client home, independent of package version, mode, and statistics, so ordinary patch updates and restarts do not repeat the review.
24
+ From 0.1.11, the first normal interactive `aptly setup` or `aptly set default` presents one grouped review for clients awaiting review, showing each current value, provenance, and default or overridden home. `excerpt` is recommended as option 3. Enter or keep preserves an existing explicit or legacy scope, including `none`; an unselected scope becomes `none`. Explicit `setup --transmission` or `set transmission <scope>` records the actual choice as reviewed. A private revision 1 marker is stored per client home, independent of package version, mode, and statistics, so ordinary patch updates and restarts do not repeat the review.
25
25
 
26
- The new command below always asks again by explicit request; it is not available in published 0.1.10:
26
+ The command below is supported from 0.1.11 and always asks again by explicit request. If you use 0.1.10, update first:
27
27
 
28
28
  ```sh
29
29
  aptly set transmission --review
@@ -31,7 +31,7 @@ aptly set transmission --review
31
31
 
32
32
  Canceling leaves scopes and review markers unchanged; normal setup or default configuration may already have applied non-transmission defaults. Automatic setup, check, migrate, explicit-transmission setup, CI, non-TTY execution, skipped setup, npm lifecycle scripts, MCP, Hooks, help, show, and statistics reads do not prompt. Prompts use stderr and leave JSON stdout clean. Existing disabled policies, modes, launchers, keys, ledgers, statistics, and trust settings are preserved.
33
33
 
34
- The 0.1.10 update process cannot load the new question immediately. For the first rollout, run interactive `aptly setup`, `aptly set default`, or `aptly set transmission --review` after upgrading to a release that contains it. Future updates containing this feature print the next step without spawning a new process.
34
+ The 0.1.10 update process cannot immediately load the updated CLI’s new question. After updating to 0.1.11 or later, run interactive `aptly setup`, `aptly set default`, or `aptly set transmission --review` with the same account environment. `aptly update` in 0.1.11 or later also prints the next setup command without spawning a new process.
35
35
 
36
36
  ```sh
37
37
  aptly set transmission --show
@@ -40,6 +40,8 @@ aptly set transmission description
40
40
  aptly set transmission excerpt
41
41
  ```
42
42
 
43
+ The top-level `status` in `--show` is `complete` (exit 0) when the query completes and `partial` (exit 1) for incomplete expected setup or corrupt or unreadable state. `none`, `unselected`, and genuinely unconfigured clients, including manual direct-only MCP without an expected automatic policy, are completed queries. Successful client results remain available when another client fails. Existing client JSON fields and values are retained; strict full-object consumers must accept the additive `status`. Some legacy client statuses conflate unconfigured and error states, so the aggregate also reflects checked query health. `complete` does not certify host routing, model, or trust readiness. Reads do not repair setup, obtain consent, or call a provider, and do not print raw paths, input, keys, or stacks.
44
+
43
45
  The change commands above show alternatives; run only the one you want. Use `--client codex|claude|all` to select hosts. `none` disables automatic transmission and preserves the original call. `description` permits only a parent-supplied description. Without one, it requests context before calling the API and never falls back to native body or label. `defaults` denies the unresolved spawn; `advisory` supplies feedback only. `excerpt` permits existing native excerpts and explicit descriptions. Source, size and known-secret checks establish neither non-sensitive content nor user consent.
44
46
 
45
47
  Existing v1 policies remain byte-identical and report `excerpt` with `legacy` provenance. An explicit change migrates the policy to v2 and updates its ownership receipt together. Modified policies and custom launchers are not silently adopted; conflicts preserve them. Keys, ledgers and unknown records are not deleted. Restart MCP after changes. Already-started transmission cannot be recalled; changed policy prevents in-flight results, retry and fresh preparation from applying. Do not bypass an old call-binding conflict with a new paid identity. Explicit `recommend_agent` and `aptly recommend` requests remain separate and are not prohibited by this automatic-transmission setting.
@@ -31,7 +31,7 @@ After the setup check succeeds, follow [statistics activation](statistics.md). `
31
31
 
32
32
  ### Policy paths revert in managed accounts
33
33
 
34
- Planned for 0.1.11. A manager such as Orca can mirror a same-name MCP registration from the canonical home and overwrite an account-only absolute policy path. Hooks can remain intact while MCP and statistics reference different policies.
34
+ This policy-source migration is available from 0.1.11. A manager such as Orca can mirror a same-name MCP registration from the canonical home and overwrite an account-only absolute policy path. Hooks can remain intact while MCP and statistics reference different policies.
35
35
 
36
36
  Upgrade every registered Aptly backend first and stop the affected hosts/MCP processes. For an existing Codex setup with intact ownership, explicitly migrate the canonical/default registration first, then repeat in each intended account environment with its selected `CODEX_HOME`. An account-only edit can still be overwritten by synchronization.
37
37
 
@@ -42,7 +42,7 @@ CODEX_HOME="$HOME/.codex" aptly setup --check --client codex
42
42
  CODEX_HOME="$HOME/.codex" aptly stats --client codex
43
43
  ```
44
44
 
45
- Migration registers `APTLY_HOOK_POLICY_PATH = "@codex-home"` and forwards `CODEX_HOME` through `env_vars`. At startup, the server selects that home's `aptly/auto-policy.json`. Missing, empty or relative values are rejected without selecting another home. MCP startup still requires an explicit forwarded home, including `CODEX_HOME="$HOME/.codex"` for the default home. If the 0.1.11 CLI reports `policy_source_home_invalid` in an ordinary terminal without the variable, use the explicit default home as above. The 0.1.12 CLI fix validates its already selected standard `~/.codex` when the variable is absent; explicit account selection and invalid-value rejection remain intact. The example uses the default home; substitute the intended absolute account home for account-specific commands. This is an operator-declared source selection, not complete host provenance. See [Codex MCP environment forwarding](https://learn.chatgpt.com/docs/extend/mcp#stdio-servers).
45
+ Migration registers `APTLY_HOOK_POLICY_PATH = "@codex-home"` and forwards `CODEX_HOME` through `env_vars`. At startup, the server selects that home's `aptly/auto-policy.json`. Missing, empty or relative values are rejected without selecting another home. MCP startup still requires an explicit forwarded home, including `CODEX_HOME="$HOME/.codex"` for the default home. If the 0.1.11 CLI reports `policy_source_home_invalid` in an ordinary terminal without the variable, use the explicit default home as above. From 0.1.12, the CLI validates its already selected standard `~/.codex` when the variable is absent. CLI default-home selection is separate from environment forwarding at MCP startup; explicit account selection and invalid-value rejection remain intact. The example uses the default home; substitute the intended absolute account home for account-specific commands. This is an operator-declared source selection, not complete host provenance. See [Codex MCP environment forwarding](https://learn.chatgpt.com/docs/extend/mcp#stdio-servers).
46
46
 
47
47
  Migration does not move or reset policy contents, transmission consent, ledger paths, statistics history or Hook trust. Existing fixed/shared policies remain fixed unless explicitly migrated. Custom launchers, unrelated registration changes and ownership mismatches require local review; do not edit or copy receipts to bypass errors. Restart the server and check again in the intended account. A successful dry-run or file check does not prove the running MCP updated or a model was observed.
48
48
 
@@ -84,6 +84,8 @@ A successful Codex configuration needs no reset. Retry only the affected host an
84
84
 
85
85
  ## Interrupted processes and ledger locks
86
86
 
87
+ Ledger PREFLIGHT reads do not change file permissions or contents. On POSIX, owner-only permissions such as `0600` and `0400` are accepted; `0644` or an incorrect owner is refused through existing failure paths (for example, `ledger_error`), without automatic `chmod` or retry. Before explicitly repairing permissions, confirm the exact intended local file and its owner, and stop relevant writers. Never delete or reset the ledger, `unknown` records, reservations, cache, locks, or journals as a fix. Subsequent legitimate writes still occur under the existing writer lock and may normalize permissions to `0600`. Windows ownership and private-access guards remain unchanged; POSIX mode bits do not guarantee Windows ACLs.
88
+
87
89
  This locking design requires Aptly `0.1.2` or later and is not included in npm `0.1.1`. The JSON ledger keeps its request IDs, `unknown` records, completed cache, call counts, and reserved costs. Only persistent ledgers use Node.js 24's built-in SQLite. The adjacent `ledger.json.lock` remains after a normal exit; its presence alone does not mean an active lock. With the new design, process exit releases the OS lock so a later request can use the same ledger. It does not retry an existing uncertain ID or refund reserved costs.
88
90
 
89
91
  Keep the ledger and lock in a private directory on a local filesystem that supports hard links, and use one canonical path for each ledger. Network shares, cloud-synced directories, and path aliases are outside the supported scope. Do not delete or replace the new lock or SQLite journal, or open them with another database tool while in use. Age and PID alone do not establish that an owner has exited.
package/docs/guide/en.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Aptly user guide
2
2
 
3
+ This guide targets Aptly 0.1.13. Each topic preserves feature-specific minimum versions and recovery instructions for older releases.
4
+
3
5
  [한국어](ko.md) · **English** · [简体中文](zh-CN.md) · [日本語](ja.md)
4
6
 
5
7
  [Back to README](../../README.en.md)
@@ -185,6 +185,12 @@ Codex が子エージェントの `message` を暗号文として Hook に渡す
185
185
 
186
186
  ## 診断と開発
187
187
 
188
+ `aptly doctor [--client codex|claude|all]` は独立した JSON スキーマ(`kind: aptly-doctor`、`schema_version: 1`)でローカル登録、ポリシー、登録先パッケージのバージョン、台帳メタデータを読み取ります。`complete`/終了コード 0 は照会完了、`partial`/終了コード 1 は観測失敗を示し、ホストの動作を保証しません。接続中の MCP バージョン、Hook の信頼・実行、再起動の必要性、チケット使用量はローカルでは `unknown` です。登録ランチャーの実行、資格情報ストアの照会、API・ネットワーク呼び出し、状態の作成・変更、更新通知は行いません。
189
+
190
+ 安全なパスから台帳サイズを先に確認し、4 MiB 以下のみ既存の保存スキーマで検証して `total`・`complete`・`unknown` 件数を表示します。超過時は本文を読まず `scan_skipped_size_limit` を返します。初回使用で台帳がない場合、履歴は未観測であり 0 件とは断定しません。観測中の変更では `changed_during_observation` として集計を破棄します。診断時間には検証と再確認を含み、書き込み時間は `not_measured` です。キー・パス・環境値・リクエスト ID・タスク本文は出力しません。数字のみのリリース版を表示し、任意のバージョン接尾辞は `unsupported_version_metadata` とします。
191
+
192
+ 接続中の MCP の `get_routing_capabilities.runtime_diagnostics` は応答プロセスのバージョン、ポリシーソースの種類、プロセス内の復旧スロット数 `capacity`・`used`・`remaining`・`expired_retained`・`in_flight` を追加します。期限切れのチケットもスロットを占有し、照会は更新・削除や再試行資格の確認を行いません(`retry_eligibility: not_checked`)。既存の `credential_status` は起動時のスナップショットです。同じバージョンでも設定の再読み込みや全書き込みプロセスの停止は証明できません。厳格な MCP 消費側はこの追加オブジェクトを許容してください。既存の `aptly report` スキーマとファイル出力は維持します。
193
+
188
194
  ```sh
189
195
  aptly report --format both --output-dir reports
190
196
  ```
@@ -32,7 +32,7 @@ Claude Code の Hook ファイルは通常 `~/.claude/settings.json` ですが
32
32
 
33
33
  ## CLI による設定
34
34
 
35
- 未リリースのソースでは、最初の通常の対話形式 `aptly set default` がクライアントホームごとのレビュー待ち項目をまとめて質問します。`excerpt` を推奨し、Enter は既存の範囲を保持するか、未選択なら `none` を選びます。[送信レビュー](transmission.md#guide-transmission-scope)を参照してください。このレビューは公開済み 0.1.10 にはありません。
35
+ 0.1.11 以降、最初の通常の対話形式 `aptly set default` がクライアントホームごとのレビュー待ち項目をまとめて質問します。`excerpt` を推奨し、Enter は既存の範囲を保持するか、未選択なら `none` を選びます。[送信レビュー](transmission.md#guide-transmission-scope)を参照してください。この再レビューの流れは 0.1.10 ではサポートされないため、先に更新してください。
36
36
 
37
37
  `set` コマンドは 0.1.1 以降で利用できます。既存の起動パスは自動で切り替えません。API キー設定は、現在のパッケージの標準 Node/サーバー登録で、OS 資格情報の参照に対応する実行環境だと確認できた場合にのみ使用できます。独自ラッパー、旧バージョン、別のインストール先は `credential_launcher_unverified` で拒否します。登録を明示的に切り替えるかアップグレードしてから、再度実行してください。
38
38
 
@@ -97,6 +97,8 @@ MCP の `env` の値は文字列なので、候補配列も JSON 文字列とし
97
97
 
98
98
  未指定の場合は上記のデフォルト値を使い、`[]` の場合はその client の推薦を無効にします。空の文字列・重複・未対応のモデル・不正な JSON はエラーです。`CLAUDE_MODELS`・`CODEX_MODELS` も別名として利用できますが、同じプロバイダーの標準名と別名を同時に設定するとエラーになります。候補設定は、既存の選択を上書きしたり、アカウントのモデルへのアクセス権限を認証したりするものではありません。
99
99
 
100
+ `aptly set default` は、MCP `env` の既存候補と別名、Codex `env_vars` の転送宣言、および現在の CLI で確認できる Claude の継承候補を保持します。同じモデル系列の両方の変数名が未設定の場合だけ既定候補を追加します。Codex の転送変数は現在の端末で値を確認できなくても既定値に置き換えず、継承値を設定ファイルにコピーしません。CLI は同名の静的な `env` 値を優先して有効な設定を検証します。カタログの検証は維持されるため、別名の競合や不正な値があれば設定変更を拒否します。再起動した MCP の最終候補は別途確認してください。
101
+
100
102
  ## 関連文書
101
103
 
102
104
  [インストールと更新](installation.md) · [自動推薦](routing.md) · [Decisions API の送信範囲](transmission.md) · [高度な MCP 連携と開発参考](advanced.md) · [トラブルシューティング](troubleshooting.md)
@@ -48,11 +48,11 @@ npm install -g aptly@latest --ignore-scripts
48
48
  aptly setup --client all
49
49
  ```
50
50
 
51
- 未リリースのソースでも npm lifecycle インストールは送信レビューを質問しません。機能を含むリリースへ更新後、同じアカウント環境で対話形式の `aptly setup`、`aptly set default` または `aptly set transmission --review` を実行してください。0.1.10 の更新プロセスは更新中に新しい質問をできません。[送信レビュー](transmission.md#guide-transmission-scope)を参照してください。
51
+ 送信レビューは 0.1.11 以降で提供され、npm lifecycle インストールでは質問しません。0.1.10 からアップグレードする場合は、先にパッケージを更新し、同じアカウント環境で対話形式の `aptly setup`、`aptly set default` または `aptly set transmission --review` を実行してください。更新プロセスが新しいレビューを代行したり、同意したものとして扱ったりすることはありません。[送信レビュー](transmission.md#guide-transmission-scope)を参照してください。
52
52
 
53
53
  スクリプトの実行にかかわらず、明示的な `setup` を利用できます。既存の起動パスは保持するため、旧パスのエラーは[実行パスの復旧手順](troubleshooting.md#guide-launcher-recovery)に従ってください。キー設定・MCP の再起動と Codex の `/hooks` 信頼確認は別途必要です。
54
54
 
55
- 未リリースのインストールスクリプトは、確認待ちの登録がある場合に `aptly set transmission --review` の実行案内だけを stderr に表示し、質問や選択の記録は行いません。
55
+ 0.1.11 以降のインストールスクリプトは、設定が正常に完了し、登録済みクライアントにレビュー待ちがある場合に `aptly set transmission --review` の実行案内だけを stderr に表示し、質問や選択の記録は行いません。
56
56
 
57
57
  <a id="guide-package-updates"></a>
58
58
 
@@ -22,8 +22,12 @@ aptly stats enable --client codex --codex-native-metadata
22
22
  aptly stats disable --client codex
23
23
  ```
24
24
 
25
+ `aptly stats` の読み取り(`--today` を含む)のトップレベル `status` は、照会が完了すると `complete`(終了コード 0)、未対応の統計要求や破損・読み取り・ストアのエラーがあると `partial`(終了コード 1)です。収集が無効な場合や実際に未設定のクライアントも照会完了です。一部のクライアントが失敗しても成功した結果は保持します。既存のクライアント JSON フィールドと値は維持するため、オブジェクト全体を厳密に検査する利用側は追加された `status` を受け入れてください。`complete` はホストのルーティング・モデル・信頼の準備を保証しません。予期しない統計エラーは `statistics_failed` で報告し、生のパス・入力・キー・スタックは出力しません。読み取りは自動修復・同意取得・プロバイダー呼び出しを行いません。
26
+
25
27
  形式は `aptly stats [--today] [--client codex|claude|all]`、`aptly stats enable [--client] [--codex-native-metadata]`、`aptly stats disable [--client]` です。収集は既定で無効で、postinstall でも自動有効化しません。enable は Aptly 所有のコマンド観測器を設置し、別の `stats-ownership.json` に記録します。既存の receipt・MCP・launcher・キー・予算・送信設定は保持します。有効化後は MCP とホストを再起動し、Codex では `/hooks` で native Hook の信頼を確認してください。
26
28
 
29
+ `stats enable` は最初のイベント前に空の統計 DB を初期化し、既存 DB は検証して保持します。初期化に失敗すると `partial` と `statistics_store_initialization_failed` を返し、適用済みの登録設定が残る場合があります。旧バージョンで有効化後、イベントがなく DB が未作成の場合は `stats enable` を再実行してください。照会は DB の作成や修復を行いません。
30
+
27
31
  disable は収集を無効にし、変更されていない所有観測器だけを削除します。変更済みやカスタムの観測器は警告して保持し、データとキーも残します。`remove` は統計所有の定義を検証・削除しますが、データは保持します。個別に管理される収集器やカスタム Hook は自動的に取り込みません。
28
32
 
29
33
  非公開の状態は予算台帳とは別の `stats.sqlite`、`stats-config.json`、`stats-key`(HMAC 秘密鍵)を使用します。鍵を共有しないでください。記録にタスク原文・会話記録・生 ID・パス・エラー・資格情報は含まれません。統計の読み取りは API・キー・資格情報ストアにアクセスせず、初期化や通知も行いません。
@@ -4,7 +4,7 @@
4
4
 
5
5
  [ガイド目次](../ja.md)
6
6
 
7
- 以下の送信レビューは**未リリースのソース機能**で、公開済みの Aptly 0.1.10 パッケージには含まれません。
7
+ 以下の送信レビューと `--review` コマンドは **Aptly 0.1.11 以降で提供されます**。0.1.10 を使用している場合は、先にパッケージを更新してください。
8
8
 
9
9
  ## このページの目次
10
10
 
@@ -19,11 +19,11 @@
19
19
 
20
20
  ここでの送信は、**ローカルのタスク情報を OpenAI Decisions API に送ること**であり、Aptly の開発者にタスクを提供する機能ではありません。適用モード `defaults/advisory` と送信範囲は別の設定です。新規登録は v2 ポリシーの `unselected` となり、自動送信しません。
21
21
 
22
- 公開済み 0.1.10 の対話形式 `aptly set default` は未選択のホストだけに質問し、Enter で `none` を選びます。非対話実行と postinstall は質問せず、同意したものとして扱いません。
22
+ 0.1.10 からアップグレードする際の参考: このバージョンの対話形式 `aptly set default` は未選択のホストだけに質問し、Enter で `none` を選びます。非対話実行と postinstall は質問せず、同意したものとして扱いません。
23
23
 
24
- 未リリースのソースでは、最初の通常の対話形式 `aptly setup` または `aptly set default` で、レビュー待ちのクライアントをまとめて一度に質問し、各現在値・出所・既定または上書きされたホームを表示します。推奨は選択肢 3 の `excerpt` です。Enter または維持を選ぶと既存の明示的な範囲・legacy 範囲と `none` を保持し、未選択の場合は `none` になります。明示的な `setup --transmission` または `set transmission <scope>` は実際の選択をレビュー済みとして記録します。クライアントホームごとの非公開 revision 1 マーカーはパッケージバージョン・モード・統計とは独立しており、通常のパッチ更新や再起動では再質問しません。
24
+ 0.1.11 以降、最初の通常の対話形式 `aptly setup` または `aptly set default` で、レビュー待ちのクライアントをまとめて一度に質問し、各現在値・出所・既定または上書きされたホームを表示します。推奨は選択肢 3 の `excerpt` です。Enter または維持を選ぶと既存の明示的な範囲・legacy 範囲と `none` を保持し、未選択の場合は `none` になります。明示的な `setup --transmission` または `set transmission <scope>` は実際の選択をレビュー済みとして記録します。クライアントホームごとの非公開 revision 1 マーカーはパッケージバージョン・モード・統計とは独立しており、通常のパッチ更新や再起動では再質問しません。
25
25
 
26
- 以下の新しいコマンドは明示的な要求により毎回質問します。公開済みの 0.1.10 では利用できません:
26
+ 以下のコマンドは 0.1.11 以降でサポートされ、明示的な要求により毎回質問します。0.1.10 では先に更新してください:
27
27
 
28
28
  ```sh
29
29
  aptly set transmission --review
@@ -31,7 +31,7 @@ aptly set transmission --review
31
31
 
32
32
  キャンセルすると範囲とレビューマーカーは変わりません。通常の setup または default では送信以外の既定設定が既に適用されている場合があります。自動 setup、check、migrate、送信範囲を明示した setup、CI、非 TTY、setup のスキップ、npm lifecycle スクリプト、MCP、Hook、help、show、統計の読み取りでは質問しません。質問は stderr に出力し、JSON stdout は維持します。既存の無効化ポリシー・モード・ランチャー・キー・台帳・統計・信頼設定を保持します。
33
33
 
34
- 0.1.10 の更新プロセスは新しい質問を直ちに読み込めません。初回の提供時は機能を含むリリースへ更新後、対話形式の `aptly setup`、`aptly set default` または `aptly set transmission --review` を実行してください。この機能を含む将来の更新は、新しいプロセスを起動せず次の手順を表示します。
34
+ 0.1.10 の更新プロセスは、更新された CLI の新しい質問を直ちに読み込みません。0.1.11 以降に更新した後、同じアカウント環境で対話形式の `aptly setup`、`aptly set default` または `aptly set transmission --review` を実行してください。0.1.11 以降の `aptly update` も新しいプロセスを起動せず、後続の設定コマンドを案内します。
35
35
 
36
36
  ```sh
37
37
  aptly set transmission --show
@@ -40,6 +40,8 @@ aptly set transmission description
40
40
  aptly set transmission excerpt
41
41
  ```
42
42
 
43
+ `--show` 結果のトップレベル `status` は、照会が完了すると `complete`(終了コード 0)、期待される設定が不完全な場合や状態が破損・読み取り不能な場合は `partial`(終了コード 1)です。`none`・`unselected` や実際に未設定のクライアント(自動ポリシーが期待されない手動の直接呼び出し専用 MCP を含む)も照会完了です。一部のクライアントが失敗しても成功した結果は保持します。既存のクライアント JSON フィールドと値は維持するため、オブジェクト全体を厳密に検査する利用側は追加された `status` を受け入れてください。一部の従来のクライアント状態は未設定とエラーを区別しないため、集約状態には確認した照会の健全性も反映します。`complete` はホストのルーティング・モデル・信頼の準備を保証しません。読み取りは自動修復・同意取得・プロバイダー呼び出しを行わず、生のパス・入力・キー・スタックを出力しません。
44
+
43
45
  変更コマンドは選択肢を示しています。希望する一つだけを実行してください。`--client codex|claude|all` で対象を選べます。`none` は自動送信を停止し、元の呼び出しを保持します。`description` は親エージェントが提供した説明だけを許可します。説明がなければ API 呼び出し前に文脈補足を求め、native 本文やラベルには自動で切り替えません。`defaults` は未解決の spawn を拒否し、`advisory` は案内のみを返します。`excerpt` は既存の native 抜粋と明示的な説明を許可します。出所・サイズ・既知の秘密パターンの検査は、非機密性やユーザーの同意を証明しません。
44
46
 
45
47
  既存の v1 ポリシーはバイト単位で保持され、出所 `legacy` の `excerpt` と表示されます。明示的な変更時だけ v2 に移行し、所有権記録も同時に更新します。変更済みポリシーや独自ランチャーを自動で引き継がず、競合時は保持します。キー・台帳・不明な記録は削除しません。変更後は MCP を再起動してください。開始済みの送信は回収できず、ポリシー変更前の処理中結果・retry・fresh 準備は適用されません。既存の結合競合を新しい有料 ID で回避しないでください。明示的な `recommend_agent` と `aptly recommend` は別の要求であり、この自動送信設定では禁止しません。
@@ -31,7 +31,7 @@ aptly stats --client codex
31
31
 
32
32
  ### 管理対象アカウントでポリシーパスが戻る場合
33
33
 
34
- 0.1.11 に含める予定の機能です。Orca などの管理ツールが既定ホームの同名 MCP 登録をアカウントホームに同期すると、アカウントだけで修正した絶対ポリシーパスが上書きされる場合があります。Hook が残っていても MCP と統計が異なるポリシーを参照することがあります。
34
+ 0.1.11 以降で提供されるポリシー参照の移行機能です。Orca などの管理ツールが既定ホームの同名 MCP 登録をアカウントホームに同期すると、アカウントだけで修正した絶対ポリシーパスが上書きされる場合があります。Hook が残っていても MCP と統計が異なるポリシーを参照することがあります。
35
35
 
36
36
  登録済みの Aptly サーバーをすべて更新し、対象ホストと MCP プロセスを停止してください。所有権記録が正常な既存 Codex 設定で、まず既定/正本の登録があるホームを明示的に移行し、その後、対象アカウントの `CODEX_HOME` を選択した各環境で繰り返してください。アカウントファイルだけの変更は同期で戻る可能性があります。
37
37
 
@@ -42,7 +42,7 @@ CODEX_HOME="$HOME/.codex" aptly setup --check --client codex
42
42
  CODEX_HOME="$HOME/.codex" aptly stats --client codex
43
43
  ```
44
44
 
45
- 移行では `APTLY_HOOK_POLICY_PATH = "@codex-home"` と `env_vars` による `CODEX_HOME` の転送を登録します。起動時にそのホームの `aptly/auto-policy.json` を選びます。変数の欠落、空値、相対パスは別のホームに置き換えず拒否します。MCP 起動時には既定ホームでも `CODEX_HOME="$HOME/.codex"` を明示的に転送する必要があります。変数のない通常の端末で 0.1.11 CLI が `policy_source_home_invalid` を返す場合は、上の例のように既定ホームを明示してください。0.1.12 の CLI 修正では変数がない場合、すでに選択した標準の `~/.codex` を検証に使用します。明示的なアカウント選択と無効値の拒否は維持します。例は既定ホーム用です。各アカウントでは対象の絶対ホームパスに置き換えてください。これは運用者が指定した参照元の選択であり、ホスト全体の設定を証明するものではありません。[Codex MCP の環境変数転送](https://learn.chatgpt.com/docs/extend/mcp#stdio-servers)を参照してください。
45
+ 移行では `APTLY_HOOK_POLICY_PATH = "@codex-home"` と `env_vars` による `CODEX_HOME` の転送を登録します。起動時にそのホームの `aptly/auto-policy.json` を選びます。変数の欠落、空値、相対パスは別のホームに置き換えず拒否します。MCP 起動時には既定ホームでも `CODEX_HOME="$HOME/.codex"` を明示的に転送する必要があります。変数のない通常の端末で 0.1.11 CLI が `policy_source_home_invalid` を返す場合は、上の例のように既定ホームを明示してください。0.1.12 以降、CLI は変数がない場合、すでに選択した標準の `~/.codex` を検証に使用します。CLI の既定ホームの選択と MCP 起動時の環境転送は別です。明示的なアカウント選択と無効値の拒否は維持します。例は既定ホーム用です。各アカウントでは対象の絶対ホームパスに置き換えてください。これは運用者が指定した参照元の選択であり、ホスト全体の設定を証明するものではありません。[Codex MCP の環境変数転送](https://learn.chatgpt.com/docs/extend/mcp#stdio-servers)を参照してください。
46
46
 
47
47
  移行はポリシー内容、送信同意、台帳パス、統計履歴、Hook の信頼を移動または初期化しません。既存の固定/共有ポリシーは明示的に移行しなければ維持されます。カスタムランチャー、無関係な登録変更、所有権の不一致はローカルで確認してください。エラーを回避するために記録を編集・コピーしないでください。サーバーを再起動して対象アカウントで再確認してください。プレビューやファイル検査の成功は、稼働中 MCP の更新やモデルの観測を証明しません。
48
48
 
@@ -84,6 +84,8 @@ aptly setup --client claude --migrate-launcher --include-existing
84
84
 
85
85
  ## プロセス中断と台帳ロック
86
86
 
87
+ 台帳の PREFLIGHT 読み取りは、ファイルの権限や内容を変更しません。POSIX では所有者のみがアクセスできる権限(例: `0600`、`0400`)を受け入れ、`0644` や不正な所有者は既存の失敗経路(例: `ledger_error`)で拒否します。自動で `chmod` や再試行はしません。権限を明示的に修復する前に、対象の正確なローカルファイルと所有者を確認し、関連する書き込みプロセスを停止してください。修復のために台帳、`unknown` 記録、予約、キャッシュ、ロック、journal を削除または初期化しないでください。その後の正当な書き込みは引き続き既存の書き込みロックの下で行われ、権限が `0600` に正規化される場合があります。Windows の所有権と非公開アクセスの保護は変わらず、POSIX 権限ビットは Windows ACL を保証しません。
88
+
87
89
  このロック方式は Aptly `0.1.2` 以降で利用でき、npm `0.1.1` には含まれません。JSON 台帳のリクエスト ID・`unknown`・完了済みキャッシュ・呼び出し数・予約費用の形式は維持します。永続台帳だけが Node.js 24 内蔵の SQLite を使用します。隣接する `ledger.json.lock` は正常終了後も残るため、ファイルの存在だけではロックが使用中かどうかを判断できません。新方式ではプロセス終了時に OS のロックが解放され、後続のリクエストが同じ台帳を使用できます。結果が不明な既存 ID の再試行や予約費用の返却は行いません。
88
90
 
89
91
  台帳とロックは、ハードリンクに対応したローカルファイルシステムの非公開ディレクトリに置き、各台帳に同一の正規パスを使用してください。ネットワーク共有・クラウド同期ディレクトリ・パスの別名はサポート範囲外です。新しいロックや SQLite journal を削除・置換したり、使用中に他の DB ツールで開いたりしないでください。ファイルの古さや PID だけでは所有プロセスの終了を確認できません。
package/docs/guide/ja.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Aptly 使用ガイド
2
2
 
3
+ このガイドは Aptly 0.1.13 を対象としています。機能ごとの最小バージョンと旧バージョンの復旧手順は各文書で区別します。
4
+
3
5
  [한국어](ko.md) · [English](en.md) · [简体中文](zh-CN.md) · **日本語**
4
6
 
5
7
  [README に戻る](../../README.ja.md)
@@ -185,6 +185,12 @@ Codex가 자식 `message`를 암호문으로 Hook에 전달하는 환경에서
185
185
 
186
186
  ## 진단과 개발
187
187
 
188
+ `aptly doctor [--client codex|claude|all]`은 별도 JSON 스키마(`kind: aptly-doctor`, `schema_version: 1`)로 로컬 등록·정책·등록 대상 패키지 버전과 원장 메타데이터를 조회합니다. `complete`/종료 코드 0은 조회 완료를, `partial`/종료 코드 1은 관측 실패를 뜻하며 호스트의 정상 작동을 보증하지 않습니다. 연결된 MCP 버전, Hook 신뢰·실행, 재시작 필요 여부와 티켓 사용량은 로컬 파일만으로 확인할 수 없어 `unknown`입니다. 등록된 런처나 자격 저장소를 실행·조회하지 않으며 API·네트워크 호출, 상태 생성·수정, 업데이트 알림도 수행하지 않습니다.
189
+
190
+ 원장은 안전한 경로의 크기를 먼저 확인하고 4MiB 이하만 기존 저장 스키마로 검증하여 `total`·`complete`·`unknown` 건수를 표시합니다. 초과 시 `scan_skipped_size_limit`으로 본문 읽기를 건너뜁니다. 처음 사용하여 원장이 없으면 이력은 미확인이고 0건으로 단정하지 않습니다. 관측 중 변경은 `changed_during_observation`으로 집계를 폐기합니다. 진단 시간은 파일 검증·재검증을 포함한 조회 시간이며 쓰기 시간은 `not_measured`입니다. 키·경로·환경값·요청 ID·본문은 출력하지 않습니다. 등록 버전은 숫자형 릴리스 버전만 표시하고 임의 접미사는 `unsupported_version_metadata`로 처리합니다.
191
+
192
+ 연결된 MCP의 `get_routing_capabilities.runtime_diagnostics`는 응답 프로세스의 버전·정책 소스 종류와 프로세스 내 복구 슬롯의 `capacity`·`used`·`remaining`·`expired_retained`·`in_flight`를 제공합니다. 만료된 티켓도 슬롯을 차지하며 조회는 티켓을 갱신·삭제하거나 재시도 가능성을 검사하지 않습니다(`retry_eligibility: not_checked`). 기존 `credential_status`는 시작 시점 관측입니다. 같은 버전은 설정 재로딩이나 모든 쓰기 프로세스의 중지를 증명하지 않습니다. 이 객체는 추가 필드이므로 엄격한 MCP 소비자는 이를 허용해야 합니다. 기존 `aptly report`의 스키마와 파일 출력은 유지됩니다.
193
+
188
194
  ```sh
189
195
  aptly report --format both --output-dir reports
190
196
  ```
@@ -32,7 +32,7 @@ Claude Code의 Hook 파일은 기본적으로 `~/.claude/settings.json`이며, `
32
32
 
33
33
  ## CLI로 설정하기
34
34
 
35
- 미출시 소스의 첫 일반 대화형 `aptly set default`는 클라이언트 홈별 검토 대상을 묶어 질문합니다. `excerpt`를 권장하며 Enter는 기존 범위를 유지하거나 미선택이면 `none`을 선택합니다. [전송 검토](transmission.md#guide-transmission-scope)를 참고하십시오. 이 검토는 공개된 0.1.10에 없습니다.
35
+ 0.1.11부터 첫 일반 대화형 `aptly set default`는 클라이언트 홈별 검토 대상을 묶어 질문합니다. `excerpt`를 권장하며 Enter는 기존 범위를 유지하거나 미선택이면 `none`을 선택합니다. [전송 검토](transmission.md#guide-transmission-scope)를 참고하십시오. 이 재검토 흐름은 0.1.10에서 지원하지 않으므로 먼저 업데이트하십시오.
36
36
 
37
37
  `set` 명령은 0.1.1부터 지원합니다. 명령은 기존 실행 경로를 자동 전환하지 않습니다. API 키 설정은 현재 패키지의 표준 Node/서버 등록과 OS 자격 저장소 참조 지원이 확인된 실행 경로에만 허용됩니다. 사용자 지정 래퍼·구버전·다른 설치 위치는 `credential_launcher_unverified`로 거절하며, 등록을 명시적으로 전환하거나 업그레이드한 뒤 다시 실행해야 합니다.
38
38
 
@@ -97,6 +97,8 @@ MCP의 `env` 값은 문자열이므로 후보 배열도 JSON 문자열로 전달
97
97
 
98
98
  미지정이면 위 기본값, `[]`이면 해당 호스트의 추천을 비활성화합니다. 빈 문자열·중복·지원하지 않는 모델·잘못된 JSON은 오류입니다. `CLAUDE_MODELS`·`CODEX_MODELS`도 별칭으로 지원하지만 같은 제공사의 기본 이름과 별칭을 동시에 설정하면 오류입니다. 후보 설정은 기존 선택을 덮어쓰거나 계정의 모델 접근 권한을 인증하지 않습니다.
99
99
 
100
+ `aptly set default`는 기존 MCP `env`의 후보와 별칭, Codex `env_vars`의 전달 선언, Claude에서 현재 CLI가 확인할 수 있는 상속 후보를 보존합니다. 두 이름 모두 설정되지 않은 모델군에만 기본 후보를 추가합니다. Codex의 전달 변수는 현재 터미널에서 값을 확인할 수 없어도 기본값으로 대체하지 않으며, 상속값을 설정 파일에 복사하지 않습니다. CLI는 같은 이름의 정적 `env` 값을 우선하여 유효한 설정을 검증합니다. 기존 카탈로그 규칙에 따라 두 이름이 함께 전달되거나 값이 잘못되면 설정 변경을 거부합니다. 설정 후 재시작한 MCP의 최종 후보는 별도로 확인하십시오.
101
+
100
102
  ## 관련 문서
101
103
 
102
104
  [설치·업데이트](installation.md) · [자동 추천](routing.md) · [Decisions API 전송 범위](transmission.md) · [고급 MCP 연동·개발 참고](advanced.md) · [문제 해결](troubleshooting.md)
@@ -48,11 +48,11 @@ npm install -g aptly@latest --ignore-scripts
48
48
  aptly setup --client all
49
49
  ```
50
50
 
51
- 미출시 소스에서도 npm lifecycle 설치는 전송 검토를 묻지 않습니다. 기능이 포함된 릴리스로 업데이트한 후 같은 계정 환경에서 대화형 `aptly setup`, `aptly set default` 또는 `aptly set transmission --review`를 실행하십시오. 0.1.10 업데이트 프로세스는 업데이트 중 새 질문을 할 수 없습니다. [전송 검토](transmission.md#guide-transmission-scope)를 참고하십시오.
51
+ 전송 검토는 0.1.11부터 제공하며, npm lifecycle 설치에서는 질문하지 않습니다. 0.1.10에서 업그레이드하는 경우 먼저 패키지를 업데이트한 뒤 같은 계정 환경에서 대화형 `aptly setup`, `aptly set default` 또는 `aptly set transmission --review`를 실행하십시오. 업데이트 프로세스가 새 검토를 대신 실행하거나 동의한 것으로 처리하지 않습니다. [전송 검토](transmission.md#guide-transmission-scope)를 참고하십시오.
52
52
 
53
53
  명시적 `setup`은 설치 스크립트 실행 여부와 관계없이 사용할 수 있습니다. 기존 실행 경로는 보존하므로 구버전 경로 오류는 [실행 경로 복구 절차](troubleshooting.md#guide-launcher-recovery)를 따르십시오. 키 설정·MCP 재시작과 Codex의 `/hooks` 신뢰 승인은 별도로 필요합니다.
54
54
 
55
- 미출시 설치 스크립트는 검토 대기 중인 등록이 있으면 `aptly set transmission --review` 실행 안내만 stderr로 표시하며 질문하거나 선택을 기록하지 않습니다.
55
+ 0.1.11 이상 설치 스크립트는 설정이 정상 완료되고 등록된 클라이언트에 검토가 대기 중이면 `aptly set transmission --review` 실행 안내만 stderr로 표시하며 질문하거나 선택을 기록하지 않습니다.
56
56
 
57
57
  <a id="guide-package-updates"></a>
58
58
 
@@ -22,8 +22,12 @@ aptly stats enable --client codex --codex-native-metadata
22
22
  aptly stats disable --client codex
23
23
  ```
24
24
 
25
+ `aptly stats` 조회와 `--today` 결과의 최상위 `status`는 조회가 완료되면 `complete`(종료 코드 0), 지원하지 않는 통계 요청이나 손상·읽기·저장소 오류가 있으면 `partial`(종료 코드 1)입니다. 수집이 꺼져 있거나 실제로 설정되지 않은 경우도 완료된 조회입니다. 일부 클라이언트가 실패해도 성공한 결과는 유지합니다. 기존 클라이언트 JSON 필드와 값은 유지되므로 전체 객체를 엄격히 검사하는 소비자는 추가된 `status`를 허용해야 합니다. `complete`는 호스트 라우팅·모델·신뢰 준비 상태를 인증하지 않습니다. 예상치 못한 통계 오류는 `statistics_failed`로 보고하며 원시 경로·입력·키·스택은 출력하지 않습니다. 조회는 자동 복구·동의·provider 호출을 수행하지 않습니다.
26
+
25
27
  명령 형식은 `aptly stats [--today] [--client codex|claude|all]`, `aptly stats enable [--client] [--codex-native-metadata]`, `aptly stats disable [--client]`입니다. 수집은 기본적으로 꺼져 있고 postinstall에서도 자동 활성화하지 않습니다. enable은 Aptly 소유 명령 관찰자를 설치하고 별도의 `stats-ownership.json`에 기록하며 기존 receipt·MCP·launcher·키·예산·전송 설정은 유지합니다. 활성화 후 MCP와 호스트를 재시작하고 Codex에서는 `/hooks`의 native Hook 신뢰를 검토하십시오.
26
28
 
29
+ `stats enable`은 첫 이벤트 전에 빈 통계 DB를 초기화하고 기존 DB는 검증하여 보존합니다. 초기화에 실패하면 등록 설정이 남아 있어도 `partial`과 `statistics_store_initialization_failed`를 반환합니다. 이전 버전에서 활성화 후 이벤트가 없어 DB가 아직 없다면 `stats enable`을 다시 실행하십시오. 조회는 DB를 생성하거나 복구하지 않습니다.
30
+
27
31
  disable은 수집을 끄고 변경되지 않은 소유 관찰자만 제거합니다. 수정되거나 사용자 정의된 관찰자는 경고와 함께 보존하며 데이터와 키도 유지합니다. `remove`는 통계 소유 정의를 검증·제거하지만 데이터는 유지합니다. 별도로 관리하는 수동 관찰자나 사용자 정의 Hook은 자동 채택하지 않습니다.
28
32
 
29
33
  비공개 상태는 예산 원장과 별개의 `stats.sqlite`, `stats-config.json`, `stats-key`(HMAC 비밀키)를 사용합니다. 키를 공유하지 마십시오. 기록에는 작업 원문·대화 기록·원시 ID·경로·오류·자격 증명이 없습니다. 통계 조회는 API·키·자격 저장소에 접근하지 않고 초기화나 알림도 실행하지 않습니다.
@@ -4,7 +4,7 @@
4
4
 
5
5
  [가이드 목차](../ko.md)
6
6
 
7
- 아래 전송 검토는 **아직 출시되지 않은 소스 기능**이며, 공개된 Aptly 0.1.10 패키지에는 포함되지 않습니다.
7
+ 아래 전송 검토와 `--review` 명령은 **Aptly 0.1.11부터 제공합니다**. 0.1.10 사용자는 먼저 패키지를 업데이트하십시오.
8
8
 
9
9
  ## 이 문서의 목차
10
10
 
@@ -19,11 +19,11 @@
19
19
 
20
20
  여기서 전송은 **로컬 작업 정보를 OpenAI Decisions API에 보내는 것**이며 Aptly 개발자에게 작업을 제공하는 기능이 아닙니다. 적용 모드 `defaults/advisory`와 전송 범위는 별개입니다. 신규 등록은 v2 정책의 `unselected` 상태이며 자동 전송하지 않습니다.
21
21
 
22
- 공개된 0.1.10의 대화형 `aptly set default`는 미선택 호스트에만 묻고 Enter를 누르면 `none`을 선택합니다. 비대화형 실행과 postinstall은 묻거나 동의한 것으로 처리하지 않습니다.
22
+ 0.1.10에서 업그레이드할 때의 참고: 해당 버전의 대화형 `aptly set default`는 미선택 호스트에만 묻고 Enter를 누르면 `none`을 선택합니다. 비대화형 실행과 postinstall은 묻거나 동의한 것으로 처리하지 않습니다.
23
23
 
24
- 미출시 소스에서는 첫 일반 대화형 `aptly setup` 또는 `aptly set default`가 검토 대기 중인 클라이언트를 하나로 묶어 현재 값·출처·기본 또는 재정의된 홈을 보여 주고 질문합니다. 권장 항목은 3번 `excerpt`입니다. Enter 또는 유지 선택은 기존 명시·legacy 범위와 `none`을 그대로 보존하며, 미선택 범위는 `none`이 됩니다. 명시적인 `setup --transmission` 또는 `set transmission <scope>`는 실제 선택을 검토 완료로 기록합니다. 클라이언트 홈별 비공개 revision 1 검토 표시는 패키지 버전·모드·통계와 독립적이므로 일반 패치 업데이트나 재시작마다 다시 묻지 않습니다.
24
+ 0.1.11부터 첫 일반 대화형 `aptly setup` 또는 `aptly set default`가 검토 대기 중인 클라이언트를 하나로 묶어 현재 값·출처·기본 또는 재정의된 홈을 보여 주고 질문합니다. 권장 항목은 3번 `excerpt`입니다. Enter 또는 유지 선택은 기존 명시·legacy 범위와 `none`을 그대로 보존하며, 미선택 범위는 `none`이 됩니다. 명시적인 `setup --transmission` 또는 `set transmission <scope>`는 실제 선택을 검토 완료로 기록합니다. 클라이언트 홈별 비공개 revision 1 검토 표시는 패키지 버전·모드·통계와 독립적이므로 일반 패치 업데이트나 재시작마다 다시 묻지 않습니다.
25
25
 
26
- 아래 새 명령은 명시적 요청에 따라 항상 다시 묻습니다. 공개된 0.1.10에서는 사용할 수 없습니다:
26
+ 아래 명령은 0.1.11부터 지원하며 명시적 요청에 따라 항상 다시 묻습니다. 0.1.10에서는 먼저 업데이트하십시오:
27
27
 
28
28
  ```sh
29
29
  aptly set transmission --review
@@ -31,7 +31,7 @@ aptly set transmission --review
31
31
 
32
32
  취소하면 범위와 검토 표시는 변경되지 않습니다. 일반 setup 또는 default의 전송 외 기본 설정은 이미 적용되었을 수 있습니다. 자동 setup, check, migrate, 전송 범위를 명시한 setup, CI, 비터미널 실행, setup 건너뛰기, npm lifecycle 스크립트, MCP, Hook, help, show, 통계 조회에서는 묻지 않습니다. 질문은 stderr에 출력하며 JSON stdout은 유지합니다. 기존 비활성 정책·모드·실행 래퍼·키·원장·통계·신뢰 설정을 보존합니다.
33
33
 
34
- 0.1.10 업데이트 프로세스는 새 질문을 즉시 불러올 수 없습니다. 최초 배포에서는 기능이 포함된 릴리스로 업데이트한 후 대화형 `aptly setup`, `aptly set default` 또는 `aptly set transmission --review`를 실행하십시오. 이 기능이 포함된 이후 업데이트는 새 프로세스를 실행하지 않고 다음 단계를 안내합니다.
34
+ 0.1.10의 업데이트 프로세스는 업데이트된 CLI의 새 질문을 즉시 불러오지 않습니다. 0.1.11 이상으로 업데이트한 후 같은 계정 환경에서 대화형 `aptly setup`, `aptly set default` 또는 `aptly set transmission --review`를 실행하십시오. 0.1.11 이상의 `aptly update`도 새 프로세스를 실행하지 않고 후속 설정 명령을 안내합니다.
35
35
 
36
36
  ```sh
37
37
  aptly set transmission --show
@@ -40,6 +40,8 @@ aptly set transmission description
40
40
  aptly set transmission excerpt
41
41
  ```
42
42
 
43
+ `--show` 결과의 최상위 `status`는 조회가 완료되면 `complete`(종료 코드 0), 예상된 설정이 불완전하거나 손상·읽기 오류가 있으면 `partial`(종료 코드 1)입니다. `none`·`unselected`와 실제 미설정 상태(자동 정책이 예상되지 않는 수동 직접 전용 MCP 포함)는 완료된 조회입니다. 일부 클라이언트가 실패해도 성공한 결과는 유지합니다. 기존 클라이언트 JSON 필드와 값은 유지되므로 전체 객체를 엄격히 검사하는 소비자는 추가된 `status`를 허용해야 합니다. 일부 기존 클라이언트 상태는 미설정과 오류를 구분하지 않으므로 집계에는 확인된 조회 상태도 반영됩니다. `complete`는 호스트 라우팅·모델·신뢰 준비 상태를 인증하지 않습니다. 조회는 자동 복구·동의·provider 호출을 수행하지 않으며 원시 경로·입력·키·스택을 출력하지 않습니다.
44
+
43
45
  위 변경 명령은 세 가지 대안을 보여 줍니다. 원하는 하나만 실행하십시오. `--client codex|claude|all`로 대상을 고를 수 있습니다. `none`은 자동 전송을 끄고 원래 호출을 보존합니다. `description`은 부모 에이전트가 제공한 설명만 허용합니다. 설명이 없으면 API 호출 전에 문맥 보충을 요청하며 native 본문·라벨로 자동 대체하지 않습니다. `defaults`는 해결 전 스폰을 차단하고 `advisory`는 안내만 제공합니다. `excerpt`는 기존 native 발췌와 명시 설명을 허용합니다. 설명의 출처·크기·민감 패턴 검사는 비민감성이나 사용자 동의를 인증하지 않습니다.
44
46
 
45
47
  기존 v1은 `legacy` 출처의 `excerpt`로 표시하고 바이트 그대로 유지합니다. 명시 변경은 정책을 v2로 전환하고 소유권 기록을 함께 갱신합니다. 운영자가 수정한 정책·다른 실행 래퍼는 자동으로 인수하지 않으며 충돌 시 보존합니다. 키·원장·불명 기록은 삭제하지 않습니다. 변경 후 MCP를 재시작하십시오. 이미 시작된 전송을 회수하지 못하며 진행 중 결과·retry·fresh는 변경된 정책으로 적용되지 않습니다. 이전 호출 ID의 결합 충돌은 새 유료 ID로 우회하지 마십시오. 명시적 `recommend_agent`·`aptly recommend`는 별도 요청이며 이 자동 전송 설정으로 금지하지 않습니다.