@astrosheep/square 0.3.8 → 0.3.9

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "square",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Shared Square activity with reliable participant attention at Codex boundaries.",
5
5
  "author": {
6
6
  "name": "Square"
@@ -133,7 +133,7 @@ export function parseGlobalArgs(rawArgs) {
133
133
  validateName(name);
134
134
  const explicitSquarePath = requestedPath !== undefined;
135
135
  const command = args[0];
136
- const resolved = !explicitSquarePath && !['ls', 'list', 'version'].includes(command ?? '')
136
+ const resolved = !explicitSquarePath && !['ls', 'list', 'version', 'install', 'uninstall'].includes(command ?? '')
137
137
  ? resolveDefaultSquarePath()
138
138
  : { path: requestedPath ?? DEFAULT_SQUARE_PATH, multiple: false };
139
139
  return { squarePath: resolved.path, explicitSquarePath, multipleSquares: resolved.multiple, name, args };
@@ -1,34 +1,77 @@
1
1
  import os from 'node:os';
2
2
  import { executeHarnessTarget, harnessTargets, } from '../harness.js';
3
+ function installTargets(intent, action) {
4
+ const available = harnessTargets().filter((target) => target.capabilities.includes(action));
5
+ const names = intent.all ? available.map((target) => target.name) : [...new Set(intent.targets)];
6
+ if (names.length === 0)
7
+ throw new Error(`${action} requires one or more targets, or --all`);
8
+ for (const name of names) {
9
+ if (!available.some((target) => target.name === name)) {
10
+ throw new Error(`Unknown ${action} target: ${name}`);
11
+ }
12
+ }
13
+ return names;
14
+ }
15
+ function parseInstall(argv, action) {
16
+ const all = argv.includes('--all');
17
+ const force = argv.includes('-f') || argv.includes('--force');
18
+ const allowedOptions = action === 'install' ? ['--all', '-f', '--force'] : ['--all'];
19
+ const option = argv.find((argument) => argument.startsWith('-') && !allowedOptions.includes(argument));
20
+ if (option !== undefined)
21
+ throw new Error(`Unknown ${action} option: ${option}`);
22
+ if (action === 'uninstall' && force)
23
+ throw new Error(`Unknown uninstall option: ${argv.find((item) => item === '-f' || item === '--force')}`);
24
+ const targets = argv.filter((argument) => !argument.startsWith('-'));
25
+ if (all && targets.length > 0)
26
+ throw new Error(`Cannot combine ${action} --all with named targets`);
27
+ return { targets, all, force };
28
+ }
29
+ function targetCommand(action) {
30
+ return {
31
+ parse(argv) { return parseInstall(argv, action); },
32
+ async execute(intent, context) {
33
+ const results = [];
34
+ for (const target of installTargets(intent, action)) {
35
+ results.push(await executeHarnessTarget(target, action, {
36
+ homeDir: context.homeDir,
37
+ squarePath: context.squarePath,
38
+ force: intent.force,
39
+ }));
40
+ }
41
+ return {
42
+ notes: results.flatMap((result) => result.notes),
43
+ lines: results.flatMap((result) => result.lines),
44
+ };
45
+ },
46
+ present(result) { process.stdout.write(formatHarnessResult(result)); },
47
+ };
48
+ }
49
+ export const installCommand = targetCommand('install');
50
+ export const uninstallCommand = targetCommand('uninstall');
3
51
  export const harnessCommand = {
4
52
  parse(argv) {
5
- const action = argv[0];
6
- if (action !== 'install' && action !== 'uninstall' && action !== 'doctor') {
7
- throw new Error('harness requires install, uninstall, or doctor');
8
- }
53
+ if (argv[0] !== 'doctor')
54
+ throw new Error('harness only supports doctor');
9
55
  const rest = argv.slice(1);
10
- const option = rest.find((argument) => argument.startsWith('-') && argument !== '-f' && argument !== '--force');
56
+ const option = rest.find((argument) => argument.startsWith('-'));
11
57
  if (option !== undefined)
12
58
  throw new Error(`Unknown harness option: ${option}`);
59
+ if (rest.length > 1)
60
+ throw new Error('harness doctor accepts at most one target');
13
61
  return {
14
- action,
15
- target: rest.find((argument) => !argument.startsWith('-')),
16
- force: rest.includes('-f') || rest.includes('--force'),
62
+ target: rest[0],
17
63
  };
18
64
  },
19
65
  async execute(intent, context) {
20
- if (intent.target === undefined && intent.action !== 'doctor') {
21
- throw new Error('harness install/uninstall requires an explicit target: skills | claude | codex | opencode | pi');
22
- }
23
66
  const targetNames = intent.target === undefined
24
67
  ? harnessTargets().map((target) => target.name)
25
68
  : [intent.target];
26
69
  const results = [];
27
70
  for (const target of targetNames) {
28
- results.push(await executeHarnessTarget(target, intent.action, {
71
+ results.push(await executeHarnessTarget(target, 'doctor', {
29
72
  homeDir: context.homeDir,
30
73
  squarePath: context.squarePath,
31
- force: intent.force,
74
+ force: false,
32
75
  }));
33
76
  }
34
77
  return {
@@ -1,6 +1,6 @@
1
1
  import { buildCommand, compactCommand, doneCommand, expressCommand, holdCommand, joinCommand, resumeCommand } from './square-commands.js';
2
2
  import { doctorCommand } from './maintenance-commands.js';
3
- import { harnessCommand } from './harness-command.js';
3
+ import { harnessCommand, installCommand, uninstallCommand } from './harness-command.js';
4
4
  import { helpCommand, versionCommand } from './meta-commands.js';
5
5
  import { catchCommand, claudeHookCommand, codexHookCommand, historyCommand, inboxCommand, listCommand, participantsCommand, statusCommand, streamCommand, warmupCommand, } from './observation-commands.js';
6
6
  /** Every public command is an executable adapter, including aliases and utility commands. */
@@ -17,6 +17,8 @@ export const commandRegistry = [
17
17
  { names: ['done'], spec: doneCommand },
18
18
  { names: ['hold'], spec: holdCommand },
19
19
  { names: ['resume'], spec: resumeCommand },
20
+ { names: ['install'], spec: installCommand },
21
+ { names: ['uninstall'], spec: uninstallCommand },
20
22
  { names: ['harness'], spec: harnessCommand },
21
23
  { names: ['compact'], spec: compactCommand },
22
24
  { names: ['doctor'], spec: doctorCommand },
@@ -22,17 +22,21 @@ export function installHarnessLinks(links, force = false) {
22
22
  if (!fs.existsSync(link.source)) {
23
23
  throw new Error(`Harness link source is missing: ${link.source}`);
24
24
  }
25
+ const existing = lstatMaybe(link.target);
25
26
  return {
26
27
  ...link,
27
- existing: lstatMaybe(link.target),
28
+ existing,
28
29
  sourceIsDirectory: fs.statSync(link.source).isDirectory(),
30
+ alreadyManaged: existing !== undefined && sameLink(link.source, link.target),
29
31
  };
30
32
  });
31
- for (const { target, existing } of prepared) {
32
- if (existing !== undefined && !force)
33
+ for (const { target, existing, alreadyManaged } of prepared) {
34
+ if (existing !== undefined && !alreadyManaged && !force)
33
35
  throw new Error(`Refusing to overwrite existing link: ${target}\nPass -f to replace it.`);
34
36
  }
35
- for (const { source, target, existing, sourceIsDirectory } of prepared) {
37
+ for (const { source, target, existing, sourceIsDirectory, alreadyManaged } of prepared) {
38
+ if (alreadyManaged)
39
+ continue;
36
40
  fs.mkdirSync(path.dirname(target), { recursive: true });
37
41
  if (existing !== undefined)
38
42
  fs.rmSync(target, { recursive: true, force: true });
package/dist/help.js CHANGED
@@ -48,9 +48,19 @@ const COMMANDS = [
48
48
  { names: ['hold'], usage: '--as <name> hold [reason | -]', usesSquare: true, group: 'participant', summary: 'Raise a hand and pause participant activity.' },
49
49
  { names: ['resume'], usage: '--as <name> resume', usesSquare: true, group: 'participant', summary: 'Lower the raised hand and resume activity.' },
50
50
  {
51
- names: ['harness'], usage: 'harness <install <skills|claude|codex|opencode|pi> [-f] | uninstall <skills|claude|codex|opencode|pi> | doctor [skills|claude|codex|opencode|pi|delivery]>', usesSquare: true, group: 'maintenance',
52
- summary: 'Install, remove, or diagnose official harness adapters.',
53
- details: ['Targets:', ' skills, claude, codex, opencode, pi Install, remove, or diagnose one adapter.', ' delivery Diagnose delivery only; skips when no readable artifact is selected.'],
51
+ names: ['install'], usage: 'install (--all | <target>...) [-f]', group: 'maintenance',
52
+ summary: 'Install Square support for one or more agent hosts.',
53
+ details: ['Targets:', ' skills, claude, codex, opencode, pi', '', 'Options:', ' --all Install every supported target.', ' -f, --force Replace existing managed links.'],
54
+ },
55
+ {
56
+ names: ['uninstall'], usage: 'uninstall (--all | <target>...)', group: 'maintenance',
57
+ summary: 'Remove Square support from one or more agent hosts.',
58
+ details: ['Targets:', ' skills, claude, codex, opencode, pi', '', 'Options:', ' --all Remove every supported target.'],
59
+ },
60
+ {
61
+ names: ['harness'], usage: 'harness doctor [skills|claude|codex|opencode|pi|delivery]', usesSquare: true, group: 'maintenance', hiddenFromIndex: true,
62
+ summary: 'Diagnose installed agent-host support.',
63
+ details: ['Targets:', ' skills, claude, codex, opencode, pi Diagnose one installed adapter.', ' delivery Diagnose delivery for the selected square.'],
54
64
  },
55
65
  { names: ['compact'], usage: 'compact [--keep N]', usesSquare: true, group: 'host', summary: 'Move older activity out of the working artifact while keeping the latest N.' },
56
66
  {
@@ -69,7 +79,7 @@ export function renderGlobalHelp() {
69
79
  const groups = [
70
80
  { key: 'participant', title: 'In the square:', order: ['join', 'express', 'catch', 'history', 'status', 'hold', 'resume', 'done'] },
71
81
  { key: 'host', title: 'Prepare and manage:', order: ['build', 'list', 'participants', 'warmup', 'compact'] },
72
- { key: 'maintenance', title: 'Setup and repair:', order: ['harness', 'doctor'] },
82
+ { key: 'maintenance', title: 'Setup and repair:', order: ['install', 'uninstall', 'doctor'] },
73
83
  ];
74
84
  const commandLines = groups.flatMap(({ key, title, order }) => [
75
85
  title,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrosheep/square",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "A shared public square where agents join, catch activity, express, and step out when done.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "square",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Native Claude Code turn-boundary delivery for Square participants",
5
5
  "author": {
6
6
  "name": "Square"