@skathio/somi 5.0.3 → 5.0.4

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.
@@ -13,7 +13,7 @@
13
13
  "url": "https://github.com/skathio/somi.git"
14
14
  },
15
15
  "description": "A workflow plugin for coding agents: say what you want or pass a ticket, and it picks the right workflow and keeps the cost down, while your agent stays in charge.",
16
- "version": "5.0.3",
16
+ "version": "5.0.4",
17
17
  "tags": [
18
18
  "workflow",
19
19
  "agents",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "somi",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "displayName": "SoMi",
5
5
  "description": "A workflow plugin for coding agents: say what you want or pass a ticket, and it picks the right workflow and keeps the cost down, while your agent stays in charge.",
6
6
  "keywords": [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "somi",
3
3
  "displayName": "SoMi",
4
- "version": "5.0.3",
4
+ "version": "5.0.4",
5
5
  "description": "A workflow plugin for coding agents: say what you want or pass a ticket, and it picks the right workflow and keeps the cost down, while your agent stays in charge.",
6
6
  "keywords": [
7
7
  "workflow",
@@ -11,7 +11,7 @@
11
11
  "name": "somi",
12
12
  "source": "github:skathio/somi",
13
13
  "description": "A workflow plugin for coding agents: say what you want or pass a ticket, and it picks the right workflow and keeps the cost down, while your agent stays in charge.",
14
- "version": "5.0.3",
14
+ "version": "5.0.4",
15
15
  "tags": [
16
16
  "workflow",
17
17
  "agents",
package/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.3
1
+ 5.0.4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skathio/somi",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "scripts": {
5
5
  "test": "node --test --test-reporter=spec tests/*.test.mjs",
6
6
  "test:coverage": "node -e \"require('fs').mkdirSync('coverage',{recursive:true})\" && node --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info tests/*.test.mjs",
@@ -118,7 +118,7 @@ const LARGE = (request) => String(request ?? '').length > LONG_REQUEST;
118
118
  // Everything here is done from the chat: the agent runs SoMi's own commands by their full path, because no somi command is on the PATH.
119
119
  const QUALITY_CONFIG = `Relay this briefly. To change a quality limit, write it under quality in the file named by global_config, or under quality.commit or quality.pr for one scope, never in the project's .somi/config.json, where only a tighter value counts. Before you write a value looser than the current limit, ask the user and wait for a yes. quality_timeout_seconds is how long the gate may run before it counts as failed: to change it, write quality.timeout_seconds there, a whole number from ${QUALITY_TIMEOUT.min} to ${QUALITY_TIMEOUT.max}.`;
120
120
  const SETUP = (host) => `To check SoMi's setup, run \`${somiCommand('doctor')}\` and relay what it finds. After tiers.main changes, run \`${somiCommand('setup')}\`. To connect another plugin to a step, run \`${somiCommand('slot <step> <plugin:component>')}\` with the step and component the user names, and \`${somiCommand('slot --list')}\` to show what is connected. To start sessions with SoMi's agent on its tier's model, \`${somiCommand('launch claude')}\` or \`${somiCommand('launch copilot')}\` does it, with anything after it passed to the host: give the user that command for an alias of their own.${host === 'claude' ? '' : ' SoMi registers the staged workflow, /somi-deliver, with Copilot for every project at session start, so there is nothing to run for it: a session that started before that gets it after /clear, and Copilot runs it only in experimental mode.'}`;
121
- const STAGED_ADVICE = (host) => `The user typed /somi-deliver to run this work in stages. Start the workflow below by its name with its args unchanged${host === 'claude' ? ', using the Workflow tool: it is a saved workflow, so no script and no authoring guide are needed' : ', as Copilot runs workflows in experimental mode. If Copilot says no workflow is registered by that name, this session started before SoMi registered it: tell the user that /clear or a new session loads it, and that /experimental must be on'}. Tell the user it is running and end your turn. When it returns, do not read or check the work again, because the workflow ran the checks: record its reviews with somi_review, passing tree as review_tree, and tell the user its summary and status in a few lines. If you cannot start it, say why, and call somi_route again with the same request and without staged for the steps.`;
121
+ const STAGED_ADVICE = (host) => `The user typed /somi-deliver to run this work in stages. Start the workflow below by its name with its args unchanged${host === 'claude' ? ', using the Workflow tool: it is a saved workflow, so no script and no authoring guide are needed' : ', as Copilot runs workflows in experimental mode. If Copilot says no workflow is registered by that name, this session started before SoMi registered it: reload extensions with the extensions reload tool, which registers it without losing the conversation, then start the workflow again; failing that, tell the user that /clear or a new session loads it. /experimental must be on'}. Tell the user it is running and end your turn. When it returns, do not read or check the work again, because the workflow ran the checks: record its reviews with somi_review, passing tree as review_tree, and tell the user its summary and status in a few lines. If you cannot start it, say why, and call somi_route again with the same request and without staged for the steps.`;
122
122
  const SUGGEST_STAGED = 'This looks like large work. Tell the user once that typing /somi-deliver with it runs it in stages, each on its tier, and that only they can start that. Then follow steps.';
123
123
 
124
124
  // With no rule to go on and the whole table to choose from, a request is new work. Asking the model to pick costs a turn and lets it
@@ -13,6 +13,8 @@ const PROJECT_MARK = '// Written by somi init:';
13
13
 
14
14
  const isLink = (p) => { try { return fs.lstatSync(p).isSymbolicLink(); } catch { return false; } };
15
15
 
16
+ export const copilotHomeExists = (env = process.env, home = os.homedir()) => fs.existsSync(env.COPILOT_HOME || path.join(home, '.copilot'));
17
+
16
18
  export const copilotExtensionFile = (env = process.env, home = os.homedir()) => path.join(env.COPILOT_HOME || path.join(home, '.copilot'), 'extensions', 'somi', 'extension.mjs');
17
19
 
18
20
  // A few lines that load SoMi's own module from the plugin. When the plugin is gone, it joins with nothing rather than failing to load.
package/scripts/somi.mjs CHANGED
@@ -12,7 +12,7 @@
12
12
  // somi status | migrate
13
13
  // somi setup [--host claude|copilot] makes SoMi the session agent, on the model set for its tier
14
14
  // somi doctor [--host claude|copilot] [--profile]
15
- // somi init --host copilot registers the staged workflow with Copilot CLI, once for every project
15
+ // somi init [--host copilot] registers the staged workflow with Copilot CLI, once for every project
16
16
  // somi launch claude|copilot [args...] starts the host with SoMi's agent, on the model set for its tier
17
17
  //
18
18
  // Exit codes: 0 done, 1 a check, the doctor or the pull request gate failed, 64 the request was refused.
@@ -28,7 +28,7 @@ import { runCheck } from './lib/check.mjs';
28
28
  import { ConfigFileError, globalConfigPath, loadConfig, readConfigFile } from './lib/config-files.mjs';
29
29
  import { duplicateHookWarnings, runDoctor } from './lib/doctor.mjs';
30
30
  import { commitBase, listFiles, repoRoot, resolveRef, snapshotTree, stateIsTracked, workBase } from './lib/git-tree.mjs';
31
- import { installCopilotExtension, projectExtensionWarnings } from './lib/init.mjs';
31
+ import { copilotHomeExists, installCopilotExtension, projectExtensionWarnings } from './lib/init.mjs';
32
32
  import { LAUNCH_HOSTS, launchPlan, spawnPlan } from './lib/launch.mjs';
33
33
  import { addToLedger, readLedger } from './lib/ledger.mjs';
34
34
  import { migrate } from './lib/migrate.mjs';
@@ -146,13 +146,19 @@ function slotCommand(ctx, args) {
146
146
  return 0;
147
147
  }
148
148
 
149
- // The session-start hook does this on its own, so init is for a session that started before the plugin was installed.
149
+ // The session-start hook does this on its own, so init is for a session that started before the plugin was installed. Without --host it
150
+ // finds Copilot CLI by its environment or its folder, and on Claude Code it has nothing to do.
151
+ const RELOAD = 'A file that is current is not yet a loaded extension. In the open session, reload extensions (the extensions reload tool) to register the workflow without losing the conversation, or start a new session or /clear. Copilot runs workflows in experimental mode: start with --experimental, or turn it on with /experimental.';
150
152
  function initCommand(ctx, args) {
151
153
  const { values } = parseArgs({ args, options: { host: { type: 'string' } } });
152
- if (values.host !== 'copilot') throw new StateError('init takes --host copilot; the Claude Code plugin needs no setup');
154
+ if (values.host !== undefined && values.host !== 'copilot' && values.host !== 'claude') throw new StateError('init takes --host copilot or --host claude');
155
+ // An explicit SOMI_HOST wins; the folder is only a guess for when nothing says which host this is.
156
+ const named = ctx.env.SOMI_HOST === 'claude' || ctx.env.SOMI_HOST === 'copilot';
157
+ const host = values.host ?? (detectHost(ctx.env) === 'copilot' || (!named && copilotHomeExists(ctx.env)) ? 'copilot' : 'claude');
158
+ if (host === 'claude') { print({ host, extension: null, workflows: 'The Claude Code plugin needs no setup.' }); return 0; }
153
159
  const extension = installCopilotExtension({ pluginRoot: PLUGIN_ROOT, env: ctx.env });
154
160
  const warnings = [...duplicateHookWarnings(ctx.root), ...projectExtensionWarnings(ctx.root)];
155
- print({ extension, workflows: 'Copilot loads it at the next session start or after /clear, and runs workflows in experimental mode: start with --experimental, or turn it on with /experimental.', ...(warnings.length ? { warnings } : {}) });
161
+ print({ host, extension, workflows: RELOAD, ...(warnings.length ? { warnings } : {}) });
156
162
  return extension.written || extension.current ? 0 : 1;
157
163
  }
158
164