iosm-cli 0.2.0 → 0.2.2

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 (111) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +64 -52
  3. package/dist/core/agent-teams.d.ts.map +1 -1
  4. package/dist/core/agent-teams.js +38 -11
  5. package/dist/core/agent-teams.js.map +1 -1
  6. package/dist/core/failure-retrospective.d.ts +12 -0
  7. package/dist/core/failure-retrospective.d.ts.map +1 -0
  8. package/dist/core/failure-retrospective.js +115 -0
  9. package/dist/core/failure-retrospective.js.map +1 -0
  10. package/dist/core/model-registry.d.ts.map +1 -1
  11. package/dist/core/model-registry.js +2 -3
  12. package/dist/core/model-registry.js.map +1 -1
  13. package/dist/core/models-dev-provider-catalog.d.ts +30 -0
  14. package/dist/core/models-dev-provider-catalog.d.ts.map +1 -0
  15. package/dist/core/models-dev-provider-catalog.js +118 -0
  16. package/dist/core/models-dev-provider-catalog.js.map +1 -0
  17. package/dist/core/models-dev-providers.d.ts +12 -0
  18. package/dist/core/models-dev-providers.d.ts.map +1 -0
  19. package/dist/core/models-dev-providers.js +736 -0
  20. package/dist/core/models-dev-providers.js.map +1 -0
  21. package/dist/core/project-index/index.d.ts +17 -0
  22. package/dist/core/project-index/index.d.ts.map +1 -0
  23. package/dist/core/project-index/index.js +323 -0
  24. package/dist/core/project-index/index.js.map +1 -0
  25. package/dist/core/project-index/types.d.ts +34 -0
  26. package/dist/core/project-index/types.d.ts.map +1 -0
  27. package/dist/core/project-index/types.js +2 -0
  28. package/dist/core/project-index/types.js.map +1 -0
  29. package/dist/core/sdk.d.ts.map +1 -1
  30. package/dist/core/sdk.js +8 -0
  31. package/dist/core/sdk.js.map +1 -1
  32. package/dist/core/shared-memory.d.ts +46 -0
  33. package/dist/core/shared-memory.d.ts.map +1 -0
  34. package/dist/core/shared-memory.js +253 -0
  35. package/dist/core/shared-memory.js.map +1 -0
  36. package/dist/core/slash-commands.d.ts.map +1 -1
  37. package/dist/core/slash-commands.js +5 -1
  38. package/dist/core/slash-commands.js.map +1 -1
  39. package/dist/core/subagents.js +1 -1
  40. package/dist/core/subagents.js.map +1 -1
  41. package/dist/core/swarm/gates.d.ts +9 -0
  42. package/dist/core/swarm/gates.d.ts.map +1 -0
  43. package/dist/core/swarm/gates.js +65 -0
  44. package/dist/core/swarm/gates.js.map +1 -0
  45. package/dist/core/swarm/index.d.ts +9 -0
  46. package/dist/core/swarm/index.d.ts.map +1 -0
  47. package/dist/core/swarm/index.js +9 -0
  48. package/dist/core/swarm/index.js.map +1 -0
  49. package/dist/core/swarm/locks.d.ts +21 -0
  50. package/dist/core/swarm/locks.d.ts.map +1 -0
  51. package/dist/core/swarm/locks.js +93 -0
  52. package/dist/core/swarm/locks.js.map +1 -0
  53. package/dist/core/swarm/planner.d.ts +16 -0
  54. package/dist/core/swarm/planner.d.ts.map +1 -0
  55. package/dist/core/swarm/planner.js +137 -0
  56. package/dist/core/swarm/planner.js.map +1 -0
  57. package/dist/core/swarm/retry.d.ts +16 -0
  58. package/dist/core/swarm/retry.d.ts.map +1 -0
  59. package/dist/core/swarm/retry.js +32 -0
  60. package/dist/core/swarm/retry.js.map +1 -0
  61. package/dist/core/swarm/scheduler.d.ts +48 -0
  62. package/dist/core/swarm/scheduler.d.ts.map +1 -0
  63. package/dist/core/swarm/scheduler.js +554 -0
  64. package/dist/core/swarm/scheduler.js.map +1 -0
  65. package/dist/core/swarm/spawn.d.ts +16 -0
  66. package/dist/core/swarm/spawn.d.ts.map +1 -0
  67. package/dist/core/swarm/spawn.js +42 -0
  68. package/dist/core/swarm/spawn.js.map +1 -0
  69. package/dist/core/swarm/state-store.d.ts +35 -0
  70. package/dist/core/swarm/state-store.d.ts.map +1 -0
  71. package/dist/core/swarm/state-store.js +106 -0
  72. package/dist/core/swarm/state-store.js.map +1 -0
  73. package/dist/core/swarm/types.d.ts +116 -0
  74. package/dist/core/swarm/types.d.ts.map +1 -0
  75. package/dist/core/swarm/types.js +2 -0
  76. package/dist/core/swarm/types.js.map +1 -0
  77. package/dist/core/system-prompt.d.ts.map +1 -1
  78. package/dist/core/system-prompt.js +3 -2
  79. package/dist/core/system-prompt.js.map +1 -1
  80. package/dist/core/tools/shared-memory.d.ts +23 -0
  81. package/dist/core/tools/shared-memory.d.ts.map +1 -0
  82. package/dist/core/tools/shared-memory.js +134 -0
  83. package/dist/core/tools/shared-memory.js.map +1 -0
  84. package/dist/core/tools/task.d.ts +8 -1
  85. package/dist/core/tools/task.d.ts.map +1 -1
  86. package/dist/core/tools/task.js +664 -123
  87. package/dist/core/tools/task.js.map +1 -1
  88. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  89. package/dist/modes/interactive/components/footer.js +3 -11
  90. package/dist/modes/interactive/components/footer.js.map +1 -1
  91. package/dist/modes/interactive/components/login-dialog.d.ts +1 -0
  92. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  93. package/dist/modes/interactive/components/login-dialog.js +27 -4
  94. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  95. package/dist/modes/interactive/components/oauth-selector.d.ts +13 -1
  96. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  97. package/dist/modes/interactive/components/oauth-selector.js +89 -27
  98. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  99. package/dist/modes/interactive/components/subagent-message.d.ts.map +1 -1
  100. package/dist/modes/interactive/components/subagent-message.js +14 -0
  101. package/dist/modes/interactive/components/subagent-message.js.map +1 -1
  102. package/dist/modes/interactive/interactive-mode.d.ts +50 -0
  103. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  104. package/dist/modes/interactive/interactive-mode.js +1594 -51
  105. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  106. package/docs/cli-reference.md +11 -1
  107. package/docs/configuration.md +4 -1
  108. package/docs/getting-started.md +2 -2
  109. package/docs/interactive-mode.md +43 -4
  110. package/docs/orchestration-and-subagents.md +96 -169
  111. package/package.json +5 -4
@@ -0,0 +1,16 @@
1
+ import type { SwarmSpawnCandidate } from "./types.js";
2
+ export declare function createSpawnFingerprint(candidate: Pick<SwarmSpawnCandidate, "description" | "path" | "changeType">): string;
3
+ export declare class SwarmSpawnQueue {
4
+ private readonly byFingerprint;
5
+ private readonly order;
6
+ enqueue(candidate: SwarmSpawnCandidate): {
7
+ accepted: boolean;
8
+ fingerprint: string;
9
+ };
10
+ drain(limit: number): Array<{
11
+ fingerprint: string;
12
+ candidate: SwarmSpawnCandidate;
13
+ }>;
14
+ size(): number;
15
+ }
16
+ //# sourceMappingURL=spawn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../src/core/swarm/spawn.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAMtD,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,MAAM,GAAG,YAAY,CAAC,GAAG,MAAM,CAG1H;AAED,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IACxE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IAEtC,OAAO,CAAC,SAAS,EAAE,mBAAmB,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;IAUnF,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,mBAAmB,CAAA;KAAE,CAAC;IAcpF,IAAI,IAAI,MAAM;CAGd"}
@@ -0,0 +1,42 @@
1
+ import { createHash } from "node:crypto";
2
+ function normalize(input) {
3
+ return input.trim().toLowerCase().replace(/\s+/g, " ");
4
+ }
5
+ export function createSpawnFingerprint(candidate) {
6
+ const payload = [normalize(candidate.description), normalize(candidate.path), normalize(candidate.changeType)].join("|");
7
+ return createHash("sha256").update(payload).digest("hex").slice(0, 24);
8
+ }
9
+ export class SwarmSpawnQueue {
10
+ constructor() {
11
+ this.byFingerprint = new Map();
12
+ this.order = [];
13
+ }
14
+ enqueue(candidate) {
15
+ const fingerprint = createSpawnFingerprint(candidate);
16
+ if (this.byFingerprint.has(fingerprint)) {
17
+ return { accepted: false, fingerprint };
18
+ }
19
+ this.byFingerprint.set(fingerprint, candidate);
20
+ this.order.push(fingerprint);
21
+ return { accepted: true, fingerprint };
22
+ }
23
+ drain(limit) {
24
+ const result = [];
25
+ const max = Math.max(0, limit);
26
+ while (this.order.length > 0 && result.length < max) {
27
+ const fingerprint = this.order.shift();
28
+ if (!fingerprint)
29
+ break;
30
+ const candidate = this.byFingerprint.get(fingerprint);
31
+ if (!candidate)
32
+ continue;
33
+ this.byFingerprint.delete(fingerprint);
34
+ result.push({ fingerprint, candidate });
35
+ }
36
+ return result;
37
+ }
38
+ size() {
39
+ return this.byFingerprint.size;
40
+ }
41
+ }
42
+ //# sourceMappingURL=spawn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../../src/core/swarm/spawn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,SAAS,SAAS,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,SAA2E;IACjH,MAAM,OAAO,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzH,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,M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ACzC,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED,IAAI;QACH,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;IAChC,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { SwarmSpawnCandidate } from \"./types.js\";\n\nfunction normalize(input: string): string {\n\treturn input.trim().toLowerCase().replace(/\\s+/g, \" \");\n}\n\nexport function createSpawnFingerprint(candidate: Pick<SwarmSpawnCandidate, \"description\" | \"path\" | \"changeType\">): string {\n\tconst payload = [normalize(candidate.description), normalize(candidate.path), normalize(candidate.changeType)].join(\"|\");\n\treturn createHash(\"sha256\").update(payload).digest(\"hex\").slice(0, 24);\n}\n\nexport class SwarmSpawnQueue {\n\tprivate readonly byFingerprint = new Map<string, SwarmSpawnCandidate>();\n\tprivate readonly order: string[] = [];\n\n\tenqueue(candidate: SwarmSpawnCandidate): { accepted: boolean; fingerprint: string } {\n\t\tconst fingerprint = createSpawnFingerprint(candidate);\n\t\tif (this.byFingerprint.has(fingerprint)) {\n\t\t\treturn { accepted: false, fingerprint };\n\t\t}\n\t\tthis.byFingerprint.set(fingerprint, candidate);\n\t\tthis.order.push(fingerprint);\n\t\treturn { accepted: true, fingerprint };\n\t}\n\n\tdrain(limit: number): Array<{ fingerprint: string; candidate: SwarmSpawnCandidate }> {\n\t\tconst result: Array<{ fingerprint: string; candidate: SwarmSpawnCandidate }> = [];\n\t\tconst max = Math.max(0, limit);\n\t\twhile (this.order.length > 0 && result.length < max) {\n\t\t\tconst fingerprint = this.order.shift();\n\t\t\tif (!fingerprint) break;\n\t\t\tconst candidate = this.byFingerprint.get(fingerprint);\n\t\t\tif (!candidate) continue;\n\t\t\tthis.byFingerprint.delete(fingerprint);\n\t\t\tresult.push({ fingerprint, candidate });\n\t\t}\n\t\treturn result;\n\t}\n\n\tsize(): number {\n\t\treturn this.byFingerprint.size;\n\t}\n}\n"]}
@@ -0,0 +1,35 @@
1
+ import type { SwarmEvent, SwarmPlan, SwarmRunMeta, SwarmRuntimeState } from "./types.js";
2
+ export interface SwarmReportsPayload {
3
+ integrationReport: string;
4
+ gates: Record<string, unknown>;
5
+ sharedContext: string;
6
+ }
7
+ export declare class SwarmStateStore {
8
+ private readonly cwd;
9
+ private readonly runId;
10
+ private readonly rootDir;
11
+ private readonly reportsDir;
12
+ constructor(cwd: string, runId: string);
13
+ getRunDir(): string;
14
+ getStatePath(): string;
15
+ private getRunPath;
16
+ private getDagPath;
17
+ private getEventsPath;
18
+ private getCheckpointPath;
19
+ init(meta: SwarmRunMeta, plan: SwarmPlan, state: SwarmRuntimeState): void;
20
+ appendEvent(event: SwarmEvent): void;
21
+ saveState(state: SwarmRuntimeState): void;
22
+ saveCheckpoint(state: SwarmRuntimeState): void;
23
+ loadMeta(): SwarmRunMeta | undefined;
24
+ loadPlan(): SwarmPlan | undefined;
25
+ saveMeta(meta: SwarmRunMeta): void;
26
+ savePlan(plan: SwarmPlan): void;
27
+ loadState(): SwarmRuntimeState | undefined;
28
+ writeReports(payload: SwarmReportsPayload): void;
29
+ static listRuns(cwd: string, limit?: number): Array<{
30
+ runId: string;
31
+ runPath: string;
32
+ statePath: string;
33
+ }>;
34
+ }
35
+ //# sourceMappingURL=state-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-store.d.ts","sourceRoot":"","sources":["../../../src/core/swarm/state-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAezF,MAAM,WAAW,mBAAmB;IACnC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,eAAe;IAIf,OAAO,CAAC,QAAQ,CAAC,GAAG;IAAU,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHhE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAEP,GAAG,EAAE,MAAM,EAAmB,KAAK,EAAE,MAAM;IAKxE,SAAS,IAAI,MAAM;IAInB,YAAY,IAAI,MAAM;IAItB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,iBAAiB;IAIzB,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI;IASzE,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAQpC,SAAS,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAKzC,cAAc,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAQ9C,QAAQ,IAAI,YAAY,GAAG,SAAS;IAIpC,QAAQ,IAAI,SAAS,GAAG,SAAS;IAIjC,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAKlC,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAK/B,SAAS,IAAI,iBAAiB,GAAG,SAAS;IAI1C,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAOhD,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CActG"}
@@ -0,0 +1,106 @@
1
+ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ function writeJson(filePath, payload) {
4
+ writeFileSync(filePath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
5
+ }
6
+ function readJson(filePath) {
7
+ if (!existsSync(filePath))
8
+ return undefined;
9
+ try {
10
+ return JSON.parse(readFileSync(filePath, "utf8"));
11
+ }
12
+ catch {
13
+ return undefined;
14
+ }
15
+ }
16
+ export class SwarmStateStore {
17
+ constructor(cwd, runId) {
18
+ this.cwd = cwd;
19
+ this.runId = runId;
20
+ this.rootDir = join(cwd, ".iosm", "orchestrate", runId);
21
+ this.reportsDir = join(this.rootDir, "reports");
22
+ }
23
+ getRunDir() {
24
+ return this.rootDir;
25
+ }
26
+ getStatePath() {
27
+ return join(this.rootDir, "state.json");
28
+ }
29
+ getRunPath() {
30
+ return join(this.rootDir, "run.json");
31
+ }
32
+ getDagPath() {
33
+ return join(this.rootDir, "dag.json");
34
+ }
35
+ getEventsPath() {
36
+ return join(this.rootDir, "events.jsonl");
37
+ }
38
+ getCheckpointPath() {
39
+ return join(this.rootDir, "checkpoints", "latest.json");
40
+ }
41
+ init(meta, plan, state) {
42
+ mkdirSync(join(this.rootDir, "checkpoints"), { recursive: true });
43
+ mkdirSync(this.reportsDir, { recursive: true });
44
+ writeJson(this.getRunPath(), meta);
45
+ writeJson(this.getDagPath(), plan);
46
+ this.saveState(state);
47
+ this.saveCheckpoint(state);
48
+ }
49
+ appendEvent(event) {
50
+ mkdirSync(this.rootDir, { recursive: true });
51
+ writeFileSync(this.getEventsPath(), `${JSON.stringify(event)}\n`, {
52
+ encoding: "utf8",
53
+ flag: "a",
54
+ });
55
+ }
56
+ saveState(state) {
57
+ mkdirSync(this.rootDir, { recursive: true });
58
+ writeJson(this.getStatePath(), state);
59
+ }
60
+ saveCheckpoint(state) {
61
+ mkdirSync(join(this.rootDir, "checkpoints"), { recursive: true });
62
+ writeJson(this.getCheckpointPath(), {
63
+ savedAt: new Date().toISOString(),
64
+ state,
65
+ });
66
+ }
67
+ loadMeta() {
68
+ return readJson(this.getRunPath());
69
+ }
70
+ loadPlan() {
71
+ return readJson(this.getDagPath());
72
+ }
73
+ saveMeta(meta) {
74
+ mkdirSync(this.rootDir, { recursive: true });
75
+ writeJson(this.getRunPath(), meta);
76
+ }
77
+ savePlan(plan) {
78
+ mkdirSync(this.rootDir, { recursive: true });
79
+ writeJson(this.getDagPath(), plan);
80
+ }
81
+ loadState() {
82
+ return readJson(this.getStatePath());
83
+ }
84
+ writeReports(payload) {
85
+ mkdirSync(this.reportsDir, { recursive: true });
86
+ writeFileSync(join(this.reportsDir, "integration_report.md"), `${payload.integrationReport.trim()}\n`, "utf8");
87
+ writeJson(join(this.reportsDir, "gates.json"), payload.gates);
88
+ writeFileSync(join(this.reportsDir, "shared_context.md"), `${payload.sharedContext.trim()}\n`, "utf8");
89
+ }
90
+ static listRuns(cwd, limit = 20) {
91
+ const root = join(cwd, ".iosm", "orchestrate");
92
+ if (!existsSync(root))
93
+ return [];
94
+ const names = readdirSync(root, { withFileTypes: true })
95
+ .filter((entry) => entry.isDirectory())
96
+ .map((entry) => entry.name)
97
+ .sort((a, b) => b.localeCompare(a))
98
+ .slice(0, Math.max(1, limit));
99
+ return names.map((runId) => ({
100
+ runId,
101
+ runPath: join(root, runId, "run.json"),
102
+ statePath: join(root, runId, "state.json"),
103
+ }));
104
+ }
105
+ }
106
+ //# sourceMappingURL=state-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-store.js","sourceRoot":"","sources":["../../../src/core/swarm/state-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,SAAS,SAAS,CAAC,QAAgB,EAAE,OAAgB;IACpD,aAAa,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,QAAQ,CAAI,QAAgB;IACpC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,IAAI,CAAC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ACtD,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;aACtC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;aAC1B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;aAClC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC5B,KAAK;YACL,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC;YACtC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC;SAC1C,CAAC,CAAC,CAAC;IACL,CAAC;CACD","sourcesContent":["import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { SwarmEvent, SwarmPlan, SwarmRunMeta, SwarmRuntimeState } from \"./types.js\";\n\nfunction writeJson(filePath: string, payload: unknown): void {\n\twriteFileSync(filePath, `${JSON.stringify(payload, null, 2)}\\n`, \"utf8\");\n}\n\nfunction readJson<T>(filePath: string): T | undefined {\n\tif (!existsSync(filePath)) return undefined;\n\ttry {\n\t\treturn JSON.parse(readFileSync(filePath, \"utf8\")) as T;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport interface SwarmReportsPayload {\n\tintegrationReport: string;\n\tgates: Record<string, unknown>;\n\tsharedContext: string;\n}\n\nexport class SwarmStateStore {\n\tprivate readonly rootDir: string;\n\tprivate readonly reportsDir: string;\n\n\tconstructor(private readonly cwd: string, private readonly runId: string) {\n\t\tthis.rootDir = join(cwd, \".iosm\", \"orchestrate\", runId);\n\t\tthis.reportsDir = join(this.rootDir, \"reports\");\n\t}\n\n\tgetRunDir(): string {\n\t\treturn this.rootDir;\n\t}\n\n\tgetStatePath(): string {\n\t\treturn join(this.rootDir, \"state.json\");\n\t}\n\n\tprivate getRunPath(): string {\n\t\treturn join(this.rootDir, \"run.json\");\n\t}\n\n\tprivate getDagPath(): string {\n\t\treturn join(this.rootDir, \"dag.json\");\n\t}\n\n\tprivate getEventsPath(): string {\n\t\treturn join(this.rootDir, \"events.jsonl\");\n\t}\n\n\tprivate getCheckpointPath(): string {\n\t\treturn join(this.rootDir, \"checkpoints\", \"latest.json\");\n\t}\n\n\tinit(meta: SwarmRunMeta, plan: SwarmPlan, state: SwarmRuntimeState): void {\n\t\tmkdirSync(join(this.rootDir, \"checkpoints\"), { recursive: true });\n\t\tmkdirSync(this.reportsDir, { recursive: true });\n\t\twriteJson(this.getRunPath(), meta);\n\t\twriteJson(this.getDagPath(), plan);\n\t\tthis.saveState(state);\n\t\tthis.saveCheckpoint(state);\n\t}\n\n\tappendEvent(event: SwarmEvent): void {\n\t\tmkdirSync(this.rootDir, { recursive: true });\n\t\twriteFileSync(this.getEventsPath(), `${JSON.stringify(event)}\\n`, {\n\t\t\tencoding: \"utf8\",\n\t\t\tflag: \"a\",\n\t\t});\n\t}\n\n\tsaveState(state: SwarmRuntimeState): void {\n\t\tmkdirSync(this.rootDir, { recursive: true });\n\t\twriteJson(this.getStatePath(), state);\n\t}\n\n\tsaveCheckpoint(state: SwarmRuntimeState): void {\n\t\tmkdirSync(join(this.rootDir, \"checkpoints\"), { recursive: true });\n\t\twriteJson(this.getCheckpointPath(), {\n\t\t\tsavedAt: new Date().toISOString(),\n\t\t\tstate,\n\t\t});\n\t}\n\n\tloadMeta(): SwarmRunMeta | undefined {\n\t\treturn readJson<SwarmRunMeta>(this.getRunPath());\n\t}\n\n\tloadPlan(): SwarmPlan | undefined {\n\t\treturn readJson<SwarmPlan>(this.getDagPath());\n\t}\n\n\tsaveMeta(meta: SwarmRunMeta): void {\n\t\tmkdirSync(this.rootDir, { recursive: true });\n\t\twriteJson(this.getRunPath(), meta);\n\t}\n\n\tsavePlan(plan: SwarmPlan): void {\n\t\tmkdirSync(this.rootDir, { recursive: true });\n\t\twriteJson(this.getDagPath(), plan);\n\t}\n\n\tloadState(): SwarmRuntimeState | undefined {\n\t\treturn readJson<SwarmRuntimeState>(this.getStatePath());\n\t}\n\n\twriteReports(payload: SwarmReportsPayload): void {\n\t\tmkdirSync(this.reportsDir, { recursive: true });\n\t\twriteFileSync(join(this.reportsDir, \"integration_report.md\"), `${payload.integrationReport.trim()}\\n`, \"utf8\");\n\t\twriteJson(join(this.reportsDir, \"gates.json\"), payload.gates);\n\t\twriteFileSync(join(this.reportsDir, \"shared_context.md\"), `${payload.sharedContext.trim()}\\n`, \"utf8\");\n\t}\n\n\tstatic listRuns(cwd: string, limit = 20): Array<{ runId: string; runPath: string; statePath: string }> {\n\t\tconst root = join(cwd, \".iosm\", \"orchestrate\");\n\t\tif (!existsSync(root)) return [];\n\t\tconst names = readdirSync(root, { withFileTypes: true })\n\t\t\t.filter((entry) => entry.isDirectory())\n\t\t\t.map((entry) => entry.name)\n\t\t\t.sort((a, b) => b.localeCompare(a))\n\t\t\t.slice(0, Math.max(1, limit));\n\t\treturn names.map((runId) => ({\n\t\t\trunId,\n\t\t\trunPath: join(root, runId, \"run.json\"),\n\t\t\tstatePath: join(root, runId, \"state.json\"),\n\t\t}));\n\t}\n}\n"]}
@@ -0,0 +1,116 @@
1
+ import type { EngineeringContract } from "../contract.js";
2
+ import type { RepoScaleMode } from "../project-index/types.js";
3
+ export type SwarmTaskStatus = "pending" | "ready" | "running" | "done" | "error" | "blocked" | "cancelled";
4
+ export type SwarmRunStatus = "running" | "completed" | "blocked" | "stopped" | "failed";
5
+ export type SwarmSeverity = "low" | "medium" | "high";
6
+ export type SwarmConcurrencyClass = "default" | "analysis" | "implementation" | "verification" | "docs" | "tests";
7
+ export type SwarmSpawnPolicy = "allow" | "manual_high_risk" | "deny";
8
+ export interface SwarmTaskPlan {
9
+ id: string;
10
+ brief: string;
11
+ depends_on: string[];
12
+ scopes: string[];
13
+ touches: string[];
14
+ concurrency_class: SwarmConcurrencyClass;
15
+ severity: SwarmSeverity;
16
+ needs_user_input: boolean;
17
+ model_hint?: string;
18
+ spawn_policy?: SwarmSpawnPolicy;
19
+ }
20
+ export interface SwarmTaskRuntimeState {
21
+ id: string;
22
+ status: SwarmTaskStatus;
23
+ attempts: number;
24
+ depends_on: string[];
25
+ startedAt?: string;
26
+ completedAt?: string;
27
+ lastError?: string;
28
+ touches: string[];
29
+ scopes: string[];
30
+ }
31
+ export interface SwarmBudgetState {
32
+ limitUsd?: number;
33
+ spentUsd: number;
34
+ warned80: boolean;
35
+ hardStopped: boolean;
36
+ }
37
+ export interface SwarmRuntimeState {
38
+ runId: string;
39
+ status: SwarmRunStatus;
40
+ createdAt: string;
41
+ updatedAt: string;
42
+ tick: number;
43
+ noProgressTicks: number;
44
+ readyQueue: string[];
45
+ blockedTasks: string[];
46
+ tasks: Record<string, SwarmTaskRuntimeState>;
47
+ locks: Record<string, string[]>;
48
+ retries: Record<string, number>;
49
+ budget: SwarmBudgetState;
50
+ lastError?: string;
51
+ }
52
+ export type SwarmEventType = "run_started" | "tick" | "task_ready" | "task_running" | "task_done" | "task_error" | "task_blocked" | "task_retry" | "lock_acquired" | "lock_released" | "spawn_enqueued" | "spawn_rejected" | "run_completed" | "run_blocked" | "run_stopped" | "run_failed" | "gate_task" | "gate_run";
53
+ export interface SwarmEvent {
54
+ type: SwarmEventType;
55
+ timestamp: string;
56
+ runId: string;
57
+ tick?: number;
58
+ taskId?: string;
59
+ message: string;
60
+ payload?: Record<string, unknown>;
61
+ }
62
+ export interface SwarmGateResult {
63
+ taskId: string;
64
+ pass: boolean;
65
+ warnings: string[];
66
+ failures: string[];
67
+ checks: string[];
68
+ }
69
+ export interface SwarmRunGateResult {
70
+ pass: boolean;
71
+ warnings: string[];
72
+ failures: string[];
73
+ }
74
+ export interface SwarmSpawnCandidate {
75
+ description: string;
76
+ path: string;
77
+ changeType: string;
78
+ severity: SwarmSeverity;
79
+ parentTaskId?: string;
80
+ }
81
+ export interface SwarmDispatchResult {
82
+ taskId: string;
83
+ status: "done" | "error" | "blocked";
84
+ error?: string;
85
+ failureCause?: string;
86
+ costUsd?: number;
87
+ touchesRefined?: string[];
88
+ spawnCandidates?: SwarmSpawnCandidate[];
89
+ }
90
+ export interface SwarmPlan {
91
+ source: "plain" | "singular";
92
+ request: string;
93
+ tasks: SwarmTaskPlan[];
94
+ notes: string[];
95
+ }
96
+ export interface SwarmRunMeta {
97
+ runId: string;
98
+ createdAt: string;
99
+ source: "plain" | "singular";
100
+ request: string;
101
+ contract: EngineeringContract;
102
+ contractHash: string;
103
+ repoScaleMode: RepoScaleMode;
104
+ semanticStatus?: string;
105
+ maxParallel: number;
106
+ budgetUsd?: number;
107
+ linkedSingularRunId?: string;
108
+ linkedSingularOption?: string;
109
+ }
110
+ export interface SwarmSchedulerResult {
111
+ state: SwarmRuntimeState;
112
+ taskGates: SwarmGateResult[];
113
+ runGate: SwarmRunGateResult;
114
+ events: SwarmEvent[];
115
+ }
116
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/swarm/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;AAC3G,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AACxF,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AACtD,MAAM,MAAM,qBA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CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/swarm/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { EngineeringContract } from \"../contract.js\";\nimport type { RepoScaleMode } from \"../project-index/types.js\";\n\nexport type SwarmTaskStatus = \"pending\" | \"ready\" | \"running\" | \"done\" | \"error\" | \"blocked\" | \"cancelled\";\nexport type SwarmRunStatus = \"running\" | \"completed\" | \"blocked\" | \"stopped\" | \"failed\";\nexport type SwarmSeverity = \"low\" | \"medium\" | \"high\";\nexport type SwarmConcurrencyClass = \"default\" | \"analysis\" | \"implementation\" | \"verification\" | \"docs\" | \"tests\";\nexport type SwarmSpawnPolicy = \"allow\" | \"manual_high_risk\" | \"deny\";\n\nexport interface SwarmTaskPlan {\n\tid: string;\n\tbrief: string;\n\tdepends_on: string[];\n\tscopes: string[];\n\ttouches: string[];\n\tconcurrency_class: SwarmConcurrencyClass;\n\tseverity: SwarmSeverity;\n\tneeds_user_input: boolean;\n\tmodel_hint?: string;\n\tspawn_policy?: SwarmSpawnPolicy;\n}\n\nexport interface SwarmTaskRuntimeState {\n\tid: string;\n\tstatus: SwarmTaskStatus;\n\tattempts: number;\n\tdepends_on: string[];\n\tstartedAt?: string;\n\tcompletedAt?: string;\n\tlastError?: string;\n\ttouches: string[];\n\tscopes: string[];\n}\n\nexport interface SwarmBudgetState {\n\tlimitUsd?: number;\n\tspentUsd: number;\n\twarned80: boolean;\n\thardStopped: boolean;\n}\n\nexport interface SwarmRuntimeState {\n\trunId: string;\n\tstatus: SwarmRunStatus;\n\tcreatedAt: string;\n\tupdatedAt: string;\n\ttick: number;\n\tnoProgressTicks: number;\n\treadyQueue: string[];\n\tblockedTasks: string[];\n\ttasks: Record<string, SwarmTaskRuntimeState>;\n\tlocks: Record<string, string[]>;\n\tretries: Record<string, number>;\n\tbudget: SwarmBudgetState;\n\tlastError?: string;\n}\n\nexport type SwarmEventType =\n\t| \"run_started\"\n\t| \"tick\"\n\t| \"task_ready\"\n\t| \"task_running\"\n\t| \"task_done\"\n\t| \"task_error\"\n\t| \"task_blocked\"\n\t| \"task_retry\"\n\t| \"lock_acquired\"\n\t| \"lock_released\"\n\t| \"spawn_enqueued\"\n\t| \"spawn_rejected\"\n\t| \"run_completed\"\n\t| \"run_blocked\"\n\t| \"run_stopped\"\n\t| \"run_failed\"\n\t| \"gate_task\"\n\t| \"gate_run\";\n\nexport interface SwarmEvent {\n\ttype: SwarmEventType;\n\ttimestamp: string;\n\trunId: string;\n\ttick?: number;\n\ttaskId?: string;\n\tmessage: string;\n\tpayload?: Record<string, unknown>;\n}\n\nexport interface SwarmGateResult {\n\ttaskId: string;\n\tpass: boolean;\n\twarnings: string[];\n\tfailures: string[];\n\tchecks: string[];\n}\n\nexport interface SwarmRunGateResult {\n\tpass: boolean;\n\twarnings: string[];\n\tfailures: string[];\n}\n\nexport interface SwarmSpawnCandidate {\n\tdescription: string;\n\tpath: string;\n\tchangeType: string;\n\tseverity: SwarmSeverity;\n\tparentTaskId?: string;\n}\n\nexport interface SwarmDispatchResult {\n\ttaskId: string;\n\tstatus: \"done\" | \"error\" | \"blocked\";\n\terror?: string;\n\tfailureCause?: string;\n\tcostUsd?: number;\n\ttouchesRefined?: string[];\n\tspawnCandidates?: SwarmSpawnCandidate[];\n}\n\nexport interface SwarmPlan {\n\tsource: \"plain\" | \"singular\";\n\trequest: string;\n\ttasks: SwarmTaskPlan[];\n\tnotes: string[];\n}\n\nexport interface SwarmRunMeta {\n\trunId: string;\n\tcreatedAt: string;\n\tsource: \"plain\" | \"singular\";\n\trequest: string;\n\tcontract: EngineeringContract;\n\tcontractHash: string;\n\trepoScaleMode: RepoScaleMode;\n\tsemanticStatus?: string;\n\tmaxParallel: number;\n\tbudgetUsd?: number;\n\tlinkedSingularRunId?: string;\n\tlinkedSingularOption?: string;\n}\n\nexport interface SwarmSchedulerResult {\n\tstate: SwarmRuntimeState;\n\ttaskGates: SwarmGateResult[];\n\trunGate: SwarmRunGateResult;\n\tevents: SwarmEvent[];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AA0BhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,yBAAyB;IACzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,MAAM,CAuRhF"}
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAyB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AA0BhE,MAAM,WAAW,wBAAwB;IACxC,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,uCAAuC;IACvC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,yBAAyB;IACzB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,kEAAkE;AAClE,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,MAAM,CAwRhF"}
@@ -206,8 +206,9 @@ Operating defaults:
206
206
  - For explicit subagent/orchestration requests, execute at least one task tool call before giving a final prose-only answer.
207
207
  - Do not expose internal orchestration scaffolding to the user (for example: [ORCHESTRATION_DIRECTIVE], pseudo tool-call JSON, or raw task arguments).
208
208
  - When invoking tools, call them directly without preambles like "I will now call tool X"; only report outcomes that matter to the user.
209
- - Respect orchestration constraints from the user exactly: count, parallel vs sequential execution, per-agent profile, and per-agent working directory (cwd) when provided.
210
- - For explicit parallel orchestration requests, issue multiple independent task tool calls to match the requested agent count; do not collapse to a single subagent unless the user asks for one.
209
+ - Respect orchestration constraints from the user exactly: count, parallel vs sequential execution, per-agent profile, and per-agent working directory (cwd) when provided.
210
+ - Treat explicit orchestration requests in any language as constraints (including non-English text and minor typos).
211
+ - For explicit parallel orchestration requests, issue multiple independent task tool calls to match the requested agent count; do not collapse to a single subagent unless the user asks for one.
211
212
  - For explicit parallel orchestration requests, emit independent task calls in a single assistant turn whenever possible so they can be launched together.
212
213
  - Runtime note: when parallel orchestration is requested, emit independent task calls in one assistant turn so they can run concurrently; avoid background mode unless the user explicitly asks for detached async runs.
213
214
  - If orchestration constraints are ambiguous or conflict, ask one concise clarification (or use ask_user when available) before launching subagents.
@@ -1 +1 @@
1
- {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAEhE,0CAA0C;AAC1C,MAAM,gBAAgB,GAA2B;IAChD,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,8CAA8C;IACpD,IAAI,EAAE,4DAA4D;IAClE,KAAK,EAAE,2BAA2B;IAClC,IAAI,EAAE,yDAAyD;IAC/D,IAAI,EAAE,kDAAkD;IACxD,EAAE,EAAE,yBAAyB;IAC7B,EAAE,EAAE,+FAA+F;IACnG,EAAE,EAAE,yCAAyC;IAC7C,QAAQ,EACP,uHAAuH;IACxH,KAAK,EACJ,wGAAwG;IACzG,EAAE,EAAE,yCAAyC;IAC7C,EAAE,EAAE,mDAAmD;IACvD,OAAO,EAAE,mDAAmD;IAC5D,GAAG,EAAE,oEAAoE;IACzE,eAAe,EACd,4FAA4F;IAC7F,IAAI,EAAE,6MAA6M;CACnN,CAAC;AAqBF,kEAAkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,UAAoC,EAAE;IACvE,MAAM,EACL,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,GAAG,EACH,YAAY,EAAE,oBAAoB,EAClC,MAAM,EAAE,cAAc,GACtB,GAAG,OAAO,CAAC;IACZ,MAAM,WAAW,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAEzC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,MAAM,QAAQ,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE;QAC5C,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,MAAM;QACb,GA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2BAA2B,CAAC;QACtC,MAAM,IAAI,mDAAmD,CAAC;QAC9D,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;YACxD,MAAM,IAAI,MAAM,QAAQ,OAAO,OAAO,MAAM,CAAC;QAC9C,CAAC;IACF,CAAC;IAED,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,2CAA2C;IAC3C,MAAM,IAAI,4BAA4B,QAAQ,EAAE,CAAC;IACjD,MAAM,IAAI,gCAAgC,WAAW,EAAE,CAAC;IAExD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.js\";\n\n/** Tool descriptions for system prompt */\nconst toolDescriptions: Record<string, string> = {\n\tread: \"Read file contents\",\n\tbash: \"Execute bash commands (ls, grep, find, etc.)\",\n\tedit: \"Make surgical edits to files (find exact text and replace)\",\n\twrite: \"Create or overwrite files\",\n\tgrep: \"Search file contents for patterns (respects .gitignore)\",\n\tfind: \"Find files by glob pattern (respects .gitignore)\",\n\tls: \"List directory contents\",\n\trg: \"Run ripgrep directly for advanced regex search (prefer explicit path args, e.g. -n pattern .)\",\n\tfd: \"Run fd directly for fast file discovery\",\n\tast_grep:\n\t\t\"Run ast-grep for AST/syntax-aware structural code search (prefer run --pattern; retry with scan/-p on older versions)\",\n\tcomby:\n\t\t\"Run comby for structural pattern search/rewrite previews (prefer explicit -matcher; no in-place edits)\",\n\tjq: \"Run jq for JSON querying/transformation\",\n\tyq: \"Run yq for YAML/JSON/TOML querying/transformation\",\n\tsemgrep: \"Run semgrep for structural/static security checks\",\n\tsed: \"Run sed for stream editing/extraction previews (no in-place edits)\",\n\tsemantic_search:\n\t\t\"Semantic embeddings search over the project index (actions: status, index, rebuild, query)\",\n\ttask: \"Run a specialized subagent (supports profile, cwd, lock_key for optional write serialization, run_id/task_id, model override, background mode for detached runs, and agent=<custom name from .iosm/agents>)\",\n};\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write] */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. Default: process.cwd() */\n\tcwd?: string;\n\t/** Pre-loaded context files. */\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\t/** Pre-loaded skills. */\n\tskills?: Skill[];\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions = {}): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd ?? process.cwd();\n\n\tconst now = new Date();\n\tconst dateTime = now.toLocaleString(\"en-US\", {\n\t\tweekday: \"long\",\n\t\tyear: \"numeric\",\n\t\tmonth: \"long\",\n\t\tday: \"numeric\",\n\t\thour: \"2-digit\",\n\t\tminute: \"2-digit\",\n\t\tsecond: \"2-digit\",\n\t\ttimeZoneName: \"short\",\n\t});\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\t// Append project context files\n\t\tif (contextFiles.length > 0) {\n\t\t\tprompt += \"\\n\\n# Project Context\\n\\n\";\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\t\tprompt += `## ${filePath}\\n\\n${content}\\n\\n`;\n\t\t\t}\n\t\t}\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date/time and working directory last\n\t\tprompt += `\\nCurrent date and time: ${dateTime}`;\n\t\tprompt += `\\nCurrent working directory: ${resolvedCwd}`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// Built-ins use toolDescriptions. Custom tools can provide one-line snippets.\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst toolsList =\n\t\ttools.length > 0\n\t\t\t? tools\n\t\t\t\t\t.map((name) => {\n\t\t\t\t\t\tconst snippet = toolSnippets?.[name] ?? toolDescriptions[name] ?? name;\n\t\t\t\t\t\treturn `- ${name}: ${snippet}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\")\n\t\t\t: \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasEdit = tools.includes(\"edit\");\n\tconst hasWrite = tools.includes(\"write\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst hasRg = tools.includes(\"rg\");\n\tconst hasFd = tools.includes(\"fd\");\n\tconst hasAstGrep = tools.includes(\"ast_grep\");\n\tconst hasComby = tools.includes(\"comby\");\n\tconst hasJq = tools.includes(\"jq\");\n\tconst hasYq = tools.includes(\"yq\");\n\tconst hasSemgrep = tools.includes(\"semgrep\");\n\tconst hasSed = tools.includes(\"sed\");\n\tconst hasSemanticSearch = tools.includes(\"semantic_search\");\n\tconst hasRead = tools.includes(\"read\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs && !hasRg && !hasFd) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find; prefer rg for targeted search when available\");\n\t} else if (hasBash && (hasGrep || hasFind || hasLs || hasRg || hasFd)) {\n\t\taddGuideline(\"Prefer grep/find/ls/rg/fd tools over bash for codebase exploration (faster and less noisy)\");\n\t}\n\n\tif (hasRg || hasFd || hasAstGrep || hasComby || hasJq || hasYq || hasSemgrep || hasSed || hasSemanticSearch) {\n\t\taddGuideline(\n\t\t\t\"Route work to specialized tools first: rg/fd (search/discovery), semantic_search (concept-level retrieval), ast_grep/comby (structural code queries), jq/yq (data/config transforms), semgrep (risk scans), sed (stream extraction)\",\n\t\t);\n\t}\n\n\tif (hasAstGrep || hasComby) {\n\t\taddGuideline(\"Use ast_grep/comby for syntax-aware structural queries before falling back to broad regex\");\n\t}\n\n\tif (hasComby) {\n\t\taddGuideline(\"Use comby to preview structural rewrite matches first, then apply final changes via edit/write\");\n\t}\n\n\tif (hasJq || hasYq) {\n\t\taddGuideline(\"Prefer jq/yq over ad-hoc shell parsing when extracting or transforming JSON/YAML/TOML\");\n\t}\n\n\tif (hasSemgrep) {\n\t\taddGuideline(\"Use semgrep for rule-based risk scans and structural security checks when relevant\");\n\t}\n\n\tif (hasSed) {\n\t\taddGuideline(\"Use sed for preview/extraction workflows only; perform final file edits with edit/write\");\n\t}\n\n\tif (hasSemanticSearch) {\n\t\taddGuideline(\n\t\t\t\"Use semantic_search for intent/meaning queries that are hard to express with regex; use rg/ast_grep for exact symbol and syntax matches\",\n\t\t);\n\t\taddGuideline(\n\t\t\t\"semantic_search query can auto-refresh stale indexes when semantic auto-index is enabled (default); if disabled or if provider/chunk/filter changes require it, run semantic_search index/rebuild explicitly\",\n\t\t);\n\t}\n\n\tif (hasRg || hasAstGrep || hasComby) {\n\t\taddGuideline(\n\t\t\t\"For rg/ast_grep/comby, pass explicit target paths to avoid cwd ambiguity; if syntax errors occur (especially ast_grep), retry once with version-compatible command forms before concluding no matches\",\n\t\t);\n\t}\n\n\tif (\n\t\thasBash &&\n\t\t(hasRg || hasFd || hasAstGrep || hasComby || hasJq || hasYq || hasSemgrep || hasSed || hasSemanticSearch)\n\t) {\n\t\taddGuideline(\n\t\t\t\"If a required CLI tool is missing, install it first when permitted (rg/fd can be auto-managed; others via brew/apt/pipx/npm), then continue with that tool instead of broad bash fallback. For semantic_search, configure provider/index first via /semantic setup.\",\n\t\t);\n\t}\n\n\t// Read before edit guideline\n\tif (hasRead && hasEdit) {\n\t\taddGuideline(\"Use read to examine files before editing. You must use this tool instead of cat or sed.\");\n\t}\n\n\t// Edit guideline\n\tif (hasEdit) {\n\t\taddGuideline(\"Use edit for precise changes (old text must match exactly)\");\n\t}\n\n\t// Write guideline\n\tif (hasWrite) {\n\t\taddGuideline(\"Use write only for new files or complete rewrites\");\n\t}\n\n\t// Output guideline (only when actually writing or executing)\n\tif (hasEdit || hasWrite) {\n\t\taddGuideline(\n\t\t\t\"When summarizing your actions, output plain text directly - do NOT use cat or bash to display what you did\",\n\t\t);\n\t}\n\n\taddGuideline(\"Inspect the relevant files before editing and keep exploration bounded to the task\");\n\taddGuideline(\"Make reasonable assumptions and continue unless a risky ambiguity blocks the work\");\n\taddGuideline(\"Classify requests as simple vs complex: execute simple work immediately, use a step plan for complex work\");\n\taddGuideline(\"For complex work, publish a short step plan before edits and keep step statuses current while executing\");\n\taddGuideline(\"If a meaningful architecture or product fork changes implementation, ask a concise clarification before editing\");\n\taddGuideline(\"After changes, run the smallest relevant verification and report the concrete result\");\n\taddGuideline(\"Do not claim success without evidence; if you could not verify, say so explicitly\");\n\taddGuideline(\"Complete the requested task end-to-end when possible instead of stopping at analysis\");\n\taddGuideline(\"For code review requests, lead with findings and risks before summaries\");\n\taddGuideline(\n\t\t\"When an active engineering contract is present in context, treat its constraints, quality gates, and definition_of_done as execution requirements unless user overrides them.\",\n\t);\n\taddGuideline(\"For major feature forks, run a /singular feasibility pass before coding to compare implementation options.\");\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are a professional software engineering agent operating inside iosm-cli. Help users inspect systems, change code, run commands, maintain project artifacts when needed, and explain results clearly.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n${guidelines}\n\nOperating defaults:\n- Summarize work in standard engineering language first: what you inspected, what you changed, what you verified, and any remaining risk or blocker.\n- Do NOT start by reading documentation unless the user asks for documentation help, asks about harness internals, or implementation is blocked without it.\n- Start implementation turns with a quick repository scan of the files most likely to matter before proposing or editing.\n- Prefer targeted reads and searches over broad dumps; keep command output bounded and focused.\n- For complex tasks, include a machine-readable plan block before edits and update it when statuses change:\n <task_plan complexity=\"complex\">\n - [in_progress] Current step\n - [pending] Next step\n </task_plan>\n- Skip plan blocks for simple one-shot tasks.\n- When a material architecture fork exists, pause and ask one concise clarification (or use ask_user when available) before implementation.\n- Treat verification as mandatory after edits: tests, type checks, linters, or a precise explanation of why verification was not possible.\n- For complex requests, execute plan steps in order, close each step explicitly, and finish the full plan unless blocked.\n- If the user explicitly asks for subagents/agents orchestration, you MUST use the task tool rather than doing all work in the main agent.\n- For explicit subagent/orchestration requests, execute at least one task tool call before giving a final prose-only answer.\n- Do not expose internal orchestration scaffolding to the user (for example: [ORCHESTRATION_DIRECTIVE], pseudo tool-call JSON, or raw task arguments).\n- When invoking tools, call them directly without preambles like \"I will now call tool X\"; only report outcomes that matter to the user.\n- Respect orchestration constraints from the user exactly: count, parallel vs sequential execution, per-agent profile, and per-agent working directory (cwd) when provided.\n- For explicit parallel orchestration requests, issue multiple independent task tool calls to match the requested agent count; do not collapse to a single subagent unless the user asks for one.\n- For explicit parallel orchestration requests, emit independent task calls in a single assistant turn whenever possible so they can be launched together.\n- Runtime note: when parallel orchestration is requested, emit independent task calls in one assistant turn so they can run concurrently; avoid background mode unless the user explicitly asks for detached async runs.\n- If orchestration constraints are ambiguous or conflict, ask one concise clarification (or use ask_user when available) before launching subagents.\n- When the user provides an <orchestrate ...>...</orchestrate> block, treat it as an execution contract and follow its mode/agents/profile/cwd assignments strictly.\n- When orchestration assignments include run_id/task_id/lock_key or depends_on, enforce them in task calls (run_id/task_id for team tracking, lock_key for serialization domains, depends_on for ordering).\n- For write-heavy parallel orchestration, prefer isolation=worktree to reduce cross-agent interference when the repository is git-backed.\n- If the user message includes @<custom-agent-name>, treat it as an explicit agent selection and call task with agent set to that custom agent name.\n\niosm-cli reference docs (use when needed):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), package composition (docs/packages.md)\n- When working on harness internals, read the relevant docs/examples before implementing`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\t// Append project context files\n\tif (contextFiles.length > 0) {\n\t\tprompt += \"\\n\\n# Project Context\\n\\n\";\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\tprompt += `## ${filePath}\\n\\n${content}\\n\\n`;\n\t\t}\n\t}\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date/time and working directory last\n\tprompt += `\\nCurrent date and time: ${dateTime}`;\n\tprompt += `\\nCurrent working directory: ${resolvedCwd}`;\n\n\treturn prompt;\n}\n"]}
1
+ {"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/core/system-prompt.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAc,MAAM,aAAa,CAAC;AAEhE,0CAA0C;AAC1C,MAAM,gBAAgB,GAA2B;IAChD,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,8CAA8C;IACpD,IAAI,EAAE,4DAA4D;IAClE,KAAK,EAAE,2BAA2B;IAClC,IAAI,EAAE,yDAAyD;IAC/D,IAAI,EAAE,kDAAkD;IACxD,EAAE,EAAE,yBAAyB;IAC7B,EAAE,EAAE,+FAA+F;IACnG,EAAE,EAAE,yCAAyC;IAC7C,QAAQ,EACP,uHAAuH;IACxH,KAAK,EACJ,wGAAwG;IACzG,EAAE,EAAE,yCAAyC;IAC7C,EAAE,EAAE,mDAAmD;IACvD,OAAO,EAAE,mDAAmD;IAC5D,GAAG,EAAE,oEAAoE;IACzE,eAAe,EACd,4FAA4F;IAC7F,IAAI,EAAE,6MAA6M;CACnN,CAAC;AAqBF,kEAAkE;AAClE,MAAM,UAAU,iBAAiB,CAAC,UAAoC,EAAE;IACvE,MAAM,EACL,YAAY,EACZ,aAAa,EACb,YAAY,EAC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AAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElE,IAAI,MAAM,GAAG;;;EAGZ,SAAS;;;;;EAKT,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAgCY,UAAU;qBACb,QAAQ;cACf,YAAY;;yFAE+D,CAAC;IAEzF,IAAI,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,aAAa,CAAC;IACzB,CAAC;IAED,+BAA+B;IAC/B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,2BAA2B,CAAC;QACtC,MAAM,IAAI,mDAAmD,CAAC;QAC9D,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;YACxD,MAAM,IAAI,MAAM,QAAQ,OAAO,OAAO,MAAM,CAAC;QAC9C,CAAC;IACF,CAAC;IAED,yDAAyD;IACzD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,2CAA2C;IAC3C,MAAM,IAAI,4BAA4B,QAAQ,EAAE,CAAC;IACjD,MAAM,IAAI,gCAAgC,WAAW,EAAE,CAAC;IAExD,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/**\n * System prompt construction and project context loading\n */\n\nimport { getDocsPath, getExamplesPath, getReadmePath } from \"../config.js\";\nimport { formatSkillsForPrompt, type Skill } from \"./skills.js\";\n\n/** Tool descriptions for system prompt */\nconst toolDescriptions: Record<string, string> = {\n\tread: \"Read file contents\",\n\tbash: \"Execute bash commands (ls, grep, find, etc.)\",\n\tedit: \"Make surgical edits to files (find exact text and replace)\",\n\twrite: \"Create or overwrite files\",\n\tgrep: \"Search file contents for patterns (respects .gitignore)\",\n\tfind: \"Find files by glob pattern (respects .gitignore)\",\n\tls: \"List directory contents\",\n\trg: \"Run ripgrep directly for advanced regex search (prefer explicit path args, e.g. -n pattern .)\",\n\tfd: \"Run fd directly for fast file discovery\",\n\tast_grep:\n\t\t\"Run ast-grep for AST/syntax-aware structural code search (prefer run --pattern; retry with scan/-p on older versions)\",\n\tcomby:\n\t\t\"Run comby for structural pattern search/rewrite previews (prefer explicit -matcher; no in-place edits)\",\n\tjq: \"Run jq for JSON querying/transformation\",\n\tyq: \"Run yq for YAML/JSON/TOML querying/transformation\",\n\tsemgrep: \"Run semgrep for structural/static security checks\",\n\tsed: \"Run sed for stream editing/extraction previews (no in-place edits)\",\n\tsemantic_search:\n\t\t\"Semantic embeddings search over the project index (actions: status, index, rebuild, query)\",\n\ttask: \"Run a specialized subagent (supports profile, cwd, lock_key for optional write serialization, run_id/task_id, model override, background mode for detached runs, and agent=<custom name from .iosm/agents>)\",\n};\n\nexport interface BuildSystemPromptOptions {\n\t/** Custom system prompt (replaces default). */\n\tcustomPrompt?: string;\n\t/** Tools to include in prompt. Default: [read, bash, edit, write] */\n\tselectedTools?: string[];\n\t/** Optional one-line tool snippets keyed by tool name. */\n\ttoolSnippets?: Record<string, string>;\n\t/** Additional guideline bullets appended to the default system prompt guidelines. */\n\tpromptGuidelines?: string[];\n\t/** Text to append to system prompt. */\n\tappendSystemPrompt?: string;\n\t/** Working directory. Default: process.cwd() */\n\tcwd?: string;\n\t/** Pre-loaded context files. */\n\tcontextFiles?: Array<{ path: string; content: string }>;\n\t/** Pre-loaded skills. */\n\tskills?: Skill[];\n}\n\n/** Build the system prompt with tools, guidelines, and context */\nexport function buildSystemPrompt(options: BuildSystemPromptOptions = {}): string {\n\tconst {\n\t\tcustomPrompt,\n\t\tselectedTools,\n\t\ttoolSnippets,\n\t\tpromptGuidelines,\n\t\tappendSystemPrompt,\n\t\tcwd,\n\t\tcontextFiles: providedContextFiles,\n\t\tskills: providedSkills,\n\t} = options;\n\tconst resolvedCwd = cwd ?? process.cwd();\n\n\tconst now = new Date();\n\tconst dateTime = now.toLocaleString(\"en-US\", {\n\t\tweekday: \"long\",\n\t\tyear: \"numeric\",\n\t\tmonth: \"long\",\n\t\tday: \"numeric\",\n\t\thour: \"2-digit\",\n\t\tminute: \"2-digit\",\n\t\tsecond: \"2-digit\",\n\t\ttimeZoneName: \"short\",\n\t});\n\n\tconst appendSection = appendSystemPrompt ? `\\n\\n${appendSystemPrompt}` : \"\";\n\n\tconst contextFiles = providedContextFiles ?? [];\n\tconst skills = providedSkills ?? [];\n\n\tif (customPrompt) {\n\t\tlet prompt = customPrompt;\n\n\t\tif (appendSection) {\n\t\t\tprompt += appendSection;\n\t\t}\n\n\t\t// Append project context files\n\t\tif (contextFiles.length > 0) {\n\t\t\tprompt += \"\\n\\n# Project Context\\n\\n\";\n\t\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\t\tprompt += `## ${filePath}\\n\\n${content}\\n\\n`;\n\t\t\t}\n\t\t}\n\n\t\t// Append skills section (only if read tool is available)\n\t\tconst customPromptHasRead = !selectedTools || selectedTools.includes(\"read\");\n\t\tif (customPromptHasRead && skills.length > 0) {\n\t\t\tprompt += formatSkillsForPrompt(skills);\n\t\t}\n\n\t\t// Add date/time and working directory last\n\t\tprompt += `\\nCurrent date and time: ${dateTime}`;\n\t\tprompt += `\\nCurrent working directory: ${resolvedCwd}`;\n\n\t\treturn prompt;\n\t}\n\n\t// Get absolute paths to documentation and examples\n\tconst readmePath = getReadmePath();\n\tconst docsPath = getDocsPath();\n\tconst examplesPath = getExamplesPath();\n\n\t// Build tools list based on selected tools.\n\t// Built-ins use toolDescriptions. Custom tools can provide one-line snippets.\n\tconst tools = selectedTools || [\"read\", \"bash\", \"edit\", \"write\"];\n\tconst toolsList =\n\t\ttools.length > 0\n\t\t\t? tools\n\t\t\t\t\t.map((name) => {\n\t\t\t\t\t\tconst snippet = toolSnippets?.[name] ?? toolDescriptions[name] ?? name;\n\t\t\t\t\t\treturn `- ${name}: ${snippet}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\")\n\t\t\t: \"(none)\";\n\n\t// Build guidelines based on which tools are actually available\n\tconst guidelinesList: string[] = [];\n\tconst guidelinesSet = new Set<string>();\n\tconst addGuideline = (guideline: string): void => {\n\t\tif (guidelinesSet.has(guideline)) {\n\t\t\treturn;\n\t\t}\n\t\tguidelinesSet.add(guideline);\n\t\tguidelinesList.push(guideline);\n\t};\n\n\tconst hasBash = tools.includes(\"bash\");\n\tconst hasEdit = tools.includes(\"edit\");\n\tconst hasWrite = tools.includes(\"write\");\n\tconst hasGrep = tools.includes(\"grep\");\n\tconst hasFind = tools.includes(\"find\");\n\tconst hasLs = tools.includes(\"ls\");\n\tconst hasRg = tools.includes(\"rg\");\n\tconst hasFd = tools.includes(\"fd\");\n\tconst hasAstGrep = tools.includes(\"ast_grep\");\n\tconst hasComby = tools.includes(\"comby\");\n\tconst hasJq = tools.includes(\"jq\");\n\tconst hasYq = tools.includes(\"yq\");\n\tconst hasSemgrep = tools.includes(\"semgrep\");\n\tconst hasSed = tools.includes(\"sed\");\n\tconst hasSemanticSearch = tools.includes(\"semantic_search\");\n\tconst hasRead = tools.includes(\"read\");\n\n\t// File exploration guidelines\n\tif (hasBash && !hasGrep && !hasFind && !hasLs && !hasRg && !hasFd) {\n\t\taddGuideline(\"Use bash for file operations like ls, rg, find; prefer rg for targeted search when available\");\n\t} else if (hasBash && (hasGrep || hasFind || hasLs || hasRg || hasFd)) {\n\t\taddGuideline(\"Prefer grep/find/ls/rg/fd tools over bash for codebase exploration (faster and less noisy)\");\n\t}\n\n\tif (hasRg || hasFd || hasAstGrep || hasComby || hasJq || hasYq || hasSemgrep || hasSed || hasSemanticSearch) {\n\t\taddGuideline(\n\t\t\t\"Route work to specialized tools first: rg/fd (search/discovery), semantic_search (concept-level retrieval), ast_grep/comby (structural code queries), jq/yq (data/config transforms), semgrep (risk scans), sed (stream extraction)\",\n\t\t);\n\t}\n\n\tif (hasAstGrep || hasComby) {\n\t\taddGuideline(\"Use ast_grep/comby for syntax-aware structural queries before falling back to broad regex\");\n\t}\n\n\tif (hasComby) {\n\t\taddGuideline(\"Use comby to preview structural rewrite matches first, then apply final changes via edit/write\");\n\t}\n\n\tif (hasJq || hasYq) {\n\t\taddGuideline(\"Prefer jq/yq over ad-hoc shell parsing when extracting or transforming JSON/YAML/TOML\");\n\t}\n\n\tif (hasSemgrep) {\n\t\taddGuideline(\"Use semgrep for rule-based risk scans and structural security checks when relevant\");\n\t}\n\n\tif (hasSed) {\n\t\taddGuideline(\"Use sed for preview/extraction workflows only; perform final file edits with edit/write\");\n\t}\n\n\tif (hasSemanticSearch) {\n\t\taddGuideline(\n\t\t\t\"Use semantic_search for intent/meaning queries that are hard to express with regex; use rg/ast_grep for exact symbol and syntax matches\",\n\t\t);\n\t\taddGuideline(\n\t\t\t\"semantic_search query can auto-refresh stale indexes when semantic auto-index is enabled (default); if disabled or if provider/chunk/filter changes require it, run semantic_search index/rebuild explicitly\",\n\t\t);\n\t}\n\n\tif (hasRg || hasAstGrep || hasComby) {\n\t\taddGuideline(\n\t\t\t\"For rg/ast_grep/comby, pass explicit target paths to avoid cwd ambiguity; if syntax errors occur (especially ast_grep), retry once with version-compatible command forms before concluding no matches\",\n\t\t);\n\t}\n\n\tif (\n\t\thasBash &&\n\t\t(hasRg || hasFd || hasAstGrep || hasComby || hasJq || hasYq || hasSemgrep || hasSed || hasSemanticSearch)\n\t) {\n\t\taddGuideline(\n\t\t\t\"If a required CLI tool is missing, install it first when permitted (rg/fd can be auto-managed; others via brew/apt/pipx/npm), then continue with that tool instead of broad bash fallback. For semantic_search, configure provider/index first via /semantic setup.\",\n\t\t);\n\t}\n\n\t// Read before edit guideline\n\tif (hasRead && hasEdit) {\n\t\taddGuideline(\"Use read to examine files before editing. You must use this tool instead of cat or sed.\");\n\t}\n\n\t// Edit guideline\n\tif (hasEdit) {\n\t\taddGuideline(\"Use edit for precise changes (old text must match exactly)\");\n\t}\n\n\t// Write guideline\n\tif (hasWrite) {\n\t\taddGuideline(\"Use write only for new files or complete rewrites\");\n\t}\n\n\t// Output guideline (only when actually writing or executing)\n\tif (hasEdit || hasWrite) {\n\t\taddGuideline(\n\t\t\t\"When summarizing your actions, output plain text directly - do NOT use cat or bash to display what you did\",\n\t\t);\n\t}\n\n\taddGuideline(\"Inspect the relevant files before editing and keep exploration bounded to the task\");\n\taddGuideline(\"Make reasonable assumptions and continue unless a risky ambiguity blocks the work\");\n\taddGuideline(\"Classify requests as simple vs complex: execute simple work immediately, use a step plan for complex work\");\n\taddGuideline(\"For complex work, publish a short step plan before edits and keep step statuses current while executing\");\n\taddGuideline(\"If a meaningful architecture or product fork changes implementation, ask a concise clarification before editing\");\n\taddGuideline(\"After changes, run the smallest relevant verification and report the concrete result\");\n\taddGuideline(\"Do not claim success without evidence; if you could not verify, say so explicitly\");\n\taddGuideline(\"Complete the requested task end-to-end when possible instead of stopping at analysis\");\n\taddGuideline(\"For code review requests, lead with findings and risks before summaries\");\n\taddGuideline(\n\t\t\"When an active engineering contract is present in context, treat its constraints, quality gates, and definition_of_done as execution requirements unless user overrides them.\",\n\t);\n\taddGuideline(\"For major feature forks, run a /singular feasibility pass before coding to compare implementation options.\");\n\n\tfor (const guideline of promptGuidelines ?? []) {\n\t\tconst normalized = guideline.trim();\n\t\tif (normalized.length > 0) {\n\t\t\taddGuideline(normalized);\n\t\t}\n\t}\n\n\t// Always include these\n\taddGuideline(\"Be concise in your responses\");\n\taddGuideline(\"Show file paths clearly when working with files\");\n\n\tconst guidelines = guidelinesList.map((g) => `- ${g}`).join(\"\\n\");\n\n\tlet prompt = `You are a professional software engineering agent operating inside iosm-cli. Help users inspect systems, change code, run commands, maintain project artifacts when needed, and explain results clearly.\n\nAvailable tools:\n${toolsList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n${guidelines}\n\nOperating defaults:\n- Summarize work in standard engineering language first: what you inspected, what you changed, what you verified, and any remaining risk or blocker.\n- Do NOT start by reading documentation unless the user asks for documentation help, asks about harness internals, or implementation is blocked without it.\n- Start implementation turns with a quick repository scan of the files most likely to matter before proposing or editing.\n- Prefer targeted reads and searches over broad dumps; keep command output bounded and focused.\n- For complex tasks, include a machine-readable plan block before edits and update it when statuses change:\n <task_plan complexity=\"complex\">\n - [in_progress] Current step\n - [pending] Next step\n </task_plan>\n- Skip plan blocks for simple one-shot tasks.\n- When a material architecture fork exists, pause and ask one concise clarification (or use ask_user when available) before implementation.\n- Treat verification as mandatory after edits: tests, type checks, linters, or a precise explanation of why verification was not possible.\n- For complex requests, execute plan steps in order, close each step explicitly, and finish the full plan unless blocked.\n- If the user explicitly asks for subagents/agents orchestration, you MUST use the task tool rather than doing all work in the main agent.\n- For explicit subagent/orchestration requests, execute at least one task tool call before giving a final prose-only answer.\n- Do not expose internal orchestration scaffolding to the user (for example: [ORCHESTRATION_DIRECTIVE], pseudo tool-call JSON, or raw task arguments).\n- When invoking tools, call them directly without preambles like \"I will now call tool X\"; only report outcomes that matter to the user.\n\t- Respect orchestration constraints from the user exactly: count, parallel vs sequential execution, per-agent profile, and per-agent working directory (cwd) when provided.\n\t- Treat explicit orchestration requests in any language as constraints (including non-English text and minor typos).\n\t- For explicit parallel orchestration requests, issue multiple independent task tool calls to match the requested agent count; do not collapse to a single subagent unless the user asks for one.\n- For explicit parallel orchestration requests, emit independent task calls in a single assistant turn whenever possible so they can be launched together.\n- Runtime note: when parallel orchestration is requested, emit independent task calls in one assistant turn so they can run concurrently; avoid background mode unless the user explicitly asks for detached async runs.\n- If orchestration constraints are ambiguous or conflict, ask one concise clarification (or use ask_user when available) before launching subagents.\n- When the user provides an <orchestrate ...>...</orchestrate> block, treat it as an execution contract and follow its mode/agents/profile/cwd assignments strictly.\n- When orchestration assignments include run_id/task_id/lock_key or depends_on, enforce them in task calls (run_id/task_id for team tracking, lock_key for serialization domains, depends_on for ordering).\n- For write-heavy parallel orchestration, prefer isolation=worktree to reduce cross-agent interference when the repository is git-backed.\n- If the user message includes @<custom-agent-name>, treat it as an explicit agent selection and call task with agent set to that custom agent name.\n\niosm-cli reference docs (use when needed):\n- Main documentation: ${readmePath}\n- Additional docs: ${docsPath}\n- Examples: ${examplesPath} (extensions, custom tools, SDK)\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), package composition (docs/packages.md)\n- When working on harness internals, read the relevant docs/examples before implementing`;\n\n\tif (appendSection) {\n\t\tprompt += appendSection;\n\t}\n\n\t// Append project context files\n\tif (contextFiles.length > 0) {\n\t\tprompt += \"\\n\\n# Project Context\\n\\n\";\n\t\tprompt += \"Project-specific instructions and guidelines:\\n\\n\";\n\t\tfor (const { path: filePath, content } of contextFiles) {\n\t\t\tprompt += `## ${filePath}\\n\\n${content}\\n\\n`;\n\t\t}\n\t}\n\n\t// Append skills section (only if read tool is available)\n\tif (hasRead && skills.length > 0) {\n\t\tprompt += formatSkillsForPrompt(skills);\n\t}\n\n\t// Add date/time and working directory last\n\tprompt += `\\nCurrent date and time: ${dateTime}`;\n\tprompt += `\\nCurrent working directory: ${resolvedCwd}`;\n\n\treturn prompt;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { AgentTool } from "@mariozechner/pi-agent-core";
2
+ import { type Static } from "@sinclair/typebox";
3
+ import { type SharedMemoryContext } from "../shared-memory.js";
4
+ declare const sharedMemoryWriteSchema: import("@sinclair/typebox").TObject<{
5
+ key: import("@sinclair/typebox").TString;
6
+ value: import("@sinclair/typebox").TString;
7
+ scope: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"run">, import("@sinclair/typebox").TLiteral<"task">]>>;
8
+ mode: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"set">, import("@sinclair/typebox").TLiteral<"append">]>>;
9
+ if_version: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
10
+ }>;
11
+ declare const sharedMemoryReadSchema: import("@sinclair/typebox").TObject<{
12
+ key: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
13
+ prefix: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
14
+ scope: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"run">, import("@sinclair/typebox").TLiteral<"task">]>>;
15
+ limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
16
+ include_values: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
17
+ }>;
18
+ export type SharedMemoryWriteInput = Static<typeof sharedMemoryWriteSchema>;
19
+ export type SharedMemoryReadInput = Static<typeof sharedMemoryReadSchema>;
20
+ export declare function createSharedMemoryWriteTool(context: SharedMemoryContext): AgentTool<typeof sharedMemoryWriteSchema>;
21
+ export declare function createSharedMemoryReadTool(context: SharedMemoryContext): AgentTool<typeof sharedMemoryReadSchema>;
22
+ export {};
23
+ //# sourceMappingURL=shared-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-memory.d.ts","sourceRoot":"","sources":["../../../src/core/tools/shared-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAQ,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAEN,KAAK,mBAAmB,EAIxB,MAAM,qBAAqB,CAAC;AAE7B,QAAA,MAAM,uBAAuB;;;;;;EAwB3B,CAAC;AAEH,QAAA,MAAM,sBAAsB;;;;;;EA8B1B,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC5E,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAwB1E,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAC,OAAO,uBAAuB,CAAC,CA+BnH;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS,CAAC,OAAO,sBAAsB,CAAC,CA4CjH"}