@wrongstack/core 0.299.0 → 0.301.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 (165) hide show
  1. package/dist/chronicle/index.d.ts +2 -0
  2. package/dist/chronicle/index.js +297 -10
  3. package/dist/chronicle/project-server.js +253 -15
  4. package/dist/chronicle/sqlite-compaction.d.ts +20 -0
  5. package/dist/chronicle/sqlite-journal.d.ts +57 -0
  6. package/dist/coordination/agents/capability-manifest.d.ts +7 -0
  7. package/dist/coordination/agents/index.d.ts +3 -2
  8. package/dist/coordination/agents/index.js +818 -570
  9. package/dist/coordination/agents/project-agent-identity.d.ts +6 -6
  10. package/dist/coordination/agents/role-skills.d.ts +1 -1
  11. package/dist/coordination/agents/types.d.ts +6 -0
  12. package/dist/coordination/director.d.ts +10 -2
  13. package/dist/coordination/fleet-manager.d.ts +48 -3
  14. package/dist/coordination/ifleet-manager.d.ts +2 -0
  15. package/dist/coordination/index.js +6880 -6440
  16. package/dist/coordination/mail-tools.d.ts +3 -3
  17. package/dist/coordination/mailbox-project-server.js +3 -4
  18. package/dist/coordination/mailbox-types.d.ts +6 -0
  19. package/dist/coordination/multi-agent-coordinator.d.ts +1 -0
  20. package/dist/core/agent-response.d.ts +5 -1
  21. package/dist/core/agent-tools.d.ts +3 -0
  22. package/dist/core/context.d.ts +20 -0
  23. package/dist/core/fallback-model.d.ts +48 -0
  24. package/dist/core/index.d.ts +11 -9
  25. package/dist/core/index.js +1119 -310
  26. package/dist/core/instruction-template.d.ts +83 -0
  27. package/dist/core/next-steps-slot.d.ts +88 -0
  28. package/dist/core/system-prompt-blocks.d.ts +10 -1
  29. package/dist/core/system-prompt-builder.d.ts +40 -4
  30. package/dist/core/system-prompt-memory-skills.d.ts +1 -0
  31. package/dist/core/system-prompt-skill-bodies.d.ts +3 -3
  32. package/dist/defaults/index.js +9805 -8767
  33. package/dist/design/index.js +11 -3
  34. package/dist/execution/auto-compaction-middleware.d.ts +17 -0
  35. package/dist/execution/autonomy-brain.d.ts +15 -2
  36. package/dist/execution/brain-runtime.d.ts +3 -1
  37. package/dist/execution/compaction-core.d.ts +41 -2
  38. package/dist/execution/council-brain.d.ts +47 -1
  39. package/dist/execution/council-orchestrator.d.ts +25 -6
  40. package/dist/execution/council-prompts.d.ts +12 -1
  41. package/dist/execution/index.d.ts +11 -10
  42. package/dist/execution/index.js +10507 -9189
  43. package/dist/execution/tool-executor.d.ts +4 -1
  44. package/dist/execution/topic-shift-advisor.d.ts +53 -0
  45. package/dist/extension/index.js +8 -2
  46. package/dist/extension/registry.d.ts +8 -1
  47. package/dist/fleet-notifier.d.ts +9 -2
  48. package/dist/goal/index.js +11 -3
  49. package/dist/hooks/index.js +50 -13
  50. package/dist/hooks/runner.d.ts +12 -1
  51. package/dist/hq/index.js +59 -21
  52. package/dist/hq/protocol/fleet.d.ts +20 -0
  53. package/dist/hq/protocol.js +10 -0
  54. package/dist/hq/publisher.d.ts +21 -3
  55. package/dist/index.d.ts +22 -20
  56. package/dist/index.js +12211 -8572
  57. package/dist/infrastructure/index.js +108 -21
  58. package/dist/kernel/events/brain-events.d.ts +9 -0
  59. package/dist/kernel/events/provider-events.d.ts +42 -1
  60. package/dist/kernel/events/session-events.d.ts +13 -0
  61. package/dist/kernel/events/tool-events.d.ts +3 -3
  62. package/dist/models/index.d.ts +1 -0
  63. package/dist/models/index.js +18 -1
  64. package/dist/models/provider-credentials.d.ts +54 -0
  65. package/dist/plugin/api.d.ts +6 -0
  66. package/dist/plugin/config.d.ts +55 -0
  67. package/dist/plugin/index.d.ts +2 -1
  68. package/dist/plugin/index.js +2179 -544
  69. package/dist/plugins/auto-review-plugin.d.ts +3 -0
  70. package/dist/plugins/cloud-config-sync-plugin.d.ts +22 -0
  71. package/dist/plugins/review-claim-registry.d.ts +23 -8
  72. package/dist/plugins/review-types.d.ts +2 -0
  73. package/dist/registry/index.js +109 -74
  74. package/dist/registry/tool-registry.d.ts +15 -0
  75. package/dist/security/capabilities.d.ts +2 -0
  76. package/dist/security/index.d.ts +2 -2
  77. package/dist/security/index.js +166 -44
  78. package/dist/security/permission-helpers.d.ts +23 -6
  79. package/dist/security/permission-policy.d.ts +16 -0
  80. package/dist/security/readonly-permission-policy.d.ts +20 -0
  81. package/dist/security/totp.d.ts +14 -0
  82. package/dist/session-registry-atomic-file.d.ts +32 -5
  83. package/dist/skills/frontmatter.d.ts +6 -0
  84. package/dist/skills/index.js +22 -5
  85. package/dist/storage/cloud-config-sync/sanitize.d.ts +54 -0
  86. package/dist/storage/cloud-config-sync.d.ts +87 -0
  87. package/dist/storage/director-state.d.ts +7 -0
  88. package/dist/storage/index.d.ts +1 -0
  89. package/dist/storage/index.js +887 -74
  90. package/dist/tools/fallback-system-config-view-tool.d.ts +1 -1
  91. package/dist/tools/index.d.ts +1 -1
  92. package/dist/tools/index.js +898 -335
  93. package/dist/tools/one-shot-llm-tool.d.ts +1 -0
  94. package/dist/tools/plugin-manager.d.ts +27 -0
  95. package/dist/types/config/mcp-features.d.ts +18 -11
  96. package/dist/types/config/root.d.ts +8 -1
  97. package/dist/types/config/runtime.d.ts +20 -6
  98. package/dist/types/config/skills-fleet-brain.d.ts +12 -4
  99. package/dist/types/config/tools.d.ts +16 -0
  100. package/dist/types/context-window.d.ts +1 -0
  101. package/dist/types/council.d.ts +11 -0
  102. package/dist/types/hooks.d.ts +14 -0
  103. package/dist/types/index.d.ts +3 -3
  104. package/dist/types/index.js +1 -0
  105. package/dist/types/multi-agent.d.ts +12 -0
  106. package/dist/types/one-shot-llm.d.ts +25 -0
  107. package/dist/types/plugin.d.ts +28 -0
  108. package/dist/types/provider.d.ts +16 -0
  109. package/dist/types/runtime-capability-manifest.d.ts +168 -0
  110. package/dist/types/skill.d.ts +5 -0
  111. package/dist/types/system-prompt.d.ts +3 -1
  112. package/dist/types/tool-executor.d.ts +8 -1
  113. package/dist/utils/context-breakdown.d.ts +8 -2
  114. package/dist/utils/index.d.ts +1 -1
  115. package/dist/utils/index.js +141 -31
  116. package/dist/utils/regex-guard.d.ts +16 -2
  117. package/dist/utils/sage-output-block.d.ts +7 -10
  118. package/dist/utils/wstack-paths.d.ts +11 -3
  119. package/dist/worktree/index.js +4 -4
  120. package/instructions/agents/browser.md +1 -4
  121. package/instructions/agents/e2e.md +17 -15
  122. package/instructions/agents/ios.md +3 -3
  123. package/instructions/agents/search.md +1 -1
  124. package/instructions/autonomy/goal-preamble.md +4 -4
  125. package/instructions/coordination/director-preamble.md +2 -3
  126. package/instructions/coordination/subagent-baseline.md +3 -1
  127. package/instructions/leader-after-task.md +12 -0
  128. package/instructions/llm/chimera-review.md +1 -1
  129. package/instructions/modes/audit-lite.md +1 -1
  130. package/instructions/sections/tool/common-patterns.md +18 -2
  131. package/instructions/sections/tool/mailbox-compact.md +1 -1
  132. package/instructions/sections/tool/mailbox-full.md +1 -1
  133. package/instructions/system-lite.md +91 -3
  134. package/instructions/system-pro.md +296 -102
  135. package/instructions/system.md +248 -92
  136. package/package.json +3 -3
  137. package/skills/api-design/SKILL.md +3 -0
  138. package/skills/audit-log/SKILL.md +2 -0
  139. package/skills/auto-review/SKILL.md +6 -1
  140. package/skills/bug-hunter/SKILL.md +4 -1
  141. package/skills/chimera/SKILL.md +3 -0
  142. package/skills/data-governance/SKILL.md +3 -0
  143. package/skills/design-system/SKILL.md +5 -2
  144. package/skills/docker-deploy/SKILL.md +2 -0
  145. package/skills/git-flow/SKILL.md +2 -0
  146. package/skills/mailbox-bridge/SKILL.md +3 -0
  147. package/skills/mnemosyne/SKILL.md +2 -0
  148. package/skills/multi-agent/SKILL.md +4 -1
  149. package/skills/node-modern/SKILL.md +4 -1
  150. package/skills/observability/SKILL.md +3 -0
  151. package/skills/output-standards/SKILL.md +2 -0
  152. package/skills/plugin-author/SKILL.md +4 -1
  153. package/skills/prompt-engineering/SKILL.md +3 -1
  154. package/skills/react-modern/SKILL.md +6 -3
  155. package/skills/refactor-planner/SKILL.md +2 -0
  156. package/skills/research-web/SKILL.md +3 -0
  157. package/skills/sdd/SKILL.md +3 -1
  158. package/skills/security-scanner/SKILL.md +3 -0
  159. package/skills/skill-creator/SKILL.md +2 -0
  160. package/skills/tech-stack/SKILL.md +3 -0
  161. package/skills/testing/SKILL.md +4 -1
  162. package/skills/typescript-strict/SKILL.md +4 -1
  163. package/skills/wrongstack-kanban/SKILL.md +6 -3
  164. package/skills/wrongstack-mailbox/SKILL.md +4 -1
  165. package/skills/wrongstack-mailbox-mcp/SKILL.md +10 -8
@@ -40,7 +40,14 @@ function securityScoreToTier(score) {
40
40
  }
41
41
 
42
42
  // src/skills/frontmatter.ts
43
- var SCALAR_KEYS = /* @__PURE__ */ new Set(["name", "description", "trigger", "version", "license", "compatibility"]);
43
+ var SCALAR_KEYS = /* @__PURE__ */ new Set([
44
+ "name",
45
+ "description",
46
+ "trigger",
47
+ "version",
48
+ "license",
49
+ "compatibility"
50
+ ]);
44
51
  function parseSkillFrontmatter(raw) {
45
52
  const text = normalizeLineEndings(raw);
46
53
  if (!text.startsWith("---")) return {};
@@ -99,8 +106,9 @@ function parseFrontmatterBlock(block) {
99
106
  out[normalizeKey(key)] = collected.join("\n").trim();
100
107
  continue;
101
108
  }
102
- if (key === "allowed-tools" || key === "allowedTools") {
103
- out.allowedTools = rest.split(/[\s,]+/).filter(Boolean);
109
+ if (key === "allowed-tools" || key === "allowedTools" || key === "required-capabilities" || key === "requiredCapabilities" || key === "required-tools" || key === "requiredTools" || key === "optional-capabilities" || key === "optionalCapabilities") {
110
+ const values = rest.replace(/^\[/, "").replace(/\]$/, "").split(/[\s,]+/).map(unquote).filter(Boolean);
111
+ out[normalizeKey(key)] = values;
104
112
  i++;
105
113
  continue;
106
114
  }
@@ -114,7 +122,11 @@ function parseFrontmatterBlock(block) {
114
122
  return out;
115
123
  }
116
124
  function normalizeKey(key) {
117
- return key === "allowed-tools" ? "allowedTools" : key;
125
+ if (key === "allowed-tools") return "allowedTools";
126
+ if (key === "required-capabilities") return "requiredCapabilities";
127
+ if (key === "required-tools") return "requiredTools";
128
+ if (key === "optional-capabilities") return "optionalCapabilities";
129
+ return key;
118
130
  }
119
131
  function unquote(s) {
120
132
  if (s.length >= 2 && (s.startsWith('"') && s.endsWith('"') || s.startsWith("'") && s.endsWith("'"))) {
@@ -980,7 +992,12 @@ async function openInEditor(filePath, env = process.env) {
980
992
  const child = spawn(parts[0], [...parts.slice(1), filePath], {
981
993
  stdio: "ignore",
982
994
  detached: true,
983
- shell
995
+ shell,
996
+ // `shell` routes through cmd.exe on win32, which flashes a console window
997
+ // before the editor appears. A GUI editor is unaffected by the flag; the
998
+ // shell wrapper is what it suppresses. Repo convention — see
999
+ // `core/tests/architecture/spawn-convention.test.ts`.
1000
+ windowsHide: true
984
1001
  });
985
1002
  child.unref();
986
1003
  }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Contract-aware partitioning and sanitization for my.wrongstack.com config sync.
3
+ *
4
+ * The portal's namespace registry owns a fixed set of `config.json` top-level keys and
5
+ * validates each payload against a strict, recursively-specified schema (server repo:
6
+ * `docs/CLIENT_SYNC_CONTRACT.md`). This module is the client half of that contract:
7
+ *
8
+ * - `buildNamespacePayloads` projects the local config onto the contract field tree, so a
9
+ * payload can never carry a field the server does not know (which would 422) — and, more
10
+ * importantly, can never carry credential material: secret-bearing paths simply are not
11
+ * in the tree.
12
+ * - `applyNamespacePayload` merges a pulled server payload back at contract-field
13
+ * granularity, so locally-kept fields the contract does not own (e.g. `tools.exec`,
14
+ * `mcpServers.*.env`, every `providers.*.apiKey`) are never clobbered by a pull.
15
+ *
16
+ * Stripping is therefore structural (projection), with `stripSecretMaterial` as a final
17
+ * defense-in-depth pass mirroring the server's own scan.
18
+ */
19
+ /** `true` = the whole value is contract-owned; an object = recurse per key; `'*'` = record wildcard. */
20
+ export type ContractNode = true | {
21
+ [key: string]: ContractNode;
22
+ };
23
+ /** Namespace → the contract tree over the `config.json` top-level keys it owns. */
24
+ export declare const CLOUD_SYNC_CONTRACT: Readonly<Record<string, ContractNode>>;
25
+ export declare const CLOUD_SYNC_NAMESPACES: string[];
26
+ /** Server-side schema versions, sent in every push envelope. */
27
+ export declare const NAMESPACE_SCHEMA_VERSIONS: Readonly<Record<string, number>>;
28
+ /**
29
+ * Top-level keys that must never leave the machine, per the contract. Everything not in a
30
+ * contract tree stays local implicitly; this list exists for documentation and tests.
31
+ */
32
+ export declare const LOCAL_ONLY_TOP_LEVEL: readonly ['version', 'configScope', 'hq', 'cloudSync', 'sync', 'models', 'apiKey', 'baseUrl'];
33
+ /**
34
+ * Defense-in-depth sweep run over every outgoing payload after projection: drops any
35
+ * secret-named key and any string value that is (or contains) an encrypted blob. Returns
36
+ * `undefined` when nothing survives.
37
+ */
38
+ export declare function stripSecretMaterial(value: unknown): unknown;
39
+ /**
40
+ * Builds the per-namespace payloads to push. Sections absent locally are omitted (every
41
+ * top-level contract key is optional server-side); a namespace with nothing to say is
42
+ * omitted entirely.
43
+ */
44
+ export declare function buildNamespacePayloads(config: Record<string, unknown>): Record<string, Record<string, unknown>>;
45
+ /**
46
+ * Applies a pulled namespace snapshot to the local config object, returning a new object.
47
+ *
48
+ * Only keys present in the payload are touched (an omitted optional section means "the
49
+ * server doesn't know", never "deleted"), and inside each section only contract-owned
50
+ * paths are replaced — `providers.*.apiKey`, `mcpServers.*.env`, `tools.exec`, and any
51
+ * field newer than the contract stay exactly as they are locally.
52
+ */
53
+ export declare function applyNamespacePayload(config: Record<string, unknown>, namespace: string, payload: Record<string, unknown>): Record<string, unknown>;
54
+ //# sourceMappingURL=sanitize.d.ts.map
@@ -0,0 +1,87 @@
1
+ export { applyNamespacePayload, buildNamespacePayloads, CLOUD_SYNC_CONTRACT, CLOUD_SYNC_NAMESPACES, LOCAL_ONLY_TOP_LEVEL, NAMESPACE_SCHEMA_VERSIONS, stripSecretMaterial, } from './cloud-config-sync/sanitize.js';
2
+ /**
3
+ * CloudConfigSync — synchronizes the profile config with my.wrongstack.com over the
4
+ * namespaced sync API v1 (server repo: docs/CLIENT_SYNC_CONTRACT.md).
5
+ *
6
+ * Distinct from the legacy GitHub `CloudSync` (whole-file categories to a private repo)
7
+ * and from the local HQ command center: this speaks the portal's revisioned,
8
+ * schema-validated, secret-free namespace protocol.
9
+ *
10
+ * A sync pass is pull-then-push:
11
+ * 1. `GET /config?since=<cursor>` — apply changed namespaces at contract granularity
12
+ * (locally-kept fields the contract does not own are never clobbered).
13
+ * 2. For each namespace whose projected payload hash differs from the last synced
14
+ * hash: `PUT /config/<ns>` with `baseRevision` + a persisted `mutationId`, so a
15
+ * crash-and-retry of the same logical change is idempotent server-side.
16
+ * 3. `POST /heartbeat` with the cursor and revision map for fleet observability.
17
+ *
18
+ * Conflicts (409) resolve by three-way merge at owned-top-level-key granularity: keys the
19
+ * local machine did not change since its last sync adopt the server value; keys it did
20
+ * change keep the local value and are re-pushed on top of the server revision.
21
+ */
22
+ export interface CloudConfigSyncSettings {
23
+ enabled: boolean;
24
+ /** Portal base URL, e.g. https://my.wrongstack.com — no trailing slash needed. */
25
+ url: string;
26
+ /** Machine bearer token (wst_…), already decrypted. */
27
+ token: string;
28
+ }
29
+ export interface CloudConfigSyncDeps {
30
+ /** State file location, e.g. `<profileDir>/cloud-sync-state.json`. */
31
+ statePath: string;
32
+ /** Reads the decrypted profile config object (the file layer, not env/CLI merges). */
33
+ readLocalConfig(): Promise<Record<string, unknown>>;
34
+ /**
35
+ * Atomically mutates the profile config file. The mutator receives the decrypted
36
+ * object and returns the replacement; the writer re-encrypts secrets and persists.
37
+ */
38
+ writeLocalConfig(mutator: (config: Record<string, unknown>) => Record<string, unknown>): Promise<void>;
39
+ /** Resolved cloud-sync settings, or null when unconfigured/disabled. */
40
+ getSettings(): CloudConfigSyncSettings | null;
41
+ fetchImpl?: typeof fetch | undefined;
42
+ appVersion?: string | undefined;
43
+ logger?: {
44
+ info(msg: string): void;
45
+ warn(msg: string): void;
46
+ } | undefined;
47
+ randomUUID?: (() => string) | undefined;
48
+ /** Request timeout per HTTP call. Default 15s. */
49
+ requestTimeoutMs?: number | undefined;
50
+ }
51
+ export interface CloudSyncPassSummary {
52
+ ok: boolean;
53
+ skipped: boolean;
54
+ pulled: string[];
55
+ pushed: string[];
56
+ conflicted: string[];
57
+ rejected: string[];
58
+ message: string;
59
+ }
60
+ export declare class CloudConfigSync {
61
+ private readonly deps;
62
+ private state;
63
+ private readonly fetchImpl;
64
+ private readonly uuid;
65
+ private readonly timeoutMs;
66
+ constructor(deps: CloudConfigSyncDeps);
67
+ /** One full pull-then-push-then-heartbeat pass. Never throws; failures are summarized. */
68
+ syncOnce(): Promise<CloudSyncPassSummary>;
69
+ /** Human-readable status for the slash command. */
70
+ statusText(): Promise<string>;
71
+ private pullChanges;
72
+ private applySnapshot;
73
+ private dirtyNamespaces;
74
+ private pushDirty;
75
+ private putNamespace;
76
+ /**
77
+ * Three-way merge at owned-top-level-key granularity: keys unchanged locally since the
78
+ * last sync adopt the server value; locally-changed keys win and are re-pushed on top
79
+ * of the server revision with a fresh mutation id.
80
+ */
81
+ private resolveConflict;
82
+ private heartbeat;
83
+ private request;
84
+ private loadState;
85
+ private saveState;
86
+ }
87
+ //# sourceMappingURL=cloud-config-sync.d.ts.map
@@ -127,6 +127,13 @@ export declare class DirectorStateCheckpoint {
127
127
  * checkpoint continues from there.
128
128
  */
129
129
  resume(snapshot: DirectorStateSnapshot): void;
130
+ /**
131
+ * After resume, pin the live spawn ceiling from the current profile/flag
132
+ * while preserving `spawnCount` (cumulative used budget). Checkpoint
133
+ * metadata previously stored a historical `maxSpawns` that can diverge
134
+ * from the live runtime ceiling — operators need the live value to win.
135
+ */
136
+ applyLiveMaxSpawns(maxSpawns: number | undefined): void;
130
137
  current(): DirectorStateSnapshot;
131
138
  recordSpawn(sub: DirectorSubagentState, spawnCount: number): void;
132
139
  recordTaskAssigned(task: DirectorTaskState): void;
@@ -38,6 +38,7 @@ export { DefaultPromptStore, migratePromptEntry, promptChecksum, type PromptStor
38
38
  export { PromptUsageStore, type PromptUsage } from './prompt-usage-store.js';
39
39
  export { InputHistoryStore, INPUT_HISTORY_DEFAULT_MAX, } from './input-history-store.js';
40
40
  export { CloudSync, type SyncResult, ALL_SYNC_CATEGORIES, } from './cloud-sync.js';
41
+ export { applyNamespacePayload, buildNamespacePayloads, CLOUD_SYNC_CONTRACT, CLOUD_SYNC_NAMESPACES, CloudConfigSync, type CloudConfigSyncDeps, type CloudConfigSyncSettings, type CloudSyncPassSummary, LOCAL_ONLY_TOP_LEVEL, NAMESPACE_SCHEMA_VERSIONS, stripSecretMaterial, } from './cloud-config-sync.js';
41
42
  export { createSessionEventBridge, resolveAuditLevel, resolveSessionLoggingConfig, type SessionEventBridge, type AuditLevel, type SessionEventBridgeOptions, type SessionSamplingOptions, type ToolProgressSamplingOptions, CORE_RECONSTRUCT_EVENTS, STANDARD_AUDIT_EVENTS, } from './session-event-bridge.js';
42
43
  export type { SyncConfig, SyncCategory } from '../types/config.js';
43
44
  //# sourceMappingURL=index.d.ts.map